diff options
author | spoob <spoob@gmx.de> | 2009-11-08 16:08:34 +0100 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2009-11-08 16:08:34 +0100 |
commit | 6448aaa4a571a3981b04eccaa546a36507c7bc20 (patch) | |
tree | 6be34c5077079a0963b4e9a970654f86f23b88eb /pyLoadCore.py | |
parent | netload premium, second try, fixed #33 (diff) | |
download | pyload-6448aaa4a571a3981b04eccaa546a36507c7bc20.tar.xz |
check installs, fix #32
Diffstat (limited to 'pyLoadCore.py')
-rwxr-xr-x | pyLoadCore.py | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/pyLoadCore.py b/pyLoadCore.py index 8cd0f2bb9..68ec53613 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -31,6 +31,7 @@ from os.path import basename from os.path import exists from os.path import dirname from os.path import abspath +import subprocess from sys import argv from sys import exit from sys import path @@ -44,12 +45,6 @@ try: except ImportError: print "Install pycrypto to use pyLoad" exit() - -try: - find_module("pycurl") -except ImportError: - print "Install pycurl for lower memory footprint while downloading" - from module.file_list import File_List from module.remote.RequestObject import RequestObject from module.remote.SocketServer import ServerThread @@ -72,7 +67,10 @@ class Core(object): self.do_kill = False translation = gettext.translation("pyLoad", "locale", languages=[self.config['general']['language']]) translation.install(unicode=True) - + + self.check_installs("pycurl", "pycurl for lower memory footprint while downloading") + self.check_installs("tesseract", "tesseract for captcha reading", False, True) + self.check_installs("gocr", "gocr for captcha reading", False, True) 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) @@ -100,7 +98,32 @@ class Core(object): #Webserver self.init_webserver() - + + def check_installs(self, check_name, legend, python=True, essential=False): + """check wether needed tools are installed""" + try: + if python: + find_module(check_name) + else: + pipe = subprocess.PIPE + subprocess.Popen(check_name, stdout=pipe, stderr=pipe) + except: + print "Install", legend + if essential: exit() + + def check_create(self, check_name, legend, folder=True): + """check wether needed files are exists""" + if not exists(check_name): + try: + if folder: + mkdir(check_name) + else: + open(check_name, "w") + print _("%s created") % legend + except: + print _("could not create %s") % legend + exit() + def read_config(self): """ read config and sets preferences """ @@ -169,18 +192,6 @@ class Core(object): else: self.logger.info("pyLoad is up-to-date") - def check_create(self, check_name, legend, folder=True): - if not exists(check_name): - try: - if folder: - mkdir(check_name) - else: - open(check_name, "w") - print _("%s created") % legend - except: - print _("could not create %s") % legend - exit() - def init_logger(self, level): 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 |