diff options
author | spoob <spoob@gmx.de> | 2009-08-18 20:56:50 +0200 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2009-08-18 20:56:50 +0200 |
commit | 0e843b30e373d286df59fe768fb43a39e1416b61 (patch) | |
tree | eef42d764d30279822ae3b5cfa5388261d965c94 | |
parent | new webinterface functions (diff) | |
download | pyload-0e843b30e373d286df59fe768fb43a39e1416b61.tar.xz |
Updated Config System
-rw-r--r-- | config | 10 | ||||
-rw-r--r-- | module/Py_Load_File.py | 4 | ||||
-rw-r--r-- | module/file_list.py | 4 | ||||
-rw-r--r-- | module/thread_list.py | 14 | ||||
-rwxr-xr-x | pyLoadCore.py | 47 |
5 files changed, 36 insertions, 43 deletions
@@ -28,14 +28,14 @@ search_updates = True install_updates = False [reconnectTime] -starttime = 0:00 -endtime = 0:00 +start = 0:00 +end = 0:00 [downloadTime] start = 0:00 end = 0:00 [proxy] -useproxy = False -proxyadress = http://localhost:8080 -proxyprotocol = http +activated = False +adress = http://localhost:8080 +protocol = http diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py index 570e605cd..278b8f6c7 100644 --- a/module/Py_Load_File.py +++ b/module/Py_Load_File.py @@ -30,8 +30,8 @@ class PyLoadFile: def init_download(self): - if self.parent.config['useproxy']: - self.plugin.req.add_proxy(self.parent.config['proxyprotocol'], self.parent.config['proxyadress']) + if self.parent.config['proxy']['activated']: + self.plugin.req.add_proxy(self.parent.config['proxy']['protocol'], self.parent.config['proxy']['adress']) #@todo: check dependicies, ocr etc diff --git a/module/file_list.py b/module/file_list.py index a83ab61a5..35bec757f 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -37,7 +37,7 @@ class File_List(object): def new_pyfile(self, url): url = url.replace("\n", "") pyfile = PyLoadFile(self.core, url) - pyfile.download_folder = self.core.config['download_folder'] + pyfile.download_folder = self.core.config['general']['download_folder'] pyfile.id = self.get_id() return pyfile @@ -56,7 +56,7 @@ class File_List(object): self.append(url) def remove(self, pyfile): - if not self.core.config['debug_mode']: + if not self.core.config['general']['debug_mode']: if pyfile in self.files: self.files.remove(pyfile) diff --git a/module/thread_list.py b/module/thread_list.py index 778e2587d..d4f2dac97 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -32,7 +32,7 @@ class Thread_List(object): self.parent = parent self.list = parent.file_list #file list self.threads = [] - self.max_threads = int(self.parent.config['max_downloads']) + self.max_threads = int(self.parent.config['general']['max_downloads']) self.lock = RLock() self.py_downloading = [] # files downloading self.occ_plugins = [] #occupied plugins @@ -113,7 +113,7 @@ class Thread_List(object): elif pyfile.status.type == "failed": self.parent.logger.warning("Download failed: " + pyfile.url+ " | " + pyfile.status.error) - with open(self.parent.config['failed_file'], 'a') as f: + with open(self.parent.config['general']['failed_file'], 'a') as f: f.write(pyfile.url + "\n") self.list.remove(pyfile) @@ -128,12 +128,12 @@ class Thread_List(object): def init_reconnect(self): """initialise a reonnect""" - if not self.parent.config['use_reconnect'] or self.reconnecting or not self.parent.is_reconnect_time(): + if not self.parent.config['general']['use_reconnect'] or self.reconnecting or not self.parent.is_reconnect_time(): return False - if not exists(self.parent.config['reconnect_method']): - self.parent.logger.info(self.parent.config['reconnect_method'] + " not found") - self.parent.config['use_reconnect'] = False + if not exists(self.parent.config['general']['reconnect_method']): + self.parent.logger.info(self.parent.config['general']['reconnect_method'] + " not found") + self.parent.config['general']['use_reconnect'] = False return False self.lock.acquire() @@ -167,7 +167,7 @@ class Thread_List(object): return False def reconnect(self): - reconn = subprocess.Popen(self.parent.config['reconnect_method']) + reconn = subprocess.Popen(self.parent.config['general']['reconnect_method']) reconn.wait() time.sleep(1) ip = "" diff --git a/pyLoadCore.py b/pyLoadCore.py index ff8641d39..8fa737c53 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -55,15 +55,15 @@ class Core(object): self.do_kill = False - translation = gettext.translation("pyLoad", "locale", languages=[self.config['language']]) + translation = gettext.translation("pyLoad", "locale", languages=[self.config['general']['language']]) translation.install(unicode=True) - self.check_create(self.config['log_folder'], _("folder for logs")) - self.check_create(self.config['download_folder'], _("folder for downloads")) - self.check_create(self.config['link_file'], _("file for links"), False) - self.check_create(self.config['failed_file'], _("file for failed links"), False) + self.check_create(self.config['log']['log_folder'], _("folder for logs")) + self.check_create(self.config['general']['download_folder'], _("folder for downloads")) + self.check_create(self.config['general']['link_file'], _("file for links"), False) + self.check_create(self.config['general']['failed_file'], _("file for failed links"), False) - if self.config['debug_mode']: + if self.config['general']['debug_mode']: self.init_logger(logging.DEBUG) # logging level self.print_test_status = True else: @@ -93,13 +93,6 @@ class Core(object): self.configfile.read('config') for section in self.configfile.sections(): - for option in self.configfile.options(section): - self.config[option] = self.configfile.get(section, option) - self.config[option] = False if self.config[option].lower() == 'false' else self.config[option] - - #new config syntax, keep old until all config accesses are changed - - for section in self.configfile.sections(): self.config[section] = {} for option in self.configfile.options(section): self.config[section][option] = self.configfile.get(section, option) @@ -113,10 +106,10 @@ class Core(object): def read_option(self): return self.config - def create_plugin_index(self): - for file_handler in glob(self.config['plugin_folder'] + sep + '*.py') + glob(self.config['plugin_folder'] + sep + 'DLC.pyc'): - if file_handler != self.config['plugin_folder'] + sep + "Plugin.py": + plugin_folder = self.config['plugin_folder'] + for file_handler in glob(plugin_folder + sep + '*.py') + glob(plugin_folder + sep + 'DLC.pyc'): + if file_handler != plugin_folder + sep + "Plugin.py": plugin_pattern = "" plugin_file = basename(file_handler).replace('.pyc', '').replace('.py', '') for line in open(file_handler, "r").readlines(): @@ -129,7 +122,7 @@ class Core(object): def read_links(self): """read links from txt""" - txt = open(self.config['link_file'], 'r') + txt = open(self.config['general']['link_file'], 'r') new_links = 0 links = txt.readlines() for link in links: @@ -141,21 +134,21 @@ class Core(object): self.file_list.save() if new_links: - self.logger.info("Parsed link from %s: %i" % (self.config['link_file'], new_links)) + self.logger.info("Parsed link from %s: %i" % (self.config['general']['link_file'], new_links)) - txt = open(self.config['link_file'], 'w') + txt = open(self.config['general']['link_file'], 'w') txt.write("") txt.close() def check_update(self): """checks newst version """ - if not self.config['search_updates']: + if not self.config['updates']['search_updates']: return False newst_version = urllib2.urlopen("http://update.pyload.org/index.php?do=" + CURRENT_VERSION).readline() if newst_version == "True": - if not self.config['install_updates']: + if not self.config['updates']['install_updates']: self.logger.info("New version available, please run Updater") else: updater = __import__("pyLoadUpdater") @@ -177,7 +170,7 @@ class Core(object): def init_logger(self, level): - file_handler = logging.handlers.RotatingFileHandler(self.config['log_folder'] + sep + 'log.txt', maxBytes=102400, backupCount=int(self.config['log_count'])) #100 kib each + file_handler = logging.handlers.RotatingFileHandler(self.config['log']['log_folder'] + sep + 'log.txt', maxBytes=102400, backupCount=int(self.config['log']['log_count'])) #100 kib each console = logging.StreamHandler(stdout) frm = logging.Formatter("%(asctime)s: %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S") @@ -186,22 +179,22 @@ class Core(object): self.logger = logging.getLogger("log") # settable in config - if self.config['file_log']: + if self.config['log']['file_log']: self.logger.addHandler(file_handler) self.logger.addHandler(console) #if console logging self.logger.setLevel(level) def is_dltime(self): - start = self.config['start'].split(":") - end = self.config['end'].split(":") + start = self.config['downloadTime']['start'].split(":") + end = self.config['downloadTime']['end'].split(":") return self.compare_time(start, end) def is_reconnect_time(self): - start = self.config['starttime'].split(":") - end = self.config['endtime'].split(":") + start = self.config['reconnectTime']['start'].split(":") + end = self.config['reconnectTime']['end'].split(":") return self.compare_time(start, end) |