summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/PyFile.py4
-rw-r--r--module/plugins/Base.py13
-rw-r--r--module/plugins/internal/UnRar.py17
3 files changed, 24 insertions, 10 deletions
diff --git a/module/PyFile.py b/module/PyFile.py
index d70f852d1..4f8b95124 100644
--- a/module/PyFile.py
+++ b/module/PyFile.py
@@ -100,6 +100,10 @@ class PyFile(object):
return self._name
def setName(self, name):
+ """ Only set unicode or utf8 strings as name """
+ if type(name) == str:
+ name = name.decode("utf8")
+
self._name = name
name = property(getName, setName)
diff --git a/module/plugins/Base.py b/module/plugins/Base.py
index 48a3707b1..34074095e 100644
--- a/module/plugins/Base.py
+++ b/module/plugins/Base.py
@@ -18,6 +18,7 @@
"""
import sys
+from module.utils import decode
from module.utils.fs import exists, makedirs, join
# TODO
@@ -101,7 +102,17 @@ class Base(object):
else:
sep = " | "
- getattr(self.log, level)("%s: %s" % (self.__name__, sep.join([a if isinstance(a, basestring) else str(a) for a in args])))
+
+ strings = []
+ for obj in args:
+ if type(obj) == unicode:
+ strings.append(obj)
+ elif type(obj) == str:
+ strings.append(decode(obj))
+ else:
+ strings.append(str(obj))
+
+ getattr(self.log, level)("%s: %s" % (self.__name__, sep.join(strings)))
def setConfig(self, option, value):
""" Set config value for current plugin
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index b3c2fe6af..a315fbea3 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -22,7 +22,7 @@ import re
from glob import glob
from subprocess import Popen, PIPE
-from module.utils.fs import save_join, decode, fs_decode, fs_encode
+from module.utils.fs import save_join, decode, fs_encode
from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError
class UnRar(AbtractExtractor):
@@ -38,7 +38,7 @@ class UnRar(AbtractExtractor):
@staticmethod
def checkDeps():
if os.name == "nt":
- UnRar.CMD = safe_join(pypath, "UnRAR.exe")
+ UnRar.CMD = save_join(pypath, "UnRAR.exe")
p = Popen([UnRar.CMD], stdout=PIPE, stderr=PIPE)
p.communicate()
else:
@@ -65,9 +65,9 @@ class UnRar(AbtractExtractor):
if match:
#only add first parts
if int(match[0][1]) == 1:
- result.append((fs_decode(file), id))
+ result.append((file, id))
else:
- result.append((fs_decode(file), id))
+ result.append((file, id))
return result
@@ -134,9 +134,9 @@ class UnRar(AbtractExtractor):
def getDeleteFiles(self):
- if ".part" in fs_encode(self.file):
- return glob(re.sub("(?<=\.part)([01]+)", "*", fs_decode(self.file), re.IGNORECASE))
- return [fs_decode(self.file)]
+ if ".part" in self.file:
+ return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.IGNORECASE))
+ return [self.file]
def listContent(self):
command = "vb" if self.fullpath else "lb"
@@ -175,7 +175,7 @@ class UnRar(AbtractExtractor):
#NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
call = [self.CMD, command] + args + list(xargs)
- self.m.logDebug(" ".join([decode(a) for a in call]))
+ self.m.logDebug(" ".join([decode(arg) for arg in call]))
p = Popen(call, stdout=PIPE, stderr=PIPE)
@@ -188,4 +188,3 @@ def renice(pid, value):
Popen(["renice", str(value), str(pid)], stdout=PIPE, stderr=PIPE, bufsize=-1)
except:
print "Renice failed"
-