Closed bobskiman closed 1 year ago
Edit: I did not have the proper version in the config file. (was set to default and i am using v2)
After changing this, here is the output im getting for a "Downloading" file
root@61ce073b93d6:/hostbin/deluge-dc-notif-master# python3 delugePush.py 729cbc58cbfaf3c4d3372b09616bc4f575d0bee5
Traceback (most recent call last):
File "delugePush.py", line 127, in <module>
getState(torrentHash, torrentName, RATIO_CHECK_DELAY, False)
File "delugePush.py", line 73, in getState
sendMessage("Added torrent!", torrentName, tracker)
File "delugePush.py", line 43, in sendMessage
response = urllib2.urlopen(req)
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 524, in open
req = meth(req)
File "/usr/lib/python3.6/urllib/request.py", line 1255, in do_request_
raise TypeError(msg)
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
and here is for a completed file:
Traceback (most recent call last):
File "delugePush.py", line 127, in <module>
getState(torrentHash, torrentName, RATIO_CHECK_DELAY, False)
File "delugePush.py", line 83, in getState
sendMessage(message, torrentName, tracker, ratioValue)
File "delugePush.py", line 43, in sendMessage
response = urllib2.urlopen(req)
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 524, in open
req = meth(req)
File "/usr/lib/python3.6/urllib/request.py", line 1255, in do_request_
raise TypeError(msg)
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
I think this is mostly certainly due to python3
, the script is intended for use with python2
. I will make sure to add this to the README, for now there is no "quick fix", except that your python
command default to python2
(2.7 probably).
Can you try running it locally with python
instead of python3
?
I was able to push a bit further with Python3, only just urllib2 that becomes urllib.request.
Now i'm stuck at sending the actual message, still related to urllib. Ur req variable being sent to discord perhaps need to be utf-8 encoded?
[TypeError] ... expected bytes
Ill keep trying with python3 as im literally one problem away from sending the discord notification.
Any ideas btw?
On Tue., Jul. 13, 2021, 5:19 a.m. Raghu Saxena, @.***> wrote:
I think this is mostly certainly due to python3, the script is intended for use with python2. I will make sure to add this to the README, for now there is no "quick fix", except that your python command default to python2 (2.7 probably).
Can you try running it locally with python instead of python3?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ckcr4lyf/deluge-dc-notif/issues/6#issuecomment-878923556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUZT3PBRAWT74NPYQGRNVR3TXQAKHANCNFSM5AEQTYCA .
Not completely sure, but I do have a box with python3 on it I think. Will try and play around a bit tomorrow, see if I can make another version of the script for those who still use Deluge.
I am able to test succesfully but invoking the command automatically through the Execute plugin gives me the following issue...
11:37:56 [INFO ][deluge.pluginmanagerbase :189 ] Plugin Label enabled... 11:37:56 [INFO ][deluge.pluginmanagerbase :189 ] Plugin Execute enabled... 11:38:21 [INFO ][deluge.ui.web.json_api :733 ] Adding torrent from file
ubuntu-22.10-desktop-amd64.iso.torrentwith options
{'file_priorities': [1], 'add_paused': False, 'sequential_download': False, 'pre_allocate_storage': False, 'download_location': '/downloads', 'move_completed': False, 'move_completed_path': '/downloads', 'max_connections': 103, 'max_download_speed': -1, 'max_upload_slots': 13, 'max_upload_speed': -1, 'prioritize_first_last_pieces': False, 'seed_mode': False, 'super_seeding': False} 11:38:21 [INFO ][deluge.core.torrentmanager :673 ] Torrent ubuntu-22.10-desktop-amd64.iso from user "localclient" added 11:38:22 [WARNING ][deluge_execute.core :116 ] Command "/config/delugePush.py" failed with exit code 1 11:38:22 [WARNING ][deluge_execute.core :120 ] stderr: b'Traceback (most recent call last):\n File "/config/delugePush.py", line 128, in <module>\n getState(torrentHash, torrentName, RATIO_CHECK_DELAY, False)\n File "/config/delugePush.py", line 71, in getState\n tracker = lines[7][9:]\nIndexError: list index out of range\n
@frunkAF can you confirm your versions of deluge-console
, deluged
and python
?
@ckcr4lyf I use the docker container, linuxserver/deluge:latest. Here's the output of a version command
root@deluge:/# deluge-console -v
deluge-console 2.1.1
libtorrent: 2.0.8.0
Python: 3.10.8
OS: Linux
I got it working now.
I added a print(delugeConsoleResult)
in the getState section and monitored the console on portainer. The result printed was a permissions issue accessing the /root/.config
directory. I went into the container and just chmod -R 0777 to blanket allow and the script is running perfectly.
So to get it working...
1) Modified the delugePush.py to import urlib.request for new Python (Merge Request)
2) Modified line 16 in /usr/lib/python3.10/site-packages/deluge/ui/console/init.py to Console().start()
within the container
3) chmod -R 0777 /root
within the docker container
I would guess (1) is related to #8 (and valid), (3) is related to docker stuffs.
But part (2) is concerning, since it seems you need to modify deluge-console
's code (as per what you shared earlier - https://forum.deluge-torrent.org/viewtopic.php?p=235215#p235215)
I will try and see if I can address that by better detecting the values instead of relying on hardcoded indexes
@frunkAF ok, I have confirmed the execution. Issue (2) does not affect this script, it will only print an extra line at the end:
$ python delugePush.py f5357853359f3a1c3f5484350f6f60af779a7b88
<Deferred at 0x7f9ff214e1d0 current result: None>
so the exit code error etc, is mostly likely a docker permission thing.
Can you "undo" your change to console/init.py
and see if it still works? We could close this issue then.
My testing without modifying that file:
$ deluge-console -v
deluge-console 2.1.1
libtorrent: 2.0.8.0
Python: 3.10.8
OS: Linux Arch Linux rolling n/a
It worked!
It looks like the message is not an issue. It was strictly a permissions issue once the code was updated for python 3
Awesome. I will close this issue for now, @bobskiman you can use the new delugePush3.py
script for Python3 compatibility
Hi, i'm getting this error when attempting to use the test function with torrent hash. I'm using linuxserver/docker which has python3 installed. To get it running i had to change the "import urllib2" to "import urllib.request as urllib2" to actually run through the import stage of the script.
Let me know if i can help in troubleshooting.