diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-31 02:21:35 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-31 02:21:35 +0200 |
commit | 092112b44af84c7a59b1fa2cfff5c5875e778a8f (patch) | |
tree | 455f8192b0da79f3f325481a60feb239cc33d37d /module/plugins/internal/Plugin.py | |
parent | Fix https://github.com/pyload/pyload/issues/1624 (diff) | |
download | pyload-092112b44af84c7a59b1fa2cfff5c5875e778a8f.tar.xz |
Fix https://github.com/pyload/pyload/issues/1625
Diffstat (limited to 'module/plugins/internal/Plugin.py')
-rw-r--r-- | module/plugins/internal/Plugin.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index 76056c66d..70494561c 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -138,7 +138,7 @@ def chunks(iterable, size): class Plugin(object): __name__ = "Plugin" __type__ = "hoster" - __version__ = "0.19" + __version__ = "0.20" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -196,6 +196,37 @@ class Plugin(object): return self._log("critical", self.__type__, self.__name__, args) + def set_permissions(self, path): + if not os.path.exists(path): + return + + try: + if self.pyload.config.get("permission", "change_file"): + if os.path.isfile(path): + os.chmod(path, int(self.pyload.config.get("permission", "file"), 8)) + + elif os.path.isdir(path): + os.chmod(path, int(self.pyload.config.get("permission", "folder"), 8)) + + except OSError, e: + self.log_warning(_("Setting path mode failed"), e) + + try: + if os.name != "nt" and self.pyload.config.get("permission", "change_dl"): + uid = pwd.getpwnam(self.pyload.config.get("permission", "user"))[2] + gid = grp.getgrnam(self.pyload.config.get("permission", "group"))[2] + os.chown(path, uid, gid) + + except OSError, e: + self.log_warning(_("Setting owner and group failed"), e) + + + def get_chunk_count(self): + if self.chunk_limit <= 0: + return self.pyload.config.get("download", "chunks") + return min(self.pyload.config.get("download", "chunks"), self.chunk_limit) + + def set_config(self, option, value): """ Set config value for current plugin |