diff options
author | nilo <nikola.ilo@gmail.com> | 2013-04-03 14:04:03 +0200 |
---|---|---|
committer | nilo <n.ilo@celix.at> | 2013-04-03 15:18:59 +0200 |
commit | 12741a9f656cd5a0a96c29ed63a2988c5c2be9da (patch) | |
tree | fe240150f5e89629dd9e431a358af73114fcab53 /module/plugins | |
parent | DataHuFolder: error message if folder is password protected but no password i... (diff) | |
download | pyload-12741a9f656cd5a0a96c29ed63a2988c5c2be9da.tar.xz |
added progress to unrar
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/internal/UnRar.py | 22 |
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: |