summaryrefslogtreecommitdiffstats
path: root/pyload/config
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/config')
-rw-r--r--pyload/config/Parser.py342
-rw-r--r--pyload/config/Setup.py538
-rw-r--r--pyload/config/default.conf64
3 files changed, 944 insertions, 0 deletions
diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py
new file mode 100644
index 000000000..33f048150
--- /dev/null
+++ b/pyload/config/Parser.py
@@ -0,0 +1,342 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import with_statement
+from time import sleep
+from os.path import exists, join
+from shutil import copy
+
+from traceback import print_exc
+from utils import chmod, encode, decode
+
+CONF_VERSION = 1
+
+class ConfigParser:
+ """
+ holds and manage the configuration
+
+ current dict layout:
+
+ {
+
+ section: {
+ option: {
+ value:
+ type:
+ desc:
+ }
+ desc:
+
+ }
+
+ """
+
+
+ def __init__(self):
+ """Constructor"""
+ self.config = {} # the config values
+ self.plugin = {} # the config for plugins
+ self.oldRemoteData = {}
+
+ self.pluginCB = None # callback when plugin config value is changed
+
+ self.checkVersion()
+
+ self.readConfig()
+
+
+ def checkVersion(self, n=0):
+ """determines if config need to be copied"""
+ try:
+ if not exists("pyload.conf"):
+ copy(join(pypath, "pyload", "config", "default.conf"), "pyload.conf")
+
+ if not exists("plugin.conf"):
+ f = open("plugin.conf", "wb")
+ f.write("version: " + str(CONF_VERSION))
+ f.close()
+
+ f = open("pyload.conf", "rb")
+ v = f.readline()
+ f.close()
+ v = v[v.find(":") + 1:].strip()
+
+ if not v or int(v) < CONF_VERSION:
+ copy(join(pypath, "pyload", "config", "default.conf"), "pyload.conf")
+ print "Old version of config was replaced"
+
+ f = open("plugin.conf", "rb")
+ v = f.readline()
+ f.close()
+ v = v[v.find(":") + 1:].strip()
+
+ if not v or int(v) < CONF_VERSION:
+ f = open("plugin.conf", "wb")
+ f.write("version: " + str(CONF_VERSION))
+ f.close()
+ print "Old version of plugin-config replaced"
+ except:
+ if n < 3:
+ sleep(0.3)
+ self.checkVersion(n + 1)
+ else:
+ raise
+
+ def readConfig(self):
+ """reads the config file"""
+
+ self.config = self.parseConfig(join(pypath, "pyload", "config", "default.conf"))
+ self.plugin = self.parseConfig("plugin.conf")
+
+ try:
+ homeconf = self.parseConfig("pyload.conf")
+ if "username" in homeconf["remote"]:
+ if "password" in homeconf["remote"]:
+ self.oldRemoteData = {"username": homeconf["remote"]["username"]["value"],
+ "password": homeconf["remote"]["username"]["value"]}
+ del homeconf["remote"]["password"]
+ del homeconf["remote"]["username"]
+ self.updateValues(homeconf, self.config)
+
+ except Exception, e:
+ print "Config Warning"
+ print_exc()
+
+
+ def parseConfig(self, config):
+ """parses a given configfile"""
+
+ f = open(config)
+
+ config = f.read()
+
+ config = config.splitlines()[1:]
+
+ conf = {}
+
+ section, option, value, typ, desc = "", "", "", "", ""
+
+ listmode = False
+
+ for line in config:
+ comment = line.rfind("#")
+ if line.find(":", comment) < 0 > line.find("=", comment) and comment > 0 and line[comment - 1].isspace():
+ line = line.rpartition("#") # removes comments
+ if line[1]:
+ line = line[0]
+ else:
+ line = line[2]
+
+ line = line.strip()
+
+ try:
+ if line == "":
+ continue
+ elif line.endswith(":"):
+ section, none, desc = line[:-1].partition('-')
+ section = section.strip()
+ desc = desc.replace('"', "").strip()
+ conf[section] = {"desc": desc}
+ else:
+ if listmode:
+ if line.endswith("]"):
+ listmode = False
+ line = line.replace("]", "")
+
+ value += [self.cast(typ, x.strip()) for x in line.split(",") if x]
+
+ if not listmode:
+ conf[section][option] = {"desc": desc,
+ "type": typ,
+ "value": value}
+
+
+ else:
+ content, none, value = line.partition("=")
+
+ content, none, desc = content.partition(":")
+
+ desc = desc.replace('"', "").strip()
+
+ typ, none, option = content.strip().rpartition(" ")
+
+ value = value.strip()
+
+ if value.startswith("["):
+ if value.endswith("]"):
+ listmode = False
+ value = value[:-1]
+ else:
+ listmode = True
+
+ value = [self.cast(typ, x.strip()) for x in value[1:].split(",") if x]
+ else:
+ value = self.cast(typ, value)
+
+ if not listmode:
+ conf[section][option] = {"desc": desc,
+ "type": typ,
+ "value": value}
+
+ except Exception, e:
+ print "Config Warning"
+ print_exc()
+
+ f.close()
+ return conf
+
+
+ def updateValues(self, config, dest):
+ """sets the config values from a parsed config file to values in destination"""
+
+ for section in config.iterkeys():
+ if section in dest:
+ for option in config[section].iterkeys():
+ if option in ("desc", "outline"): continue
+
+ if option in dest[section]:
+ dest[section][option]["value"] = config[section][option]["value"]
+
+ #else:
+ # dest[section][option] = config[section][option]
+
+
+ #else:
+ # dest[section] = config[section]
+
+ def saveConfig(self, config, filename):
+ """saves config to filename"""
+ with open(filename, "wb") as f:
+ chmod(filename, 0600)
+ f.write("version: %i \n" % CONF_VERSION)
+ for section in config.iterkeys():
+ f.write('\n%s - "%s":\n' % (section, config[section]["desc"]))
+
+ for option, data in config[section].iteritems():
+ if option in ("desc", "outline"): continue
+
+ if isinstance(data["value"], list):
+ value = "[ \n"
+ for x in data["value"]:
+ value += "\t\t" + str(x) + ",\n"
+ value += "\t\t]\n"
+ else:
+ if isinstance(data["value"], basestring):
+ value = data["value"] + "\n"
+ else:
+ value = str(data["value"]) + "\n"
+ try:
+ f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], value))
+ except UnicodeEncodeError:
+ f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], encode(value))
+
+ def cast(self, typ, value):
+ """cast value to given format"""
+ if not isinstance(value, basestring):
+ return value
+
+ elif typ == "int":
+ return int(value)
+ elif typ == "bool":
+ return True if value.lower() in ("1", "true", "on", "an", "yes") else False
+ elif typ == "time":
+ if not value: value = "0:00"
+ if not ":" in value: value += ":00"
+ return value
+ elif typ in ("str", "file", "folder"):
+ return encode(value)
+ else:
+ return value
+
+
+ def save(self):
+ """saves the configs to disk"""
+
+ self.saveConfig(self.config, "pyload.conf")
+ self.saveConfig(self.plugin, "plugin.conf")
+
+
+ def __getitem__(self, section):
+ """provides dictonary like access: c['section']['option']"""
+ return Section(self, section)
+
+
+ def get(self, section, option):
+ """get value"""
+ value = self.config[section][option]["value"]
+ return decode(value)
+
+ def set(self, section, option, value):
+ """set value"""
+
+ value = self.cast(self.config[section][option]["type"], value)
+
+ self.config[section][option]["value"] = value
+ self.save()
+
+ def getPlugin(self, plugin, option):
+ """gets a value for a plugin"""
+ value = self.plugin[plugin][option]["value"]
+ return encode(value)
+
+ def setPlugin(self, plugin, option, value):
+ """sets a value for a plugin"""
+
+ value = self.cast(self.plugin[plugin][option]["type"], value)
+
+ if self.pluginCB: self.pluginCB(plugin, option, value)
+
+ self.plugin[plugin][option]["value"] = value
+ self.save()
+
+ def getMetaData(self, section, option):
+ """ get all config data for an option """
+ return self.config[section][option]
+
+ def addPluginConfig(self, name, config, outline=""):
+ """adds config options with tuples (name, type, desc, default)"""
+ if name not in self.plugin:
+ conf = {"desc": name,
+ "outline": outline}
+ self.plugin[name] = conf
+ else:
+ conf = self.plugin[name]
+ conf["outline"] = outline
+
+ for item in config:
+ if item[0] in conf:
+ conf[item[0]]["type"] = item[1]
+ conf[item[0]]["desc"] = item[2]
+ else:
+ conf[item[0]] = {
+ "desc": item[2],
+ "type": item[1],
+ "value": self.cast(item[1], item[3])
+ }
+
+ values = [x[0] for x in config] + ["desc", "outline"]
+ #delete old values
+ for item in conf.keys():
+ if item not in values:
+ del conf[item]
+
+ def deleteConfig(self, name):
+ """Removes a plugin config"""
+ if name in self.plugin:
+ del self.plugin[name]
+
+
+class Section:
+ """provides dictionary like access for configparser"""
+
+ def __init__(self, parser, section):
+ """Constructor"""
+ self.parser = parser
+ self.section = section
+
+ def __getitem__(self, item):
+ """getitem"""
+ return self.parser.get(self.section, item)
+
+ def __setitem__(self, item, value):
+ """setitem"""
+ self.parser.set(self.section, item, value)
diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py
new file mode 100644
index 000000000..1fbdc3e51
--- /dev/null
+++ b/pyload/config/Setup.py
@@ -0,0 +1,538 @@
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+
+import pyload.utils.pylgettext as gettext
+
+from getpass import getpass
+from os import makedirs
+from os.path import abspath, dirname, exists, join
+from subprocess import PIPE, call
+
+from pyload.utils import get_console_encoding, versiontuple
+
+
+class SetupAssistant:
+ """ pyLoads initial setup configuration assistant """
+
+ def __init__(self, path, config):
+ self.path = path
+ self.config = config
+ self.stdin_encoding = get_console_encoding(sys.stdin.encoding)
+
+
+ def start(self):
+ langs = self.config.getMetaData("general", "language")["type"].split(";")
+ lang = self.ask(u"Choose setup language", "en", langs)
+ gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
+ translation = gettext.translation("setup", join(self.path, "locale"), languages=[lang, "en"], fallback=True)
+ translation.install(True)
+
+ #Input shorthand for yes
+ self.yes = _("y")
+ #Input shorthand for no
+ self.no = _("n")
+
+ # print
+ # print _("Would you like to configure pyLoad via Webinterface?")
+ # print _("You need a Browser and a connection to this PC for it.")
+ # viaweb = self.ask(_("Start initial webinterface for configuration?"), "y", bool=True)
+ # if viaweb:
+ # try:
+ # from pyload.manager.thread import ServerThread
+ # ServerThread.setup = self
+ # import pyload.webui as webinterface
+ # webinterface.run_simple()
+ # return False
+ # except Exception, e:
+ # print "Setup failed with this error: ", e
+ # print "Falling back to commandline setup."
+
+ print
+ print
+ print _("Welcome to the pyLoad Configuration Assistant.")
+ print _("It will check your system and make a basic setup in order to run pyLoad.")
+ print
+ print _("The value in brackets [] always is the default value,")
+ print _("in case you don't want to change it or you are unsure what to choose, just hit enter.")
+ print _(
+ "Don't forget: You can always rerun this assistant with --setup or -s parameter, when you start pyload.py .")
+ print _("If you have any problems with this assistant hit STRG-C,")
+ print _("to abort and don't let him start with pyload.py automatically anymore.")
+ print
+ print
+ raw_input(_("When you are ready for system check, hit enter."))
+ print
+ print
+
+ basic, ssl, captcha, web, js = self.system_check()
+ print
+ print
+
+ if not basic:
+ print _("You need pycurl, sqlite and python 2.5, 2.6 or 2.7 to run pyLoad.")
+ print _("Please correct this and re-run pyLoad.")
+ print
+ print _("Setup will now close.")
+ print
+ print
+ raw_input(_("Press Enter to exit."))
+ return False
+
+ raw_input(_("System check finished, hit enter to see your status report."))
+ print
+ print
+ print _("## Status ##")
+ print
+
+ avail = []
+ if self.check_module("Crypto"):
+ avail.append(_("container decrypting"))
+ if ssl:
+ avail.append(_("ssl connection"))
+ if captcha:
+ avail.append(_("automatic captcha decryption"))
+ if web:
+ avail.append(_("webinterface"))
+ if js:
+ avail.append(_("extended Click'N'Load"))
+
+ string = ""
+
+ for av in avail:
+ string += ", " + av
+
+ print _("AVAILABLE FEATURES:") + string[1:]
+ print
+
+ if len(avail) < 5:
+ print _("MISSING FEATURES: ")
+
+ if not self.check_module("Crypto"):
+ print _("- no py-crypto available")
+ print _("You need this if you want to decrypt container files.")
+ print
+
+ if not ssl:
+ print _("- no SSL available")
+ print _("This is needed if you want to establish a secure connection to core or webinterface.")
+ print _("If you only want to access locally to pyLoad ssl is not usefull.")
+ print
+
+ if not captcha:
+ print _("- no Captcha Recognition available")
+ print _("Only needed for some hosters and as freeuser.")
+ print
+
+ if not js:
+ print _("- no JavaScript engine found")
+ print _("You will need this for some Click'N'Load links. Install Spidermonkey, ossp-js, pyv8 or rhino")
+ print
+
+ print
+ print _("You can abort the setup now and fix some dependicies if you want.")
+
+ print
+ con = self.ask(_("Continue with setup?"), self.yes, bool=True)
+
+ if not con:
+ return False
+
+ print
+ print
+ print _("CURRENT CONFIG PATH: %s") % abspath("")
+ print
+ print _("NOTE: If you use pyLoad on a server or the home partition lives on an iternal flash it may be a good idea to change it.")
+ path = self.ask(_("Do you want to change the config path?"), self.no, bool=True)
+ if path:
+ print
+ self.conf_path()
+ #calls exit when changed
+
+ print
+ print _("Do you want to configure login data and basic settings?")
+ print _("This is recommend for first run.")
+ con = self.ask(_("Make basic setup?"), self.yes, bool=True)
+
+ if con:
+ print
+ print
+ self.conf_basic()
+
+ if ssl:
+ print
+ print _("Do you want to configure ssl?")
+ ssl = self.ask(_("Configure ssl?"), self.no, bool=True)
+ if ssl:
+ print
+ print
+ self.conf_ssl()
+
+ if web:
+ print
+ print _("Do you want to configure webinterface?")
+ web = self.ask(_("Configure webinterface?"), self.yes, bool=True)
+ if web:
+ print
+ print
+ self.conf_web()
+
+ print
+ print
+ print _("Setup finished successfully!")
+ print
+ print
+ raw_input(_("Hit enter to exit and restart pyLoad."))
+ return True
+
+
+ def system_check(self):
+ """ make a systemcheck and return the results"""
+
+ print _("## System Information ##")
+ print
+ print _("Platform: %s") % sys.platform
+ print _("Operating System: %s") % os.name
+ print _("Python: %s") % sys.version.replace("\n", "")
+ print
+ print
+
+ print _("## System Check ##")
+ print
+
+ if sys.version_info[:2] > (2, 7):
+ print _("Your python version is to new, Please use Python 2.6/2.7")
+ python = False
+ elif sys.version_info[:2] < (2, 5):
+ print _("Your python version is to old, Please use at least Python 2.5")
+ python = False
+ else:
+ print _("Python Version: OK")
+ python = True
+
+ curl = self.check_module("pycurl")
+ self.print_dep("pycurl", curl)
+
+ sqlite = self.check_module("sqlite3")
+ self.print_dep("sqlite3", sqlite)
+
+ basic = python and curl and sqlite
+
+ print
+
+ crypto = self.check_module("Crypto")
+ self.print_dep("pycrypto", crypto)
+
+ ssl = self.check_module("OpenSSL")
+ self.print_dep("py-OpenSSL", ssl)
+
+ print
+
+ pil = self.check_module("PIL.Image")
+ self.print_dep("PIL/Pillow", pil)
+
+ if os.name == "nt":
+ tesser = self.check_prog([join(pypath, "tesseract", "tesseract.exe"), "-v"])
+ else:
+ tesser = self.check_prog(["tesseract", "-v"])
+
+ self.print_dep("tesseract", tesser)
+
+ captcha = pil and tesser
+
+ print
+
+ try:
+ import jinja2
+
+ v = jinja2.__version__
+ if v and versiontuple(v) < (2, 5, 0):
+ jinja = False
+ else:
+ jinja = True
+ except:
+ jinja = False
+
+ jinja = self.print_dep("jinja2", jinja)
+
+ beaker = self.check_module("beaker")
+ self.print_dep("beaker", beaker)
+
+ bjoern = self.check_module("bjoern")
+ self.print_dep("bjoern", bjoern)
+
+ web = sqlite and beaker
+
+ from pyload.utils.JsEngine import JsEngine
+ js = True if JsEngine.find() else False
+ self.print_dep(_("JS engine"), js)
+
+ if not jinja:
+ print
+ print
+ print _("WARNING: Your installed jinja2 version %s seems too old.") % jinja2.__version__
+ print _("You can safely continue but if the webinterface is not working,")
+ print _("please upgrade or uninstall it, because pyLoad self-includes jinja2 libary.")
+
+ return basic, ssl, captcha, web, js
+
+
+ def conf_basic(self):
+ print _("## Basic Setup ##")
+
+ print
+ print _("The following logindata is valid for CLI and webinterface.")
+
+ from pyload.database import DatabaseBackend
+
+ db = DatabaseBackend(None)
+ db.setup()
+ print _("NOTE: Consider a password of 10 or more symbols if you expect to access from outside your local network (ex. internet).")
+ print
+ username = self.ask(_("Username"), "User")
+ password = self.ask("", "", password=True)
+ db.addUser(username, password)
+ db.shutdown()
+
+ print
+ print _("External clients (GUI, CLI or other) need remote access to work over the network.")
+ print _("However, if you only want to use the webinterface you may disable it to save ram.")
+ self.config["remote"]["activated"] = self.ask(_("Enable remote access"), self.no, bool=True)
+
+ print
+ langs = self.config.getMetaData("general", "language")
+ self.config["general"]["language"] = self.ask(_("Choose pyLoad language"), "en", langs["type"].split(";"))
+
+ print
+ self.config["general"]["download_folder"] = self.ask(_("Download folder"), "Downloads")
+ print
+ self.config["download"]["max_downloads"] = self.ask(_("Max parallel downloads"), "3")
+ print
+ reconnect = self.ask(_("Use Reconnect?"), self.no, bool=True)
+ self.config["reconnect"]["activated"] = reconnect
+ if reconnect:
+ self.config["reconnect"]["method"] = self.ask(_("Reconnect script location"), "./reconnect.sh")
+
+
+ def conf_web(self):
+ print _("## Webinterface Setup ##")
+
+ print
+ self.config["webinterface"]["activated"] = self.ask(_("Activate webinterface?"), self.yes, bool=True)
+ print
+ print _("Listen address, if you use 127.0.0.1 or localhost, the webinterface will only accessible locally.")
+ self.config["webinterface"]["host"] = self.ask(_("Address"), "0.0.0.0")
+ self.config["webinterface"]["port"] = self.ask(_("Port"), "8000")
+ print
+ print _("pyLoad offers several server backends, now following a short explanation.")
+ print "- builtin:", _("Default server; best choice if you plan to use pyLoad just for you.")
+ print "- threaded:", _("Support SSL connection and can serve simultaneously more client flawlessly.")
+ print "- fastcgi:", _(
+ "Can be used by apache, lighttpd, etc.; needs to be properly configured before.")
+ if os.name != "nt":
+ print "- lightweight:", _("Very fast alternative to builtin; requires libev and bjoern packages.")
+
+ print
+ print _("NOTE: In some rare cases the builtin server is not working, if you notice problems with the webinterface")
+ print _("come back here and change the builtin server to the threaded one here.")
+
+ if os.name == "nt":
+ servers = ["builtin", "threaded", "fastcgi"]
+ default = "threaded"
+ else:
+ servers = ["builtin", "threaded", "fastcgi", "lightweight"]
+ default = "lightweight" if self.check_module("bjoern") else "builtin"
+
+ self.config["webinterface"]["server"] = self.ask(_("Server"), default, servers)
+
+
+ def conf_ssl(self):
+ print _("## SSL Setup ##")
+ print
+ print _("Execute these commands from pyLoad config folder to make ssl certificates:")
+ print
+ print "openssl genrsa -out ssl.key 1024"
+ print "openssl req -new -key ssl.key -out ssl.csr"
+ print "openssl req -days 36500 -x509 -key ssl.key -in ssl.csr > ssl.crt "
+ print
+ print _("If you're done and everything went fine, you can activate ssl now.")
+
+ self.config["ssl"]["activated"] = self.ask(_("Activate SSL?"), self.yes, bool=True)
+
+
+ def set_user(self):
+ gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
+ translation = gettext.translation("setup", join(self.path, "locale"),
+ languages=[self.config["general"]["language"], "en"], fallback=True)
+ translation.install(True)
+
+ from pyload.database import DatabaseBackend
+
+ db = DatabaseBackend(None)
+ db.setup()
+
+ noaction = True
+ try:
+ while True:
+ print _("Select action")
+ print _("1 - Create/Edit user")
+ print _("2 - List users")
+ print _("3 - Remove user")
+ print _("4 - Quit")
+ action = raw_input("[1]/2/3/4: ")
+ if not action in ("1", "2", "3", "4"):
+ continue
+ elif action == "1":
+ print
+ username = self.ask(_("Username"), "User")
+ password = self.ask("", "", password=True)
+ db.addUser(username, password)
+ noaction = False
+ elif action == "2":
+ print
+ print _("Users")
+ print "-----"
+ users = db.listUsers()
+ noaction = False
+ for user in users:
+ print user
+ print "-----"
+ print
+ elif action == "3":
+ print
+ username = self.ask(_("Username"), "")
+ if username:
+ db.removeUser(username)
+ noaction = False
+ elif action == "4":
+ break
+ finally:
+ if not noaction:
+ db.shutdown()
+
+
+ def conf_path(self, trans=False):
+ if trans:
+ gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
+ translation = gettext.translation("setup", join(self.path, "locale"),
+ languages=[self.config["general"]["language"], "en"], fallback=True)
+ translation.install(True)
+
+ print _("Setting new config path, current configuration will not be transfered!")
+ path = self.ask(_("CONFIG PATH"), abspath(""))
+ try:
+ path = join(pypath, path)
+ if not exists(path):
+ makedirs(path)
+ f = open(join(pypath, "pyload", "config", "configdir"), "wb")
+ f.write(path)
+ f.close()
+ print
+ print
+ print _("pyLoad config path changed, setup will now close!")
+ print
+ print
+ raw_input(_("Press Enter to exit."))
+ sys.exit()
+ except Exception, e:
+ print _("Setting config path failed: %s") % str(e)
+
+
+ def print_dep(self, name, value):
+ """Print Status of dependency"""
+ if value:
+ print _("%s: OK") % name
+ else:
+ print _("%s: MISSING") % name
+
+
+ def check_module(self, module):
+ try:
+ __import__(module)
+ return True
+ except:
+ return False
+
+
+ def check_prog(self, command):
+ pipe = PIPE
+ try:
+ call(command, stdout=pipe, stderr=pipe)
+ return True
+ except:
+ return False
+
+
+ def ask(self, qst, default, answers=[], bool=False, password=False):
+ """produce one line to asking for input"""
+ if answers:
+ info = "("
+
+ for i, answer in enumerate(answers):
+ info += (", " if i != 0 else "") + str((answer == default and "[%s]" % answer) or answer)
+
+ info += ")"
+ elif bool:
+ if default == self.yes:
+ info = "([%s]/%s)" % (self.yes, self.no)
+ else:
+ info = "(%s/[%s])" % (self.yes, self.no)
+ else:
+ info = "[%s]" % default
+
+ if password:
+ p1 = True
+ p2 = False
+ pwlen = 8
+ while p1 != p2:
+ # getpass(_("Password: ")) will crash on systems with broken locales (Win, NAS)
+ sys.stdout.write(_("Password: "))
+ p1 = getpass("")
+
+ if len(p1) < pwlen:
+ print _("Password too short! Use at least %s symbols." % pwlen)
+ continue
+ elif not p1.isalnum():
+ print _("Password must be alphanumeric.")
+ continue
+
+ sys.stdout.write(_("Password (again): "))
+ p2 = getpass("")
+
+ if p1 == p2:
+ return p1
+ else:
+ print _("Passwords did not match.")
+
+ while True:
+ try:
+ input = raw_input(qst + " %s: " % info)
+ except KeyboardInterrupt:
+ print "\nSetup interrupted"
+ sys.exit()
+
+ input = input.decode(self.stdin_encoding)
+
+ if input.strip() == "":
+ input = default
+
+ if bool:
+ # yes, true, t are inputs for booleans with value true
+ if input.lower().strip() in [self.yes, _("yes"), _("true"), _("t"), "yes"]:
+ return True
+ # no, false, f are inputs for booleans with value false
+ elif input.lower().strip() in [self.no, _("no"), _("false"), _("f"), "no"]:
+ return False
+ else:
+ print _("Invalid Input")
+ continue
+
+ if not answers:
+ return input
+
+ else:
+ if input in answers:
+ return input
+ else:
+ print _("Invalid Input")
diff --git a/pyload/config/default.conf b/pyload/config/default.conf
new file mode 100644
index 000000000..d1f39f481
--- /dev/null
+++ b/pyload/config/default.conf
@@ -0,0 +1,64 @@
+version: 1
+
+remote - "Remote":
+ int port : "Port" = 7227
+ ip listenaddr : "Address" = 0.0.0.0
+ bool nolocalauth : "No authentication on local connections" = True
+ bool activated : "Activated" = True
+ssl - "SSL":
+ bool activated : "Activated"= False
+ file cert : "SSL Certificate" = ssl.crt
+ file key : "SSL Key" = ssl.key
+webinterface - "Web UI":
+ bool activated : "Activated" = True
+ builtin;threaded;fastcgi;lightweight server : "Server" = builtin
+ bool https : "Use HTTPS" = False
+ ip host : "IP" = 0.0.0.0
+ int port : "Port" = 8001
+ default;dark;flat theme : "Theme" = default
+ str prefix: "Path Prefix" =
+log - "Log":
+ bool file_log : "File Log" = True
+ folder log_folder : "Folder" = Logs
+ int log_count : "Count" = 5
+ int log_size : "Size in kb" = 100
+ bool log_rotate : "Log Rotate" = True
+general - "General":
+ en;de;fr;it;es;nl;sv;ru;pl;cs;sr;pt_BR language : "Language" = en
+ folder download_folder : "Download Folder" = Downloads
+ bool debug_mode : "Debug Mode" = False
+ int min_free_space : "Min Free Space (MB)" = 200
+ bool folder_per_package : "Create folder for each package" = True
+ int renice : "CPU Priority" = 0
+download - "Download":
+ int chunks : "Max connections for one download" = 3
+ int max_downloads : "Max Parallel Downloads" = 3
+ int max_speed : "Max Download Speed in kb/s" = -1
+ bool limit_speed : "Limit Download Speed" = False
+ str interface : "Download interface to bind (ip or Name)" = None
+ bool ipv6: "Allow IPv6" = False
+ bool skip_existing : "Skip already existing files" = False
+permission - "Permissions":
+ bool change_user : "Change user of running process" = False
+ str user : "Username" = user
+ str folder : "Folder Permission mode" = 0755
+ bool change_file : "Change file mode of downloads" = False
+ str file : "Filemode for Downloads" = 0644
+ bool change_group : "Change group of running process" = False
+ str group : "Groupname" = users
+ bool change_dl : "Change Group and User of Downloads" = False
+reconnect - "Reconnect":
+ bool activated : "Use Reconnect" = False
+ str method : "Method" = None
+ time startTime : "Start" = 0:00
+ time endTime : "End" = 0:00
+downloadTime - "Download Time":
+ time start : "Start" = 0:00
+ time end : "End" = 0:00
+proxy - "Proxy":
+ str address : "Address" = "localhost"
+ int port : "Port" = 7070
+ http;socks4;socks5 type : "Protocol" = http
+ str username : "Username" = None
+ password password : "Password" = None
+ bool proxy : "Use Proxy" = False