Trying to use the deluge-console v2.1.1

Specific support for Deluge on Microsoft Windows OS
Post Reply
phpjunkie
Member
Member
Posts: 14
Joined: Tue Dec 26, 2023 12:59 pm

Trying to use the deluge-console v2.1.1

Post by phpjunkie »

I've tried searching for these files in windows and windows can't find them.

So you know, I do have python 3.11.7 installed in my windows user folder (C:\Users\phpjunkie\AppData\Local\Programs\Python). when I run a script with admin privileges under C:\Program Files\Python I get the UAC prompt every time, so I chose to install python without admin privileges so it'd end up in my user folder.

This is what is being generated.

Code: Select all

C:\Program Files\Deluge>deluge-console -c "C:\Users\phpjunkie\AppData\Roaming\deluge" -d 127.0.0.1 -p 58846 -U phpjunkie -P **********
Traceback (most recent call last):
  File "deluge-console-script.py", line 33, in <module>
  File "deluge\ui\console\__init__.py", line 16, in start
  File "deluge\ui\console\console.py", line 149, in start
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "deluge\ui\console\main.py", line 24, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "deluge\ui\console\modes\addtorrents.py", line 18, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "deluge\ui\console\modes\torrentlist\add_torrents_popup.py", line 13, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "deluge\ui\console\widgets\__init__.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "deluge\ui\console\widgets\inputpane.py", line 16, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "deluge\ui\console\widgets\fields.py", line 32, in <module>
  File "deluge\ui\console\widgets\fields.py", line 87, in BaseField
  File "deluge\decorators.py", line 62, in ret_func
  File "deluge\decorators.py", line 73, in _overrides
TypeError: 'NoneType' object is not subscriptable
[15452] Failed to execute script 'deluge-console-script' due to unhandled exception!
phpjunkie
Member
Member
Posts: 14
Joined: Tue Dec 26, 2023 12:59 pm

Re: Trying to use the deluge-console v2.1.1

Post by phpjunkie »

What I'm trying to do is create a python script for renaming files in my download folder and it works just fine except ...

Code: Select all

    OpenFiles = []
    for process in process_iter():
        if process.name() == 'deluged.exe':
            OpenFiles.extend(process.open_files())
            break

    if len(OpenFiles):
        open_files = OpenFiles.copy()
        for file in open_files:
            if r'Media\Downloads\Sort' not in file.path:
                OpenFiles.remove(file)
If the torrent isn't an active download it doesn't show up in this list and the folders/files get renamed. The list is being generated by psutil for files that are locked by deluge. I've had to manually rename a torrent folder and file and then ran 'Force re-check" on the torrent so it'd start downloading where it left off.

I was hopping to use subprocess.call to get a list of torrent in deluge so I can get all of the torrents and their status instead just the active torrents.
Last edited by phpjunkie on Tue Dec 26, 2023 2:11 pm, edited 1 time in total.
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Trying to use the deluge-console v2.1.1

Post by mhertz »

Regarding your first post, then a deluge commit rewriting the pyinstaller spec file unfortunetly broke deluge-console on windows. I did report it, with a suggested fix, and posted an end-user fix also here on forum, here you go again, unzip into 'deluge\ui' of installed deluge location, if wanted meanwhile.

Btw, deluge-console only worked in CLI mode on windows, so need commands after deluge-console e.g. 'deluge-console info' etc. It was supposed to work actually in TUI/curses mode Cas stated before, but it still doesn't however, but getting closer. Also, you don't need to specify -p, -d and -c in your case, when defaults anyway, but neither hurt of-course, just adding if wasen't aware.

As for your last post, then can use deluge-console though supprocess.* or alike, sure, or interact with the web-UI though e.g. curl is another option. Sadly on windows, you can not just use the RPC API which sounds perfect for you when already using python as is, as the needed deluge client modules are freezed inside the exe's, so not importable like on linux, though I guess could download source and just import externally from your script, and when finished could if wanted freeze your python script together with the needed deluge modules into an exe, so don't need them anymore(nor python itself), but probably going overboard now, to your quick question lol. Regardless, if need some pointers for anything of this, then give us a shout :)
phpjunkie
Member
Member
Posts: 14
Joined: Tue Dec 26, 2023 12:59 pm

Re: Trying to use the deluge-console v2.1.1

Post by phpjunkie »

mhertz wrote: Wed Dec 27, 2023 12:24 pm Regarding your first post, then a deluge commit rewriting the pyinstaller spec file unfortunetly broke deluge-console on windows. I did report it, with a suggested fix, and posted an end-user fix also here on forum, here you go again, unzip into 'deluge\ui' of installed deluge location, if wanted meanwhile.

Btw, deluge-console only worked in CLI mode on windows, so need commands after deluge-console e.g. 'deluge-console info' etc. It was supposed to work actually in TUI/curses mode Cas stated before, but it still doesn't however, but getting closer. Also, you don't need to specify -p, -d and -c in your case, when defaults anyway, but neither hurt of-course, just adding if wasen't aware.

As for your last post, then can use deluge-console though supprocess.* or alike, sure, or interact with the web-UI though e.g. curl is another option. Sadly on windows, you can not just use the RPC API which sounds perfect for you when already using python as is, as the needed deluge client modules are freezed inside the exe's, so not importable like on linux, though I guess could download source and just import externally from your script, and when finished could if wanted freeze your python script together with the needed deluge modules into an exe, so don't need them anymore(nor python itself), but probably going overboard now, to your quick question lol. Regardless, if need some pointers for anything of this, then give us a shout :)
Okay, so I'm dumping this into 'C:\Program Files\Deluge\deluge\ui'? I'm asking 'cause I don't see a folder named console in the ui folder, and the only thing I see in the config folder is the 'ui.conf'.
phpjunkie
Member
Member
Posts: 14
Joined: Tue Dec 26, 2023 12:59 pm

Re: Trying to use the deluge-console v2.1.1

Post by phpjunkie »

This time I was able to get something from it other than it crashing, but now it is freezing and doesn't respond when it loads in the terminal.
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Trying to use the deluge-console v2.1.1

Post by mhertz »

Extract my zip archive into 'C:\Program Files\Deluge\deluge\ui', so there now is a 'console' folder inside 'ui' folder.

The freezing you experience is because as said you're not adding commands to deluge-console, e.g. 'add', 'info' etc etc. - Indeed it freezes if trying run interactively(curses/TUI mode), as still unresolved issues with the windows curses lib and deluge.
phpjunkie
Member
Member
Posts: 14
Joined: Tue Dec 26, 2023 12:59 pm

Re: Trying to use the deluge-console v2.1.1

Post by phpjunkie »

i got it kinda figured out.
'C:\Program Files\Deluge\deluge-console.exe --daemon deluge --port 58846 --username phpjunkie --password ********** info'

deluge is set in the host file (C:\Windows\System32\drivers\etc\host) to point to the IP of the computer that deluged.exe is running on and it did generate the list of torrents, which is what I wanted.

Thank you.
Post Reply