summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-04-03 18:20:41 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-04-03 18:20:41 +0200
commitc0de6a240da55787524cb7039012489561c6ed67 (patch)
treeb1e23b4cfb31970a9a18f1c797790cf7207cb9b4 /module/plugins
parentSimpleCrypter: trivial fix in documentation (diff)
parentadded progress to unrar (diff)
downloadpyload-c0de6a240da55787524cb7039012489561c6ed67.tar.xz
Merge pull request #58 from thargor/stable
added progress to unrar
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/internal/UnRar.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index ef04f558e..ef31fbae2 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -114,15 +114,31 @@ class UnRar(AbtractExtractor):
def extract(self, progress, password=None):
command = "x" if self.fullpath else "e"
- # popen thinks process is still alive (just like pexpect) - very strange behavior
- # so for now progress can not be determined correctly
p = self.call_unrar(command, self.file, self.out, password=password)
renice(p.pid, self.renice)
progress(0)
- out, err = p.communicate() #wait for process
+ progressstring = ""
+ while True:
+ c = p.stdout.read(1)
+ # quit loop on eof
+ if not c:
+ break
+ # reading a percentage sign -> set progress and restart
+ if c == '%':
+ progress(int(progressstring))
+ progressstring = ""
+ # not reading a digit -> therefore restart
+ elif re.match('[0-9]',c) is None:
+ progressstring = ""
+ # add digit to progressstring
+ else:
+ progressstring = progressstring + c
progress(100)
+ # retrieve stderr
+ err = p.stderr.read()
+
if "CRC failed" in err and not password and not self.passwordProtected:
raise CRCError
elif "CRC failed" in err: