summaryrefslogtreecommitdiffstats
path: root/module/setup.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-12-07 20:01:46 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-12-07 20:01:46 +0100
commit20075709afd16c7bb69b482e552f041d20a652f2 (patch)
tree37e332a95a418e92ee384954dbf152729e1780e0 /module/setup.py
parentclosed #436 (diff)
downloadpyload-20075709afd16c7bb69b482e552f041d20a652f2.tar.xz
closed #445
Diffstat (limited to 'module/setup.py')
-rw-r--r--module/setup.py137
1 files changed, 68 insertions, 69 deletions
diff --git a/module/setup.py b/module/setup.py
index 2f6963db9..85b33b1ee 100644
--- a/module/setup.py
+++ b/module/setup.py
@@ -34,38 +34,37 @@ class Setup():
"""
pyLoads initial setup configuration assistent
"""
- def __init__(self, path, config):
+ def __init__(self, path, config):
self.path = path
self.config = config
def start(self):
-
langs = self.config.getMetaData("general", "language")["type"].split(";")
lang = self.ask(u"Choose your Language / Wähle deine Sprache", "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 = gettext.translation("setup", join(self.path, "locale"), languages=[lang, "en"], fallback=True)
translation.install(True)
#Input shorthand for yes
- self.yes=_("y")
+ 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 module.web import ServerThread
-# ServerThread.setup = self
-# from module.web import webinterface
-# webinterface.run_simple()
-# return False
-# except Exception, e:
-# print "Setup failed with this error: ", e
-# print "Falling back to commandline setup."
+ 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 module.web import ServerThread
+ # ServerThread.setup = self
+ # from module.web import webinterface
+ # webinterface.run_simple()
+ # return False
+ # except Exception, e:
+ # print "Setup failed with this error: ", e
+ # print "Falling back to commandline setup."
print ""
@@ -74,13 +73,14 @@ class Setup():
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 assistent with --setup or -s parameter, when you start pyLoadCore.")
+ print _(
+ "Don't forget: You can always rerun this assistent with --setup or -s parameter, when you start pyLoadCore.")
print _("If you have any problems with this assistent hit STRG-C,")
print _("to abort and don't let him start with pyLoadCore automatically anymore.")
print ""
print _("When you are ready for system check, hit enter.")
raw_input()
-
+
basic, ssl, captcha, gui, web, js = self.system_check()
print ""
@@ -95,8 +95,7 @@ class Setup():
print ""
print _("## Status ##")
print ""
-
-
+
avail = []
if self.check_module("Crypto"): avail.append(_("container decrypting"))
if ssl: avail.append(_("ssl connection"))
@@ -104,44 +103,44 @@ class Setup():
if gui: avail.append(_("GUI"))
if web: avail.append(_("Webinterface"))
if js: avail.append(_("extended Click'N'Load"))
-
+
string = ""
-
+
for av in avail:
- string += ", "+av
+ string += ", " + av
print _("Features available:") + string[1:]
print ""
-
+
if len(avail) < 5:
print _("Featues missing: ")
print
-
+
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 gui:
print _("Gui not available")
print _("The Graphical User Interface.")
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 _("You can abort the setup now and fix some dependicies if you want.")
con = self.ask(_("Continue with setup?"), self.yes, bool=True)
@@ -151,13 +150,13 @@ class Setup():
print ""
print _("Do you want to change the config path? Current is %s") % abspath("")
- print _("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(_("Change config path?"), self.no , bool=True)
+ print _(
+ "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(_("Change config path?"), self.no, bool=True)
if path:
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.")
@@ -202,7 +201,6 @@ class Setup():
print _("Python Version: OK")
python = True
-
curl = self.check_module("pycurl")
self.print_dep("pycurl", curl)
@@ -212,10 +210,10 @@ class Setup():
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)
@@ -223,12 +221,12 @@ class Setup():
pil = self.check_module("Image")
self.print_dep("py-imaging", 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
@@ -243,6 +241,7 @@ class Setup():
try:
import jinja2
+
v = jinja2.__version__
if v and "unknown" not in v:
if not v.startswith("2.5") and not v.startswith("2.6"):
@@ -251,15 +250,13 @@ class Setup():
print _("please upgrade or deinstall it, pyLoad includes a sufficient jinja2 libary.")
print
jinja = False
- except :
+ except:
pass
-
self.print_dep("jinja2", jinja)
beaker = self.check_module("beaker")
self.print_dep("beaker", beaker)
-
web = sqlite and beaker
from module.common import JsEngine
@@ -275,11 +272,12 @@ class Setup():
print ""
print _("The following logindata is valid for CLI, GUI and webinterface.")
-
+
from module.database import DatabaseBackend
+
db = DatabaseBackend(None)
db.setup()
- username = self.ask(_("Username"), "User")
+ username = self.ask(_("Username"), "User")
password = self.ask("", "", password=True)
db.addUser(username, password)
db.shutdown()
@@ -289,12 +287,10 @@ class Setup():
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.yes, bool=True)
-
print ""
langs = self.config.getMetaData("general", "language")
self.config["general"]["language"] = self.ask(_("Language"), "en", langs["type"].split(";"))
-
self.config["general"]["download_folder"] = self.ask(_("Downloadfolder"), "Downloads")
self.config["download"]["max_downloads"] = self.ask(_("Max parallel downloads"), "3")
#print _("You should disable checksum proofing, if you have low hardware requirements.")
@@ -309,7 +305,7 @@ class Setup():
def conf_web(self):
print ""
print _("## Webinterface Setup ##")
-
+
print ""
self.config["webinterface"]["activated"] = self.ask(_("Activate webinterface?"), self.yes, bool=True)
print ""
@@ -320,17 +316,19 @@ class Setup():
print _("pyLoad offers several server backends, now following a short explanation.")
print "builtin:", _("Default server, best choice if you dont know which one to choose.")
print "threaded:", _("This server offers SSL and is a good alternative to builtin.")
- print "fastcgi:", _("Can be used by apache, lighttpd, requires you to configure them, which is not too easy job.")
+ print "fastcgi:", _(
+ "Can be used by apache, lighttpd, requires you to configure them, which is not too easy job.")
print "lightweight:", _("Very fast alternative written in C, requires libev and linux knowlegde.")
print "\t", _("Get it from here: https://github.com/jonashaag/bjoern, compile it")
print "\t", _("and copy bjoern.so to module/lib")
print
- print _("Attention: In some rare cases the builtin server is not working, if you notice problems with the webinterface")
+ print _(
+ "Attention: 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.")
-
- self.config["webinterface"]["server"] = self.ask(_("Server"), "builtin", ["builtin", "threaded", "fastcgi", "lightweight"])
+ self.config["webinterface"]["server"] = self.ask(_("Server"), "builtin",
+ ["builtin", "threaded", "fastcgi", "lightweight"])
def conf_ssl(self):
print ""
@@ -348,13 +346,15 @@ class Setup():
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 = gettext.translation("setup", join(self.path, "locale"),
+ languages=[self.config["general"]["language"], "en"], fallback=True)
translation.install(True)
-
+
from module.database import DatabaseBackend
+
db = DatabaseBackend(None)
db.setup()
-
+
noaction = True
try:
while True:
@@ -368,7 +368,7 @@ class Setup():
continue
elif action == "1":
print ""
- username = self.ask(_("Username"), "User")
+ username = self.ask(_("Username"), "User")
password = self.ask("", "", password=True)
db.addUser(username, password)
noaction = False
@@ -400,16 +400,17 @@ class Setup():
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 = gettext.translation("setup", join(self.path, "locale"),
+ languages=[self.config["general"]["language"], "en"], fallback=True)
translation.install(True)
-
+
print _("Setting new configpath, current configuration will not be transfered!")
path = self.ask(_("Configpath"), abspath(""))
try:
path = join(pypath, path)
if not exists(path):
makedirs(path)
- f = open(join(pypath, "module","config", "configdir"), "wb")
+ f = open(join(pypath, "module", "config", "configdir"), "wb")
f.write(path)
f.close()
print _("Configpath changed, setup will now close, please restart to go on.")
@@ -418,7 +419,7 @@ class Setup():
exit()
except Exception, e:
print _("Setting config path failed: %s") % str(e)
-
+
def print_dep(self, name, value):
"""Print Status of dependency"""
if value:
@@ -463,7 +464,6 @@ class Setup():
p1 = True
p2 = False
while p1 != p2:
-
if os.name == "nt":
qst = str("Password: ") #no unicode on windows
else:
@@ -495,17 +495,16 @@ class Setup():
input = default
if bool:
- # yes, true,t are inputs for booleans with value true
- if input.lower().strip() in [self.yes, _("yes"), _("true"), _("t")]:
- return True
- # no, false,f are inputs for booleans with value false
+ # yes, true,t are inputs for booleans with value true
+ if input.lower().strip() in [self.yes, _("yes"), _("true"), _("t")]:
+ return True
+ # no, false,f are inputs for booleans with value false
elif input.lower().strip() in [self.no, _("no"), _("false"), _("f")]:
return False
else:
print _("Invalid Input")
continue
-
if not answers:
return input