Deluge console add UnicodeDecodeError

General support for problems installing or using Deluge
Post Reply
tr2015
New User
New User
Posts: 3
Joined: Wed Oct 28, 2015 4:47 am

Deluge console add UnicodeDecodeError

Post by tr2015 »

Sorry to bump this thread but I have the same problem with non-ascii named torrents. I've looked around pretty much found nothing to help me with this. So here I am.

Here some cli logs from my ubuntu thin client box:

Code: Select all

torrent@torrentbox:~$ deluge-console add /mnt/samba/library/Torrent/sickbeard-torrents/Les.Pires.Chauffards.Québécois.S01E09.FRENCH.720p.WEBRiP.H264.AAC-LCDS.mp4.torrent
'ascii' codec can't decode byte 0xc3 in position 78: ordinal not in range(128)
[ERROR   ] 00:30:15 main:347 'ascii' codec can't decode byte 0xc3 in position 78: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/main.py", line 344, in do_command
    ret = self._commands[cmd].handle(*args, **options.__dict__)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/commands/add.py", line 82, in handle
    self.console.write("{!error!}%s doesn't exist!" % arg)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/main.py", line 292, in write
    print colors.strip_colors(line.encode("utf-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 78: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/main.py", line 344, in do_command
    ret = self._commands[cmd].handle(*args, **options.__dict__)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/commands/add.py", line 82, in handle
    self.console.write("%s doesn't exist!" % arg)
  File "/usr/lib/python2.7/dist-packages/deluge/ui/console/main.py", line 292, in write
    print colors.strip_colors(line.encode("utf-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 78: ordinal not in range(128)

locale setup:

Code: Select all

torrent@torrentbox:~$ locale
LANG=en_CA.UTF-8
LANGUAGE=en_CA:en
LC_CTYPE="en_CA.UTF-8"
LC_NUMERIC="en_CA.UTF-8"
LC_TIME="en_CA.UTF-8"
LC_COLLATE="en_CA.UTF-8"
LC_MONETARY="en_CA.UTF-8"
LC_MESSAGES="en_CA.UTF-8"
LC_PAPER="en_CA.UTF-8"
LC_NAME="en_CA.UTF-8"
LC_ADDRESS="en_CA.UTF-8"
LC_TELEPHONE="en_CA.UTF-8"
LC_MEASUREMENT="en_CA.UTF-8"
LC_IDENTIFICATION="en_CA.UTF-8"
LC_ALL=en_CA.UTF-8
My setup is pretty basic. I,ve got a watch folder that deluge scans and add torrents automaticaly. I've bypassed that process to provide you a little deluge-console cli output.

I can't be interely sure that it's my setup and not deluge that in cause but still It seem to be python related (I know its vague) but i can't really get that much further in my debuging steps without some more guidance.

Thank you for your time

p.s. I'll provide any info you are asking me to debug this further
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Deluge console add UnicodeDecodeError

Post by Cas »

I have split this from the other topic as it was not precisely the same issue, this is a problem in console code with non-ascii torrents and I can replicate so this should be put into a new bug ticket.
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Deluge console add UnicodeDecodeError

Post by Cas »

In fact can you test this code change.

Code: Select all

diff --git a/deluge/ui/console/main.py b/deluge/ui/console/main.py
index a00eca3..64afc46 100644
--- a/deluge/ui/console/main.py
+++ b/deluge/ui/console/main.py
@@ -289,7 +289,7 @@ def write(self, line):
         if self.interactive:
             self.screen.add_line(line, not self.batch_write)
         else:
-            print colors.strip_colors(line.encode("utf-8"))
+            print colors.strip_colors(deluge.common.utf8_encoded(line))
 
     def do_command(self, cmd):
         """
tr2015
New User
New User
Posts: 3
Joined: Wed Oct 28, 2015 4:47 am

Re: Deluge console add UnicodeDecodeError

Post by tr2015 »

This code change works thank you very much!

It strips all non-ascii chars. Converts it to a regular ascii string and properly adds it to deluge. I can't beleive i got support for this issue. This has been bugging my for years. Couldn't have asked better from my first post here. Also I've made sure it was processed all the way back to sickrage. All is working without a hitch.

Thanks again
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Deluge console add UnicodeDecodeError

Post by Cas »

Cool :) For reference it will be in the next point release 1.3.13: http://git.deluge-torrent.org/deluge/co ... d6922838b5
tr2015
New User
New User
Posts: 3
Joined: Wed Oct 28, 2015 4:47 am

Re: Deluge console add UnicodeDecodeError

Post by tr2015 »

Glad to know there's a dedicated team involved behind this :D. I'm sure pretty this fix will help and benefit lots of other users too.
Post Reply