From 912a98b6d84c6eec826b0c522b77673ab1de666c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 16 Sep 2010 13:38:31 +0200 Subject: reconnect fix, unrar fix --- module/plugins/hooks/UnRar.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnRar.py b/module/plugins/hooks/UnRar.py index 9ee9b2d46..8875ce95f 100644 --- a/module/plugins/hooks/UnRar.py +++ b/module/plugins/hooks/UnRar.py @@ -54,12 +54,16 @@ class UnRar(Hook): f.writelines(self.comments) self.re_splitfile = re.compile("(.*)\.part(\d+)\.rar$") - def addPassword(self, pw): - if not pw in self.passwords: + def addPassword(self, pws): + if not type(pws) == list: pws = [pws] + for pw in pws: + pw = pw.strip() + if not pw or pw == "None" or pw in self.passwords: continue self.passwords.insert(0, pw) - with open(self.getConfig("passwordfile"), "w") as f: - f.writelines(self.comments) - f.writelines(self.passwords) + + with open(self.getConfig("passwordfile"), "w") as f: + f.writelines(self.comments) + f.writelines(self.passwords) def removeFiles(self, pack, fname): if not self.getConfig("deletearchive"): @@ -83,8 +87,8 @@ class UnRar(Hook): remove(join(folder, data["name"])) def packageFinished(self, pack): - if pack.password: - self.addPassword(pack.password) + if pack.password.strip() and pack.password.strip() != "None": + self.addPassword(pack.password.splitlines()) files = [] for fid, data in pack.getChildren().iteritems(): m = self.re_splitfile.search(data["name"]) @@ -94,6 +98,7 @@ class UnRar(Hook): files.append((fid,data["name"])) for fid, fname in files: + self.core.log.info(_("starting Unrar of %s") % fname) pyfile = self.core.files.getFile(fid) pyfile.setStatus("processing") def s(p): @@ -117,7 +122,7 @@ class UnRar(Hook): continue try: if e.getExitCode() == 1 and len(u.listContent(u.getPassword())) == 1: - self.core.log.debug("Unrar of %s ok" % fname) + self.core.log.info("Unrar of %s ok" % fname) self.removeFiles(pack, fname) except: self.core.log.info("Unrar of %s failed" % fname) @@ -127,7 +132,7 @@ class UnRar(Hook): continue else: if success: - self.core.log.debug("Unrar of %s ok" % fname) + self.core.log.info("Unrar of %s ok" % fname) self.removeFiles(pack, fname) else: self.core.log.info("Unrar of %s failed (wrong password)" % fname) -- cgit v1.2.3