diff options
| -rw-r--r-- | module/plugins/hooks/UnRar.py | 5 | ||||
| -rw-r--r-- | module/pyunrar.py | 17 | 
2 files changed, 13 insertions, 9 deletions
diff --git a/module/plugins/hooks/UnRar.py b/module/plugins/hooks/UnRar.py index 48e69ead9..88da0b64d 100644 --- a/module/plugins/hooks/UnRar.py +++ b/module/plugins/hooks/UnRar.py @@ -37,7 +37,8 @@ class UnRar(Hook):                     ("overwrite", "bool", "overwrite files", True),                     ("passwordfile", "str", "unrar passoword file", "unrar_passwords.txt"),                     ("deletearchive", "bool", "delete archives when done", False), -                   ("ramwarning", "bool", "warn about low ram", True)] +                   ("ramwarning", "bool", "warn about low ram", True), +                   ("renice", "int", "Cpu Priority", 10)]      __threaded__ = ["packageFinished"]      __author_name__ = ("mkaay")      __author_mail__ = ("mkaay@mkaay.de") @@ -127,7 +128,7 @@ class UnRar(Hook):              else:                  folder = download_folder -            u = Unrar(join(folder, fname), tmpdir=join(folder, "tmp"), ramSize=(self.ram if self.getConfig("ramwarning") else 0)) +            u = Unrar(join(folder, fname), tmpdir=join(folder, "tmp"), ramSize=(self.ram if self.getConfig("ramwarning") else 0), cpu=self.getConfig("renice"))              try:                  success = u.crackPassword(passwords=self.passwords, statusFunction=s, overwrite=True, destination=folder, fullPath=self.getConfig("fullpath"))              except WrongPasswordError: diff --git a/module/pyunrar.py b/module/pyunrar.py index 11b19330b..8b9892f8e 100644 --- a/module/pyunrar.py +++ b/module/pyunrar.py @@ -76,7 +76,7 @@ class CommandError(Exception):          return EXITMAP[self.ret]  class Unrar(): -    def __init__(self, archive, tmpdir=None, ramSize=0): +    def __init__(self, archive, tmpdir=None, ramSize=0, cpu=0):          """              archive should be be first or only part          """ @@ -88,9 +88,12 @@ class Unrar():          else: #old style              self.pattern = "%s.r*" % archive.replace(".rar", "")          if os.name == "nt": -            self.cmd = join(pypath, "UnRAR.exe") +            self.cmd = [join(pypath, "UnRAR.exe")]          else: -            self.cmd = "unrar" +            if cpu: +                self.cmd = ["nice", "-%s" % cpu,"unrar"] +            else: +                self.cmd = ["unrar"]          self.encrypted = None          self.headerEncrypted = None          self.smallestFiles = None @@ -112,7 +115,7 @@ class Unrar():          f = self.archive          if self.pattern:              f = self.pattern -        args = [self.cmd, "v"] +        args = self.cmd + ["v"]          if password:              args.append("-p%s" % password)          else: @@ -213,7 +216,7 @@ class Unrar():          f = self.archive          if self.pattern:              f = self.pattern -        args = [self.cmd, "t", "-p%s" % password, f] +        args = self.cmd + ["t", "-p%s" % password, f]          try:              args.append(self.getSmallestFile(password)["name"])          except WrongPasswordError: @@ -236,7 +239,7 @@ class Unrar():          f = self.archive          if self.pattern:              f = self.pattern -        args = [self.cmd] +        args = self.cmd          if fullPath:              args.append("x")          else: @@ -299,7 +302,7 @@ class Unrar():                          destination = "."                      if overwrite:                          try: -                            remove(abspath(join(destination, sf[0]))) +                            remove(abspath( join(destination, sf[0])))                          except OSError, e:                              if not e.errno == 2:                                  raise e  | 
