diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-16 17:48:30 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-16 18:06:38 +0200 |
commit | 6cdb1ae0fe8f4faf897220d0520ca3e753e9f3e4 (patch) | |
tree | 24a8d6e3c2e62597b6cd3a75b77bf1a6470bd702 | |
parent | Fix lib import (diff) | |
download | pyload-6cdb1ae0fe8f4faf897220d0520ca3e753e9f3e4.tar.xz |
[config] Use get method instead dict access
-rwxr-xr-x | pyload/Core.py | 42 | ||||
-rw-r--r-- | pyload/api/__init__.py | 28 | ||||
-rw-r--r-- | pyload/manager/Remote.py | 4 | ||||
-rw-r--r-- | pyload/manager/Thread.py | 18 | ||||
-rw-r--r-- | pyload/manager/thread/Server.py | 12 | ||||
-rw-r--r-- | pyload/network/RequestFactory.py | 24 | ||||
-rw-r--r-- | pyload/plugin/Container.py | 2 | ||||
-rw-r--r-- | pyload/plugin/Crypter.py | 4 | ||||
-rw-r--r-- | pyload/plugin/Plugin.py | 28 | ||||
-rw-r--r-- | pyload/plugin/addon/Checksum.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/ClickNLoad.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/ExternalScripts.py | 36 | ||||
-rw-r--r-- | pyload/plugin/addon/ExtractArchive.py | 14 | ||||
-rw-r--r-- | pyload/plugin/addon/MergeFiles.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/MultiHome.py | 2 | ||||
-rw-r--r-- | pyload/plugin/container/CCF.py | 2 | ||||
-rw-r--r-- | pyload/plugin/crypter/DailymotionComFolder.py | 2 | ||||
-rw-r--r-- | pyload/plugin/crypter/RelinkUs.py | 2 | ||||
-rw-r--r-- | pyload/plugin/crypter/YoutubeComFolder.py | 2 | ||||
-rw-r--r-- | pyload/plugin/hoster/Xdcc.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/SimpleCrypter.py | 2 | ||||
-rw-r--r-- | pyload/remote/ThriftBackend.py | 8 |
22 files changed, 123 insertions, 123 deletions
diff --git a/pyload/Core.py b/pyload/Core.py index c79c832e1..2a3b1108f 100755 --- a/pyload/Core.py +++ b/pyload/Core.py @@ -282,41 +282,41 @@ class Core(object): gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None]) translation = gettext.translation("pyLoad", self.path("locale"), - languages=[self.config['general']['language'], "en"], fallback=True) + languages=[self.config.get("general", "language"), "en"], fallback=True) translation.install(True) - self.debug = self.doDebug or self.config['general']['debug_mode'] - self.remote &= self.config['remote']['activated'] + self.debug = self.doDebug or self.config.get("general", "debug_mode") + self.remote &= self.config.get("remote", "activated") pid = self.isAlreadyRunning() if pid: print _("pyLoad already running with pid %s") % pid exit() - if os.name != "nt" and self.config["general"]["renice"]: - os.system("renice %d %d" % (self.config["general"]["renice"], os.getpid())) + if os.name != "nt" and self.config.get("general", "renice"): + os.system("renice %d %d" % (self.config.get("general", "renice"), os.getpid())) - if self.config["permission"]["change_group"]: + if self.config.get("permission", "change_group"): if os.name != "nt": try: from grp import getgrnam - group = getgrnam(self.config["permission"]["group"]) + group = getgrnam(self.config.get("permission", "group")) os.setgid(group[2]) except Exception, e: print _("Failed changing group: %s") % e - if self.config["permission"]["change_user"]: + if self.config.get("permission", "change_user"): if os.name != "nt": try: from pwd import getpwnam - user = getpwnam(self.config["permission"]["user"]) + user = getpwnam(self.config.get("permission", "user")) os.setuid(user[2]) except Exception, e: print _("Failed changing user: %s") % e - self.check_file(self.config['log']['log_folder'], _("folder for logs"), True) + self.check_file(self.config.get("log", "log_folder"), _("folder for logs"), True) if self.debug: self.init_logger(logging.DEBUG) # logging level @@ -345,9 +345,9 @@ class Core(object): self.captcha = True # checks seems to fail, although tesseract is available - self.check_file(self.config['general']['download_folder'], _("folder for downloads"), True) + self.check_file(self.config.get("general", "download_folder"), _("folder for downloads"), True) - if self.config['ssl']['activated']: + if self.config.get("ssl", "activated"): self.check_install("OpenSSL", _("OpenSSL for secure connection")) self.setupDB() @@ -397,7 +397,7 @@ class Core(object): if web: self.init_webserver() - spaceLeft = freeSpace(self.config["general"]["download_folder"]) + spaceLeft = freeSpace(self.config.get("general", "download_folder")) self.log.info(_("Free space: %s") % formatSize(spaceLeft)) @@ -456,7 +456,7 @@ class Core(object): def init_webserver(self): - if self.config['webui']['activated']: + if self.config.get("webui", "activated"): self.webserver = WebServer(self) self.webserver.start() @@ -467,14 +467,14 @@ class Core(object): console.setFormatter(frm) self.log = logging.getLogger("log") # settable in config - if self.config['log']['file_log']: - if self.config['log']['log_rotate']: - file_handler = logging.handlers.RotatingFileHandler(join(self.config['log']['log_folder'], 'log.txt'), - maxBytes=self.config['log']['log_size'] * 1024, - backupCount=int(self.config['log']['log_count']), + if self.config.get("log", "file_log"): + if self.config.get("log", "log_rotate"): + file_handler = logging.handlers.RotatingFileHandler(join(self.config.get("log", "log_folder"), 'log.txt'), + maxBytes=self.config.get("log", "log_size") * 1024, + backupCount=int(self.config.get("log", "log_count")), encoding="utf8") else: - file_handler = logging.FileHandler(join(self.config['log']['log_folder'], 'log.txt'), encoding="utf8") + file_handler = logging.FileHandler(join(self.config.get("log", "log_folder"), 'log.txt'), encoding="utf8") file_handler.setFormatter(frm) self.log.addHandler(file_handler) @@ -566,7 +566,7 @@ class Core(object): def shutdown(self): self.log.info(_("shutting down...")) try: - if self.config['webui']['activated'] and hasattr(self, "webserver"): + if self.config.get("webui", "activated") and hasattr(self, "webserver"): self.webserver.quit() for thread in list(self.threadManager.threads): diff --git a/pyload/api/__init__.py b/pyload/api/__init__.py index 8c114cea4..c87623697 100644 --- a/pyload/api/__init__.py +++ b/pyload/api/__init__.py @@ -215,8 +215,8 @@ class Api(Iface): :return: new reconnect state """ - self.core.config["reconnect"]["activated"] ^= True - return self.core.config["reconnect"]["activated"] + self.core.config['reconnect']['activated'] ^= True + return self.core.config.get("reconnect", "activated") @permission(PERMS.LIST) @@ -228,7 +228,7 @@ class Api(Iface): serverStatus = ServerStatus(self.core.threadManager.pause, len(self.core.threadManager.processingIds()), self.core.files.getQueueCount(), self.core.files.getFileCount(), 0, not self.core.threadManager.pause and self.isTimeDownload(), - self.core.config['reconnect']['activated'] and self.isTimeReconnect()) + self.core.config.get("reconnect", "activated") and self.isTimeReconnect()) for pyfile in [x.active for x in self.core.threadManager.threads if x.active and isinstance(x.active, PyFile)]: serverStatus.speed += pyfile.getSpeed() # bytes/s return serverStatus @@ -237,7 +237,7 @@ class Api(Iface): @permission(PERMS.STATUS) def freeSpace(self): """Available free space at download directory in bytes""" - return freeSpace(self.core.config["general"]["download_folder"]) + return freeSpace(self.core.config.get("general", "download_folder")) @permission(PERMS.ALL) @@ -263,7 +263,7 @@ class Api(Iface): :param offset: line offset :return: List of log entries """ - filename = join(self.core.config['log']['log_folder'], 'log.txt') + filename = join(self.core.config.get("log", "log_folder"), 'log.txt') try: fh = open(filename, "r") lines = fh.readlines() @@ -281,8 +281,8 @@ class Api(Iface): :return: bool """ - start = self.core.config['downloadTime']['start'].split(":") - end = self.core.config['downloadTime']['end'].split(":") + start = self.core.config.get("downloadTime", "start").split(":") + end = self.core.config.get("downloadTime", "end").split(":") return compare_time(start, end) @@ -292,9 +292,9 @@ class Api(Iface): :return: bool """ - start = self.core.config['reconnect']['startTime'].split(":") - end = self.core.config['reconnect']['endTime'].split(":") - return compare_time(start, end) and self.core.config["reconnect"]["activated"] + start = self.core.config.get("reconnect", "startTime").split(":") + end = self.core.config.get("reconnect", "endTime").split(":") + return compare_time(start, end) and self.core.config.get("reconnect", "activated") @permission(PERMS.LIST) @@ -324,7 +324,7 @@ class Api(Iface): :param dest: `Destination` :return: package id of the new package """ - if self.core.config['general']['folder_per_package']: + if self.core.config.get("general", "folder_per_package"): folder = urlparse(name).path.split("/")[-1] else: folder = "" @@ -409,7 +409,7 @@ class Api(Iface): :param data: file content :return: online check """ - th = open(join(self.core.config["general"]["download_folder"], "tmp_" + container), "wb") + th = open(join(self.core.config.get("general", "download_folder"), "tmp_" + container), "wb") th.write(str(data)) th.close() return self.checkOnlineStatus(urls + [th.name]) @@ -707,7 +707,7 @@ class Api(Iface): :param filename: filename, extension is important so it can correctly decrypted :param data: file content """ - th = open(join(self.core.config["general"]["download_folder"], "tmp_" + filename), "wb") + th = open(join(self.core.config.get("general", "download_folder"), "tmp_" + filename), "wb") th.write(str(data)) th.close() self.addPackage(th.name, [th.name], Destination.Queue) @@ -945,7 +945,7 @@ class Api(Iface): :param remoteip: :return: dict with info, empty when login is incorrect """ - if self.core.config["remote"]["nolocalauth"] and remoteip == "127.0.0.1": + if self.core.config.get("remote", "nolocalauth") and remoteip == "127.0.0.1": return "local" else: return self.core.db.checkAuth(username, password) diff --git a/pyload/manager/Remote.py b/pyload/manager/Remote.py index 4fdb36fc2..a27667070 100644 --- a/pyload/manager/Remote.py +++ b/pyload/manager/Remote.py @@ -62,8 +62,8 @@ class RemoteManager(object): def startBackends(self): - host = self.core.config["remote"]["listenaddr"] - port = self.core.config["remote"]["port"] + host = self.core.config.get("remote", "listenaddr") + port = self.core.config.get("remote", "port") for b in self.available: klass = getattr(__import__("pyload.remote.%s" % b, globals(), locals(), [b], -1), b) diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py index dd1582eb7..1f1a2dc5c 100644 --- a/pyload/manager/Thread.py +++ b/pyload/manager/Thread.py @@ -150,7 +150,7 @@ class ThreadManager(object): def tryReconnect(self): """checks if reconnect needed""" - if not (self.core.config["reconnect"]["activated"] and self.core.api.isTimeReconnect()): + if not (self.core.config.get("reconnect", "activated") and self.core.api.isTimeReconnect()): return False active = [x.active.plugin.wantReconnect and x.active.plugin.waiting for x in self.threads if x.active] @@ -158,11 +158,11 @@ class ThreadManager(object): if not (0 < active.count(True) == len(active)): return False - if not exists(self.core.config['reconnect']['method']): - if exists(join(pypath, self.core.config['reconnect']['method'])): - self.core.config['reconnect']['method'] = join(pypath, self.core.config['reconnect']['method']) + if not exists(self.core.config.get("reconnect", "method")): + if exists(join(pypath, self.core.config.get("reconnect", "method"))): + self.core.config['reconnect']['method'] = join(pypath, self.core.config.get("reconnect", "method")) else: - self.core.config["reconnect"]["activated"] = False + self.core.config['reconnect']['activated'] = False self.core.log.warning(_("Reconnect script not found!")) return @@ -181,10 +181,10 @@ class ThreadManager(object): self.core.log.debug("Old IP: %s" % ip) try: - reconn = Popen(self.core.config['reconnect']['method'], bufsize=-1, shell=True) # , stdout=subprocess.PIPE) + reconn = Popen(self.core.config.get("reconnect", "method"), bufsize=-1, shell=True) # , stdout=subprocess.PIPE) except Exception: self.core.log.warning(_("Failed executing reconnect script!")) - self.core.config["reconnect"]["activated"] = False + self.core.config['reconnect']['activated'] = False self.reconnecting.clear() if self.core.debug: print_exc() @@ -278,8 +278,8 @@ class ThreadManager(object): return if job.plugin.getPluginType() == "hoster": - spaceLeft = freeSpace(self.core.config["general"]["download_folder"]) / 1024 / 1024 - if spaceLeft < self.core.config["general"]["min_free_space"]: + spaceLeft = freeSpace(self.core.config.get("general", "download_folder")) / 1024 / 1024 + if spaceLeft < self.core.config.get("general", "min_free_space"): self.core.log.warning(_("Not enough space left on device")) self.pause = True diff --git a/pyload/manager/thread/Server.py b/pyload/manager/thread/Server.py index b724ad2f9..48958f6fb 100644 --- a/pyload/manager/thread/Server.py +++ b/pyload/manager/thread/Server.py @@ -20,12 +20,12 @@ class WebServer(threading.Thread): self.core = pycore core = pycore self.running = True - self.server = pycore.config['webui']['server'] - self.https = pycore.config['webui']['https'] - self.cert = pycore.config["ssl"]["cert"] - self.key = pycore.config["ssl"]["key"] - self.host = pycore.config['webui']['host'] - self.port = pycore.config['webui']['port'] + self.server = pycore.config.get("webui", "server") + self.https = pycore.config.get("webui", "https") + self.cert = pycore.config.get("ssl", "cert") + self.key = pycore.config.get("ssl", "key") + self.host = pycore.config.get("webui", "host") + self.port = pycore.config.get("webui", "port") self.setDaemon(True) diff --git a/pyload/network/RequestFactory.py b/pyload/network/RequestFactory.py index 5f8e7e206..97bc58209 100644 --- a/pyload/network/RequestFactory.py +++ b/pyload/network/RequestFactory.py @@ -21,7 +21,7 @@ class RequestFactory(object): def iface(self): - return self.core.config["download"]["interface"] + return self.core.config.get("download", "interface") def getRequest(self, pluginName, account=None, type="HTTP"): @@ -82,26 +82,26 @@ class RequestFactory(object): def getProxies(self): """ returns a proxy list for the request classes """ - if not self.core.config["proxy"]["proxy"]: + if not self.core.config.get("proxy", "proxy"): return {} else: type = "http" - setting = self.core.config["proxy"]["type"].lower() + setting = self.core.config.get("proxy", "type").lower() if setting == "socks4": type = "socks4" elif setting == "socks5": type = "socks5" username = None - if self.core.config["proxy"]["username"] and self.core.config["proxy"]["username"].lower() != "none": - username = self.core.config["proxy"]["username"] + if self.core.config.get("proxy", "username") and self.core.config.get("proxy", "username").lower() != "none": + username = self.core.config.get("proxy", "username") pw = None - if self.core.config["proxy"]["password"] and self.core.config["proxy"]["password"].lower() != "none": - pw = self.core.config["proxy"]["password"] + if self.core.config.get("proxy", "password") and self.core.config.get("proxy", "password").lower() != "none": + pw = self.core.config.get("proxy", "password") return { "type": type, - "address": self.core.config["proxy"]["address"], - "port": self.core.config["proxy"]["port"], + "address": self.core.config.get("proxy", "address"), + "port": self.core.config.get("proxy", "port"), "username": username, "password": pw, } @@ -111,15 +111,15 @@ class RequestFactory(object): """returns options needed for pycurl""" return {"interface": self.iface(), "proxies": self.getProxies(), - "ipv6": self.core.config["download"]["ipv6"]} + "ipv6": self.core.config.get("download", "ipv6")} def updateBucket(self): """ set values in the bucket according to settings""" - if not self.core.config["download"]["limit_speed"]: + if not self.core.config.get("download", "limit_speed"): self.bucket.setRate(-1) else: - self.bucket.setRate(self.core.config["download"]["max_speed"] * 1024) + self.bucket.setRate(self.core.config.get("download", "max_speed") * 1024) # needs pyreq in global namespace def getURL(*args, **kwargs): diff --git a/pyload/plugin/Container.py b/pyload/plugin/Container.py index 87d75976f..e8e42bb2b 100644 --- a/pyload/plugin/Container.py +++ b/pyload/plugin/Container.py @@ -45,7 +45,7 @@ class Container(Crypter): if self.pyfile.url.startswith("http"): self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1] content = self.load(self.pyfile.url) - self.pyfile.url = fs_join(self.core.config['general']['download_folder'], self.pyfile.name) + self.pyfile.url = fs_join(self.core.config.get("general", "download_folder"), self.pyfile.name) try: with open(self.pyfile.url, "wb") as f: f.write(content) diff --git a/pyload/plugin/Crypter.py b/pyload/plugin/Crypter.py index bfb558abd..3c1413f09 100644 --- a/pyload/plugin/Crypter.py +++ b/pyload/plugin/Crypter.py @@ -12,7 +12,7 @@ class Crypter(Plugin): __version = "0.05" __pattern = r'^unmatchable$' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] + __config = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config.get("general", "folder_per_package") ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] __description = """Base decrypter plugin""" @@ -65,7 +65,7 @@ class Crypter(Plugin): package_password = self.pyfile.package().password package_queue = self.pyfile.package().queue - folder_per_package = self.core.config['general']['folder_per_package'] + folder_per_package = self.core.config.get("general", "folder_per_package") try: use_subfolder = self.getConfig('use_subfolder') except Exception: diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py index 3ccf94f34..c18e16643 100644 --- a/pyload/plugin/Plugin.py +++ b/pyload/plugin/Plugin.py @@ -252,8 +252,8 @@ class Plugin(Base): def getChunkCount(self): if self.chunkLimit <= 0: - return self.core.config['download']['chunks'] - return min(self.core.config['download']['chunks'], self.chunkLimit) + return self.core.config.get("download", "chunks") + return min(self.core.config.get("download", "chunks"), self.chunkLimit) def __call__(self): @@ -616,17 +616,17 @@ class Plugin(Base): if disposition: self.pyfile.name = urlparse.urlparse(url).path.split('/')[-1] or self.pyfile.name - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") location = fs_join(download_folder, self.pyfile.package().folder) if not exists(location): try: - makedirs(location, int(self.core.config['permission']['folder'], 8)) + makedirs(location, int(self.core.config.get("permission", "folder"), 8)) - if self.core.config['permission']['change_dl'] and os.name != "nt": - uid = getpwnam(self.core.config['permission']['user'])[2] - gid = getgrnam(self.core.config['permission']['group'])[2] + if self.core.config.get("permission", "change_dl") and os.name != "nt": + uid = getpwnam(self.core.config.get("permission", "user"))[2] + gid = getgrnam(self.core.config.get("permission", "group"))[2] chown(location, uid, gid) except Exception, e: @@ -657,16 +657,16 @@ class Plugin(Base): fs_filename = fs_encode(filename) - if self.core.config['permission']['change_file']: + if self.core.config.get("permission", "change_file"): try: - chmod(fs_filename, int(self.core.config['permission']['file'], 8)) + chmod(fs_filename, int(self.core.config.get("permission", "file"), 8)) except Exception, e: self.logWarning(_("Setting file mode failed"), e) - if self.core.config['permission']['change_dl'] and os.name != "nt": + if self.core.config.get("permission", "change_dl") and os.name != "nt": try: - uid = getpwnam(self.core.config['permission']['user'])[2] - gid = getgrnam(self.core.config['permission']['group'])[2] + uid = getpwnam(self.core.config.get("permission", "user"))[2] + gid = getgrnam(self.core.config.get("permission", "group"))[2] chown(fs_filename, uid, gid) except Exception, e: @@ -740,10 +740,10 @@ class Plugin(Base): elif pyfile.status in (5, 7) and starting: # a download is waiting/starting and was appenrently started before raise SkipDownload(pyfile.pluginname) - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") location = fs_join(download_folder, pack.folder, self.pyfile.name) - if starting and self.core.config['download']['skip_existing'] and exists(location): + if starting and self.core.config.get("download", "skip_existing") and exists(location): size = os.stat(location).st_size if size >= self.pyfile.size: raise SkipDownload("File exists") diff --git a/pyload/plugin/addon/Checksum.py b/pyload/plugin/addon/Checksum.py index 53b9b4e9f..ed50b0f5e 100644 --- a/pyload/plugin/addon/Checksum.py +++ b/pyload/plugin/addon/Checksum.py @@ -105,7 +105,7 @@ class Checksum(Addon): self.checkFailed(pyfile, None, "No file downloaded") local_file = fs_encode(pyfile.plugin.lastDownload) - #download_folder = self.config['general']['download_folder'] + #download_folder = self.config.get("general", "download_folder") #local_file = fs_encode(fs_join(download_folder, pyfile.package().folder, pyfile.name)) if not isfile(local_file): @@ -166,7 +166,7 @@ class Checksum(Addon): def packageFinished(self, pypack): - download_folder = fs_join(self.config['general']['download_folder'], pypack.folder, "") + download_folder = fs_join(self.config.get("general", "download_folder"), pypack.folder, "") for link in pypack.getChildren().itervalues(): file_type = splitext(link['name'])[1][1:].lower() diff --git a/pyload/plugin/addon/ClickNLoad.py b/pyload/plugin/addon/ClickNLoad.py index b6448598a..4e1be807d 100644 --- a/pyload/plugin/addon/ClickNLoad.py +++ b/pyload/plugin/addon/ClickNLoad.py @@ -37,11 +37,11 @@ class ClickNLoad(Addon): def activate(self): - if not self.core.config['webui']['activated']: + if not self.core.config.get("webui", "activated"): return ip = "" if self.getConfig('extern') else "127.0.0.1" - webport = self.core.config['webui']['port'] + webport = self.core.config.get("webui", "port") cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py index 19d5202fd..341dd6dcd 100644 --- a/pyload/plugin/addon/ExternalScripts.py +++ b/pyload/plugin/addon/ExternalScripts.py @@ -122,10 +122,10 @@ class ExternalScripts(Addon): def downloadFailed(self, pyfile): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['download_failed']: file = fs_join(download_folder, pyfile.name) @@ -133,10 +133,10 @@ class ExternalScripts(Addon): def downloadFinished(self, pyfile): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['download_finished']: file = fs_join(download_folder, pyfile.name) @@ -154,10 +154,10 @@ class ExternalScripts(Addon): def packageFinished(self, pypack): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_finished']: self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) @@ -166,30 +166,30 @@ class ExternalScripts(Addon): def packageDeleted(self, pid): pack = self.core.api.getPackageInfo(pid) - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_deleted']: self.callScript(script, pack.id, pack.name, download_folder, pack.password) def package_extract_failed(self, pypack): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_extract_failed']: self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) def package_extracted(self, pypack): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_extracted']: self.callScript(script, pypack.id, pypack.name, download_folder) diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index a4a28ab32..26d3f07d9 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -264,7 +264,7 @@ class ExtractArchive(Addon): # reload from txt file self.reloadPasswords() - download_folder = self.config['general']['download_folder'] + download_folder = self.config.get("general", "download_folder") # iterate packages -> extractors -> targets for pid in ids: @@ -551,16 +551,16 @@ class ExtractArchive(Addon): continue try: - if self.config['permission']['change_file']: + if self.config.get("permission", "change_file"): if os.path.isfile(f): - os.chmod(f, int(self.config['permission']['file'], 8)) + os.chmod(f, int(self.config.get("permission", "file"), 8)) elif os.path.isdir(f): - os.chmod(f, int(self.config['permission']['folder'], 8)) + os.chmod(f, int(self.config.get("permission", "folder"), 8)) - if self.config['permission']['change_dl'] and os.name != "nt": - uid = getpwnam(self.config['permission']['user'])[2] - gid = getgrnam(self.config['permission']['group'])[2] + if self.config.get("permission", "change_dl") and os.name != "nt": + uid = getpwnam(self.config.get("permission", "user"))[2] + gid = getgrnam(self.config.get("permission", "group"))[2] os.chown(f, uid, gid) except Exception, e: diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py index dfc5f41d4..4f95ef9d7 100644 --- a/pyload/plugin/addon/MergeFiles.py +++ b/pyload/plugin/addon/MergeFiles.py @@ -37,9 +37,9 @@ class MergeFiles(Addon): files[data['name'][:-4]].sort() fid_dict[data['name']] = fid - download_folder = self.config['general']['download_folder'] + download_folder = self.config.get("general", "download_folder") - if self.config['general']['folder_per_package']: + if self.config.get("general", "folder_per_package"): download_folder = fs_join(download_folder, pack.folder) for name, file_list in files.iteritems(): diff --git a/pyload/plugin/addon/MultiHome.py b/pyload/plugin/addon/MultiHome.py index 057764a1e..bca6493db 100644 --- a/pyload/plugin/addon/MultiHome.py +++ b/pyload/plugin/addon/MultiHome.py @@ -24,7 +24,7 @@ class MultiHome(Addon): self.parseInterfaces(self.getConfig('interfaces').split(";")) if not self.interfaces: - self.parseInterfaces([self.config['download']['interface']]) + self.parseInterfaces([self.config.get("download", "interface")]) self.setConfig("interfaces", self.toConfig()) diff --git a/pyload/plugin/container/CCF.py b/pyload/plugin/container/CCF.py index 12031989e..ef105d8a8 100644 --- a/pyload/plugin/container/CCF.py +++ b/pyload/plugin/container/CCF.py @@ -33,7 +33,7 @@ class CCF(Container): 'filename': "test.ccf", 'upload' : open(fs_filename, "rb")}).read() - download_folder = self.config['general']['download_folder'] + download_folder = self.config.get("general", "download_folder") dlc_file = fs_join(download_folder, "tmp_%s.dlc" % pyfile.name) try: diff --git a/pyload/plugin/crypter/DailymotionComFolder.py b/pyload/plugin/crypter/DailymotionComFolder.py index 2fdb1ec8e..fe173fe82 100644 --- a/pyload/plugin/crypter/DailymotionComFolder.py +++ b/pyload/plugin/crypter/DailymotionComFolder.py @@ -101,6 +101,6 @@ class DailymotionComFolder(Crypter): for p_id, p_name, p_owner in playlists: p_videos = self.getVideos(p_id) - p_folder = fs_join(self.config['general']['download_folder'], p_owner, p_name) + p_folder = fs_join(self.config.get("general", "download_folder"), p_owner, p_name) self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) self.packages.append((p_name, p_videos, p_folder)) #: folder is NOT recognized by pyload 0.4.9! diff --git a/pyload/plugin/crypter/RelinkUs.py b/pyload/plugin/crypter/RelinkUs.py index e7fb7ed06..6296e9f40 100644 --- a/pyload/plugin/crypter/RelinkUs.py +++ b/pyload/plugin/crypter/RelinkUs.py @@ -219,7 +219,7 @@ class RelinkUs(Crypter): try: dlc = self.load(container_url) dlc_filename = self.fileid + ".dlc" - dlc_filepath = fs_join(self.config['general']['download_folder'], dlc_filename) + dlc_filepath = fs_join(self.config.get("general", "download_folder"), dlc_filename) with open(dlc_filepath, "wb") as f: f.write(dlc) package_links.append(dlc_filepath) diff --git a/pyload/plugin/crypter/YoutubeComFolder.py b/pyload/plugin/crypter/YoutubeComFolder.py index da76e556b..84277207a 100644 --- a/pyload/plugin/crypter/YoutubeComFolder.py +++ b/pyload/plugin/crypter/YoutubeComFolder.py @@ -132,7 +132,7 @@ class YoutubeComFolder(Crypter): for p in playlists: p_name = p['title'] p_videos = self.getVideosId(p['id']) - p_folder = fs_join(self.config['general']['download_folder'], p['channelTitle'], p_name) + p_folder = fs_join(self.config.get("general", "download_folder"), p['channelTitle'], p_name) self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) if not p_videos: diff --git a/pyload/plugin/hoster/Xdcc.py b/pyload/plugin/hoster/Xdcc.py index ff8d2c3b8..eda518150 100644 --- a/pyload/plugin/hoster/Xdcc.py +++ b/pyload/plugin/hoster/Xdcc.py @@ -191,7 +191,7 @@ class Xdcc(Hoster): self.pyfile.name = packname - download_folder = self.config['general']['download_folder'] + download_folder = self.config.get("general", "download_folder") filename = fs_join(download_folder, packname) self.logInfo(_("Downloading %s from %s:%d") % (packname, ip, port)) diff --git a/pyload/plugin/internal/SimpleCrypter.py b/pyload/plugin/internal/SimpleCrypter.py index f6c5aa5e2..c6582647f 100644 --- a/pyload/plugin/internal/SimpleCrypter.py +++ b/pyload/plugin/internal/SimpleCrypter.py @@ -15,7 +15,7 @@ class SimpleCrypter(Crypter, SimpleHoster): __version = "0.43" __pattern = r'^unmatchable$' - __config = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides core.config['general']['folder_per_package'] + __config = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides core.config.get("general", "folder_per_package") ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] __description = """Simple decrypter plugin""" diff --git a/pyload/remote/ThriftBackend.py b/pyload/remote/ThriftBackend.py index 83bb83811..adb168df2 100644 --- a/pyload/remote/ThriftBackend.py +++ b/pyload/remote/ThriftBackend.py @@ -21,11 +21,11 @@ class ThriftBackend(BackendBase): key = None cert = None - if self.core.config['ssl']['activated']: - if exists(self.core.config['ssl']['cert']) and exists(self.core.config['ssl']['key']): + if self.core.config.get("ssl", "activated"): + if exists(self.core.config.get("ssl", "cert")) and exists(self.core.config.get("ssl", "key")): self.core.log.info(_("Using SSL ThriftBackend")) - key = self.core.config['ssl']['key'] - cert = self.core.config['ssl']['cert'] + key = self.core.config.get("ssl", "key") + cert = self.core.config.get("ssl", "cert") transport = ServerSocket(port, host, key, cert) |