springjools / deluge-autoremoveplus

Auto removing of deluge torrents
43 stars 5 forks source link

Python 3 support #16

Open camjac251 opened 4 years ago

camjac251 commented 4 years ago

Is this supported for python 3? I'm on Python 3.6.10 and tried compiling it with my pipx virtualenv I made for the latest dev version of deluge but got this error.

byte-compiling build/bdist.linux-x86_64/egg/autoremoveplus/gtkui.py to gtkui.cpython-36.pyc
  File "build/bdist.linux-x86_64/egg/autoremoveplus/gtkui.py", line 147
    def on_menu_show(menu, (menu_item, toggled)):
                           ^
SyntaxError: invalid syntax

Similar issue here

Having an issue with the .egg install. Using delugevpn . Doesn't show up in Deluge after.

https://i.imgur.com/HO1qAiv.png

Byte-compiling build/bdist.linux-x86_64/egg/autoremoveplus/gtkui.py to gtkui.cpython-38.pyc File "build/bdist.linux-x86_64/egg/autoremoveplus/gtkui.py", line 147 def on_menu_show(menu, (menu_item, toggled)): ^ SyntaxError: invalid syntax

byte-compiling build/bdist.linux-x86_64/egg/autoremoveplus/mediaserver.py to mediaserver.cpython-38.pyc byte-compiling build/bdist.linux-x86_64/egg/autoremoveplus/webui.py to webui.cpython-38.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO

Originally posted by @exzacklyright in https://github.com/springjools/deluge-autoremoveplus/issues/3#issuecomment-568081574

camjac251 commented 4 years ago

I tried to fix it myself, but not sure if it's proper. I changed def on_menu_show(menu, (menu_item, toggled)): to def on_menu_show(menu, menu_item, toggled):

No error on compilation but when I add it to deluge (latest dev commit) using the unofficial windows build to my linux server (since web will upload as filename [object FileList]. If I try to enable the one uploaded using the windows client, it doesn't enable. It's in the plugins folder but just won't enable

y0da822 commented 4 years ago

Same exact issue here using docker container for deluge from linuxserver.io

y0da822 commented 4 years ago

was able to make this work

With the linuxio deluge docker container, I had to download the autoremover from here https://github.com/springjools/deluge-autoremoveplus then I had to compile it with python 3.6 using python3.6 setup.py bdist_egg. This made the egg file that would work with my container which was running python3.6.

But before it will actually work - this was the real kicker - the docker container from linuxserverio for deluge is missing python library requests ( https://github.com/linuxserver/docker-deluge/issues/87 ). So I had to exec into the container docker exec -it deluge /bin/bash and install the requests module with apt-get update && apt-get install -y python3-requests python3-future . THen I restarted the container and I was able to check turn on the plugin and configure it via the webui.

camjac251 commented 4 years ago

This doesn't work for me as I still get the invalid syntax error. Requests was already installed as a package and in my virtual environment, only python 3 exists so python is python 3.

y0da822 commented 4 years ago

So you see it in the plugins list but when you check it it unchecks itself? Right?

If so what’s your deluge log saying when it tries to load the plugin? That’s where I saw the issue with mine which was missing requests package.

mhertz commented 4 years ago

If anybody wants this plugin in the unofficial deluge2 installer for windows(as mentioned earlier), then here's instructions, and this was done using the nice help of camjac251 and y0da822, thanks guys! :) Note, this plugin can be enabled and used in GTK-UI, but needs actual setting up to be done in webui or from it's config file directly, and then thereafter can be used from GTK-UI, just not can be configured from there.

Anyway, download and unzip this archive linked below, and then copy the plugin to your plugin folder under deluge profile folder(plugin includes fix from camjac251 and is built for py3.8, but can be renamed to suit other python versions), and unpack the contents of deps.zip which also is included in link, into 'InstallDir\Lib\site-packages'.

As stated by y0da822, then requests and past from future(or whole future, if dosen't caring about saving little over 2mb, as I omitted in link), and urllib3 is a dep to requests needed too, as missing from deluge and it's installed deps(The other deps of requests are already installed by deluge's deps).

Note, needs new version of unofficial installer, as just recently changed to py38 and previous was py37, so if using older version, then rename plugin to have py3.7 in name and should work still.

http://s000.tinyupload.com/index.php?file_id=09831498366885208005

Edit: Sorry, missed that future(past specifically) wasen't needed anymore in later commits, so rebuilded above archive without that module added, so use this download link here instead(though the above still works fine, just features a redundant module):

http://s000.tinyupload.com/index.php?file_id=00290673701628685910

Edit2: I rebuilt deluge/installers with both requests and future included, for this and possible other plugins too, so disregard and ignore the deps.zip included in above zip and just use the plugin, but if not updating to newest installers, then you still need the deps.zip though.

Edit3: Since only a single commit added extra since last release of plugin, and not important commit, then might as well just download and use latest release version here, instead of using the plugin I linked previously.

springjools commented 4 years ago

Hey, sorry for the late response. Yes, autoremoveplus supports python3. It uses gtk3ui.py for python3 and gtkui.py for python2.

But as I wrote in the release notes: I haven't tested the plugin with gtk since I don't have a running linux machine. I have only tested it with the webui. I assume it would be quite easy to make the gtk also work, but I can't do that until I manage to install a VM. Just reinstalled windows so I don't have that yet. I do have a bunch of raspberries that I test on.

springjools commented 4 years ago

And yes mediaserver needs requests library and deluge itself needs the future package, as long as we are instructed to also support python 2. I don't know how many actually use python 2 but for deluge 1.3 it's needed at least.

mhertz commented 4 years ago

Thanks for your work springjools. As stated by others, it fails building currently, atleast for py38 which is latest version(3.8.2) and reported too under 3.6.10. The fix posted by camjac251 here, works for building at-least. BTW, deluge2 doesn't currently depend on future module, so not installed by many distros, but you dropped 'past' requirements recently I saw, so only requests needed now and it's deps, i.e urllib3 specifically as far as deps not already installed in deluge.

For everybody needing this in meantime and not using unofficial deluge2 windows installer, then zip linked in last post of mine still works, and just rename 3.8 in filename of plugin to whatever you have installed of py3, and just ignore the included deps.zip. As said, you need install python3 version of requests if missing, from distro package manager, probably named python3-requests, or on arch-linux, python-requests, or just use 'pip3 install requests'.

Edit: As I also edited into my previous post here, then since only a single commit added extra since last release of plugin, and not important commit, then might as well just download and use latest release version here, instead of using the plugin I linked previously.

springjools commented 4 years ago

Yes, I originally converted the plugin to python 3 using the six module, but when I manually went through the code I could eliminate the specifics for python 2 (silly things like old division for example).

Requests is needed to communicate with sonarr etc, but not sure how many actually want this, so maybe this could indeed be branched off to a separate plugin. But it's included now for simplicity, and it's not a very exotic library to use anyway.

There are many things still to develop but it's a bit unclear to me what people actually want. Only those who have problems are active in commenting anyway.

mhertz commented 4 years ago

I don't understand how you can build this plugin yourself, as fails for me and others here without said fix posted previously here from camjac251. Would you consider adding said fix, thanks? Fails for me with py382, and reported failing with py36. It fails in a gtk2 part though... Hmm, before sending this post, I just came to think about checking if I even had py2 installed, and I didn't, and installing it fixed it, doh! :) Maybe mention that on your instructions/first-page/requirements.txt would be propperly a good thing. I don't even know if deluge supports py2 anymore. I don't know of any distro having py2 as dep for deluge2 neither, but whatever. Thanks again! :)

springjools commented 4 years ago

Hmm, maybe there's a problem with the build script? I just zip the files and rename the extension to .egg. I didn't actually touch the build script 🤔

springjools commented 4 years ago

I started looking at the GTK using x-server over ssh, but I can't figure where the logs are being output. Nothing is showing in the log file from deluge daemon (or syslog/daemon.log either)

camjac251 commented 4 years ago

The problem is with building the plugin with python setup.py bdist_egg. I've downgraded back to 1.3.15 for now but my process for working with my linux deluged was through deluge-web or the windows build of deluge 2.0 found here https://forum.deluge-torrent.org/viewtopic.php?t=55463 and disabling classic mode to allow connecting to the remote server.

The very top post explains the problem with building the tool.

springjools commented 4 years ago

Yeah sorry for that. I was away during the Easter and just skimmed through those posts.

But yes, there's a problem like you mentioned: def on_menu_show(menu, (menu_item, toggled)):

That's not allowed in python 3 so I'll try to rewrite those functions...

springjools commented 4 years ago

@mhertz The proper fix for python 3 when you have a nested function like in this case is to rewrite it like this:

def on_menu_show(menu, tuple): (menu_item, toggled) = tuple

I'll release a new version that fixes the build script at least. I'll try to work on the GTK too...

mhertz commented 4 years ago

Thanks for proper fix springjools and that you will add it later, appreciated. About the log-entries missing, then you need specifically specify logging for the daemon and/or UI you wan't logged e.g. you need starting deluge-gtk with e.g. '-L debug -l deluge-gtk.log'.

springjools commented 4 years ago

Ah yes of course. I only started the daemon that way and assumed they would end up there. Now I should be able to work with the GTK too...

springjools commented 4 years ago

Maybe this is the reason the build didn't work: https://github.com/deluge-torrent/deluge/pull/284/commits/15c250e15252fb9131a1b4c39226fcd43d45fc08