diff options
| author | 2015-07-29 18:49:49 +0200 | |
|---|---|---|
| committer | 2015-07-29 18:49:49 +0200 | |
| commit | 2e5ad6d1cc7b352975df79a0885413ad157f0ba0 (patch) | |
| tree | 20190aec296a9b4cdfcf2f13d83776532f66cc43 /module/plugins/hooks/AntiStandby.py | |
| parent | Fix https://github.com/pyload/pyload/issues/1602 (diff) | |
| download | pyload-2e5ad6d1cc7b352975df79a0885413ad157f0ba0.tar.xz | |
Fix https://github.com/pyload/pyload/issues/1600
Diffstat (limited to 'module/plugins/hooks/AntiStandby.py')
| -rw-r--r-- | module/plugins/hooks/AntiStandby.py | 29 | 
1 files changed, 21 insertions, 8 deletions
| diff --git a/module/plugins/hooks/AntiStandby.py b/module/plugins/hooks/AntiStandby.py index 5c54b8c96..3667e378a 100644 --- a/module/plugins/hooks/AntiStandby.py +++ b/module/plugins/hooks/AntiStandby.py @@ -26,7 +26,7 @@ class Kernel32(object):  class AntiStandby(Addon):      __name__    = "AntiStandby"      __type__    = "hook" -    __version__ = "0.04" +    __version__ = "0.05"      __status__  = "testing"      __config__ = [("activated", "bool", "Activated"                       , True ), @@ -45,6 +45,7 @@ class AntiStandby(Addon):      def init(self): +        self.pid   = None          self.mtime = 0 @@ -121,6 +122,13 @@ class AntiStandby(Addon):      @Expose      def linux_standby(self, system=True, display=True):          try: +            if system: +                if self.pid: +                    self.pid.kill() + +            elif not self.pid: +                self.pid = subprocess.Popen(["caffeine"]) +              if display:                  subprocess.call(["xset", "+dpms", "s", "default"])              else: @@ -140,18 +148,23 @@ class AntiStandby(Addon):      @Expose      def max_mtime(self, path): -        return max(os.path.getmtime(os.path.join(root, file)) -                   for root, dirs, files in os.walk(path, topdown=False) -                   for file in files) +        return max(0, 0, +                   *(os.path.getmtime(os.path.join(root, file)) +                        for root, dirs, files in os.walk(path, topdown=False) +                            for file in files))      def periodical(self):          if self.get_config('hdd') is False:              return -        if os.name != "nt": -            path = self.pyload.config.get("general", "download_folder") -            if (self.max_mtime(path) - self.mtime) < self.interval: -                return +        if (self.pyfile.threadManager.pause or +                not self.pyfile.api.isTimeDownload() or +                    not self.pyfile.threadManager.getActiveFiles()): +            return + +        path = self.pyload.config.get("general", "download_folder") +        if (self.max_mtime(path) - self.mtime) < self.interval: +            return          self.touch(self.TMP_FILE) | 
