diff options
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/Extractor.py | 22 | ||||
-rw-r--r-- | module/plugins/internal/SevenZip.py | 7 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 31 |
3 files changed, 30 insertions, 30 deletions
diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 3ab5d6a0d..6bc1ddc71 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -5,7 +5,19 @@ import re from module.PyFile import PyFile from module.plugins.internal.Plugin import Plugin -from module.utils import fs_encode + + +def renice(pid, value): + if not value or os.name is "nt": + return + + try: + subprocess.Popen(["renice", str(value), str(pid)], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + bufsize=-1) + except Exception: + pass class ArchiveError(Exception): @@ -73,15 +85,14 @@ class Extractor(Plugin): @property def target(self): - return fs_encode(self.filename) + return encode(self.filename) def __init__(self, plugin, filename, out, fullpath=True, overwrite=False, excludefiles=[], - renice=0, - delete='No', + renice=False, keepbroken=False, fid=None): """ @@ -95,8 +106,7 @@ class Extractor(Plugin): self.fullpath = fullpath self.overwrite = overwrite self.excludefiles = excludefiles - self.renice = renice - self.delete = delete + self.priority = int(priority) self.keepbroken = keepbroken self.files = [] #: Store extracted files here diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index f73e935e8..db22dfc4e 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -5,7 +5,7 @@ import re import subprocess from module.plugins.internal.UnRar import ArchiveError, CRCError, PasswordError, UnRar, renice -from module.utils import save_join as fs_join +from module.plugins.internal.utils import fs_join class SevenZip(UnRar): @@ -78,8 +78,6 @@ class SevenZip(UnRar): p = self.call_cmd(command, '-o' + self.out, self.target, password=password) - renice(p.pid, self.renice) - #: Communicate and retrieve stderr self._progress(p) err = p.stderr.read().strip() @@ -139,4 +137,7 @@ class SevenZip(UnRar): self.log_debug(" ".join(call)) p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + renice(p.pid, self.priority) + return p diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 6f85c286a..6fe02a51d 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -2,22 +2,11 @@ import os import re +import string import subprocess -from glob import glob -from string import digits - -from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError -from module.utils import fs_decode, save_join as fs_join - - -def renice(pid, value): - if value and os.name is not "nt": - try: - subprocess.Popen(["renice", str(value), str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=-1) - - except Exception: - pass +from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError, renice +from module.plugins.internal.utils import decode, fs_join class UnRar(Extractor): @@ -138,7 +127,7 @@ class UnRar(Extractor): self.notify_progress(int(s)) s = "" #: Not reading a digit -> therefore restart - elif c not in digits: + elif c not in string.digits: s = "" #: Add digit to progressstring else: @@ -150,8 +139,6 @@ class UnRar(Extractor): p = self.call_cmd(command, self.target, self.out, password=password) - renice(p.pid, self.renice) - #: Communicate and retrieve stderr self._progress(p) err = p.stderr.read().strip() @@ -200,12 +187,12 @@ class UnRar(Extractor): result = set() if not self.fullpath and self.VERSION.startswith('5'): #@NOTE: Unrar 5 always list full path - for f in fs_decode(out).splitlines(): + for f in decode(out).splitlines(): f = fs_join(self.out, os.path.basename(f.strip())) if os.path.isfile(f): result.add(fs_join(self.out, os.path.basename(f))) else: - for f in fs_decode(out).splitlines(): + for f in decode(out).splitlines(): result.add(fs_join(self.out, f.strip())) return list(result) @@ -219,8 +206,7 @@ class UnRar(Extractor): args.append("-o+") else: args.append("-o-") - if self.delete != 'No': - args.append("-or") + args.append("-or") for word in self.excludefiles: args.append("-x'%s'" % word.strip()) @@ -243,4 +229,7 @@ class UnRar(Extractor): self.log_debug(" ".join(call)) p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + renice(p.pid, self.priority) + return p |