diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-01 13:10:51 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-01 13:10:51 +0200 |
commit | af6cf761c6d873648fa0ffdb4cc9f2f1a032dd3d (patch) | |
tree | 518e26cd3f11299ab3dd6755ae5a877216a24ee9 | |
parent | webif config fix (diff) | |
download | pyload-af6cf761c6d873648fa0ffdb4cc9f2f1a032dd3d.tar.xz |
some fixes
-rw-r--r-- | module/ConfigParser.py | 45 | ||||
-rw-r--r-- | module/plugins/Hook.py | 2 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 1 | ||||
-rw-r--r-- | module/plugins/hooks/ExternalScripts.py | 5 | ||||
-rw-r--r-- | module/plugins/hoster/BasePlugin.py | 7 | ||||
-rw-r--r-- | module/web/pyload/views.py | 10 | ||||
-rw-r--r-- | module/web/templates/default/settings.html | 4 |
7 files changed, 46 insertions, 28 deletions
diff --git a/module/ConfigParser.py b/module/ConfigParser.py index e37d3f521..3abc5a6ae 100644 --- a/module/ConfigParser.py +++ b/module/ConfigParser.py @@ -49,11 +49,11 @@ class ConfigParser: def checkVersion(self): """determines if config need to be copied""" - if not exists("pyload.config"): - copy(join(pypath,"module", "config", "default.config"), "pyload.config") + if not exists("pyload.conf"): + copy(join(pypath,"module", "config", "default.conf"), "pyload.conf") - if not exists("plugin.config"): - f = open("plugin.config", "wb") + if not exists("plugin.conf"): + f = open("plugin.conf", "wb") f.close() #@TODO: testing conf file version @@ -62,11 +62,11 @@ class ConfigParser: def readConfig(self): """reads the config file""" - self.config = self.parseConfig(join(pypath,"module", "config", "default.config")) - self.plugin = self.parseConfig("plugin.config") + self.config = self.parseConfig(join(pypath,"module", "config", "default.conf")) + self.plugin = self.parseConfig("plugin.conf") try: - homeconf = self.parseConfig("pyload.config") + homeconf = self.parseConfig("pyload.conf") self.updateValues(homeconf, self.config) except Exception, e: @@ -139,7 +139,7 @@ class ConfigParser: desc = desc.replace('"', "").strip() typ, option = content.split() - + value = value.strip() if value.startswith("["): @@ -205,10 +205,10 @@ class ConfigParser: if isinstance(data["value"], list): value = "[ \n" for x in data["value"]: - value += "\t\t" + x + ",\n" + value += "\t\t" + str(x) + ",\n" value += "\t\t]\n" else: - value = data["value"] + "\n" + value = str(data["value"]) + "\n" f.write('\t%s %s : "%s" = %s' % (data["typ"], option, data["desc"], value) ) #---------------------------------------------------------------------- @@ -224,8 +224,25 @@ class ConfigParser: #---------------------------------------------------------------------- def save(self): """saves the configs to disk""" - self.saveConfig(self.config, "pyload.config") - self.saveConfig(self.plugin, "plugin.config") + + self.config["remote"]["username"] = { + "desc" : "Username", + "typ": "str", + "value": self.username + } + + self.config["remote"]["password"] = { + "desc" : "Password", + "typ": "str", + "value": self.password + } + + self.saveConfig(self.config, "pyload.conf") + + del self.config["remote"]["username"] + del self.config["remote"]["password"] + + self.saveConfig(self.plugin, "plugin.conf") #---------------------------------------------------------------------- def __getitem__(self, section): @@ -263,14 +280,14 @@ class ConfigParser: config[1] : { "desc" : config[3], "typ" : config[2], - "value" : config[4] + "value" : self.cast(config[2], config[4]) } } else: if not self.plugin[config[0]].has_key(config[1]): self.plugin[config[0]][config[1]] = { "desc" : config[3], "typ" : config[2], - "value" : config[4] + "value" : self.cast(config[2], config[4]) } ######################################################################## diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index 7adbe2bbd..35be45b30 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -25,7 +25,7 @@ class Hook(): __version__ = "0.2" __type__ = "hook" __threaded__ = [] - __config__ = [] + __config__ = [ ("name", "type", "desc" , "default") ] __description__ = """interface for hook""" __author_name__ = ("mkaay", "RaNaN") __author_mail__ = ("mkaay@mkaay.de", "RaNaN@pyload.org") diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 1d3fb4309..5a53b4e47 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -57,6 +57,7 @@ class Plugin(object): __version__ = "0.4" __pattern__ = None __type__ = "hoster" + __config__ = [ ("name", "type", "desc" , "default") ] __description__ = """Base Plugin""" __author_name__ = ("RaNaN", "spoob", "mkaay") __author_mail__ = ("RaNaN@pyload.org", "spoob@pyload.org", "mkaay@mkaay.de") diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index c4bc76c82..a876618c3 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -28,6 +28,7 @@ class ExternalScripts(Hook): __name__ = "ExternalScripts" __version__ = "0.1" __description__ = """run external scripts""" + __config__ = [ ("activated", "bool", "Activated" , "True") ] __author_name__ = ("mkaay", "RaNaN", "spoob") __author_mail__ = ("mkaay@mkaay.de", "ranan@pyload.org", "spoob@pyload.org") @@ -77,8 +78,8 @@ class ExternalScripts(Hook): try: out = subprocess.Popen([join(self.folder, 'download_finished', script), pyfile.plugin.__name__, pyfile.url, pyfile.name, \ join(self.core.config['general']['download_folder'], pyfile.package().folder, pyfile.name)], stdout=subprocess.PIPE) - except Exception, e: - print e + except: + pass def packageFinished(self, pypack): for script in self.scripts['package_finished']: diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index b64e826f8..09545d493 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -16,13 +16,6 @@ class BasePlugin(Hoster): def process(self, pyfile): """main function""" - #debug stuff - - res = self.decryptCaptcha("http://www.google.com/recaptcha/api/image?c=03AHJ_VusNo91yuOYR22VR2J2XUl4x8fqcKbKato005zKhc10DT8FmIP4WQwK_5QkJZVRdCNWDPSlASuS12Y30qMjBguJpYA9fztHKFE8Lp2FGOrl6EnMcgTeyx_6FuVpMstX_XRuhusH-Z6H3Tchsj077ptyDMOPFrg") - print res - - #end - if pyfile.url.startswith("http://"): pyfile.name = re.findall("([^\/=]+)", pyfile.url)[-1] diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index a97cfbfd7..e6428d146 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -187,8 +187,8 @@ def config(request): try: if str(conf[skey][okey]['value']) != value: settings.PYLOAD.set_conf_val(skey, okey, value) - except: - errors.append("%s | %s" % (skey, okey)) + except Exception, e: + errors.append("%s | %s : %s" % (skey, okey, e)) else: continue else: @@ -205,5 +205,11 @@ def config(request): return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {}, 'errors': messages}, [status_proc])) + for section in conf.itervalues(): + for key, option in section.iteritems(): + if key == "desc": continue + + if ";" in option["typ"]: + option["list"] = option["typ"].split(";") return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': conf, 'messages': []}, [status_proc])) diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html index 36563b086..07c87a936 100644 --- a/module/web/templates/default/settings.html +++ b/module/web/templates/default/settings.html @@ -49,9 +49,9 @@ <option {% if not option.value %} selected="selected" {% endif %}value="False">{% trans "off" %}</option> </select> {% else %} - {% if option.input %} + {% if ";" in option.typ %} <select id="{{skey}}|{{okey}}" name="{{skey}}|{{okey}}"> - {% for entry in option.input %} + {% for entry in option.list %} <option {% ifequal option.value entry %} selected="selected" {% endifequal %}>{{entry}}</option> {% endfor %} </select> |