From 5499be89203a18ca61a21cfc7266cf0f4ebe6547 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 15 Dec 2011 23:18:21 +0100 Subject: refractoring --- pyLoadCore.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index e6b539097..a9faad908 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -41,10 +41,10 @@ from traceback import print_exc from module import InitHomeDir from module.plugins.AccountManager import AccountManager -from module.CaptchaManager import CaptchaManager +from module.interaction.CaptchaManager import CaptchaManager from module.ConfigParser import ConfigParser from module.plugins.PluginManager import PluginManager -from module.PullEvents import PullManager +from module.interaction.PullEvents import PullManager from module.network.RequestFactory import RequestFactory from module.web.ServerThread import WebServer from module.Scheduler import Scheduler -- cgit v1.2.3 From 4e918edba6c3808b095eab1bad137a2a8cab970d Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 17 Dec 2011 21:53:57 +0100 Subject: updated plugin api and plugin manager --- pyLoadCore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index a9faad908..35e667d01 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -20,7 +20,7 @@ @author: mkaay @version: v0.4.9 """ -CURRENT_VERSION = '0.4.9' +CURRENT_VERSION = '0.4.9.9-dev' import __builtin__ -- cgit v1.2.3 From 6eae782f13953dd0ba2bbe1b582cf33fd4d7d90a Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 19 Dec 2011 23:10:49 +0100 Subject: configparser v2, warning CONFIG will be DELETED. --- pyLoadCore.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 35e667d01..7efab1061 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -42,7 +42,7 @@ from traceback import print_exc from module import InitHomeDir from module.plugins.AccountManager import AccountManager from module.interaction.CaptchaManager import CaptchaManager -from module.ConfigParser import ConfigParser +from module.config.ConfigParser import ConfigParser from module.plugins.PluginManager import PluginManager from module.interaction.PullEvents import PullManager from module.network.RequestFactory import RequestFactory @@ -58,6 +58,7 @@ from module.utils import freeSpace, formatSize, get_console_encoding from codecs import getwriter enc = get_console_encoding(sys.stdout.encoding) +sys._stdout = sys.stdout sys.stdout = getwriter(enc)(sys.stdout, errors="replace") # TODO List @@ -294,6 +295,9 @@ class Core(object): languages=[self.config['general']['language'],"en"],fallback=True) translation.install(True) + # load again so translations are propagated + self.config.loadDefault() + self.debug = self.doDebug or self.config['general']['debug_mode'] self.remote &= self.config['remote']['activated'] @@ -360,11 +364,6 @@ class Core(object): self.check_install("OpenSSL", _("OpenSSL for secure connection")) self.setupDB() - if self.config.oldRemoteData: - self.log.info(_("Moving old user config to DB")) - self.db.addUser(self.config.oldRemoteData["username"], self.config.oldRemoteData["password"]) - - self.log.info(_("Please check your logindata with ./pyLoadCore.py -u")) if self.deleteLinks: self.log.info(_("All links removed")) @@ -446,13 +445,22 @@ class Core(object): #some memory stats # from guppy import hpy # hp=hpy() +# print hp.heap() # import objgraph -# objgraph.show_most_common_types(limit=20) +# objgraph.show_most_common_types(limit=30) # import memdebug # memdebug.start(8002) +# from meliae import scanner +# scanner.dump_all_objects('objs.json') + + #debugger +# from IPython import embed +# sys.stdout = sys._stdout +# embed() locals().clear() +# dump = False while True: sleep(2) if self.do_restart: @@ -467,6 +475,15 @@ class Core(object): self.threadManager.work() self.scheduler.work() +# if not dump: +# sleep(10) +# print "dump objs" +# from meliae import scanner +# scanner.dump_all_objects(join(pypath, "objs.json")) +# dump = True + + import locale + def setupDB(self): self.db = DatabaseBackend(self) # the backend self.db.setup() -- cgit v1.2.3 From c9a359b75905d4910e42127cef8cbe62d4a13657 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 20 Dec 2011 21:35:43 +0100 Subject: some bugfixes --- pyLoadCore.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 7efab1061..3bf742310 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -25,7 +25,6 @@ CURRENT_VERSION = '0.4.9.9-dev' import __builtin__ from getopt import getopt, GetoptError -import module.common.pylgettext as gettext from imp import find_module import logging import logging.handlers @@ -33,12 +32,17 @@ import os from os import _exit, execl, getcwd, makedirs, remove, sep, walk, chdir, close from os.path import exists, join import signal -import subprocess import sys from sys import argv, executable, exit from time import time, sleep from traceback import print_exc +import locale +locale.locale_alias = locale.windows_locale = {} #save ~100kb ram, no known sideeffects for now + +import subprocess +subprocess.__doc__ = None # the module with the largest doc we are using + from module import InitHomeDir from module.plugins.AccountManager import AccountManager from module.interaction.CaptchaManager import CaptchaManager @@ -53,6 +57,7 @@ from module import remote from module.remote.RemoteManager import RemoteManager from module.database import DatabaseBackend, FileHandler +import module.common.pylgettext as gettext from module.utils import freeSpace, formatSize, get_console_encoding from codecs import getwriter @@ -460,7 +465,6 @@ class Core(object): locals().clear() -# dump = False while True: sleep(2) if self.do_restart: @@ -475,15 +479,6 @@ class Core(object): self.threadManager.work() self.scheduler.work() -# if not dump: -# sleep(10) -# print "dump objs" -# from meliae import scanner -# scanner.dump_all_objects(join(pypath, "objs.json")) -# dump = True - - import locale - def setupDB(self): self.db = DatabaseBackend(self) # the backend self.db.setup() @@ -622,7 +617,6 @@ class Core(object): def path(self, *args): return join(pypath, *args) - def deamon(): try: pid = os.fork() -- cgit v1.2.3 From 958bf611f5d9d117f19f824990ec6fd6b537e967 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 22 Dec 2011 23:45:38 +0100 Subject: accountmanager v2, delete your accounts.conf and re-enter them in pyload, new nice debug functions, try core.shell() and core.breakpoint() --- pyLoadCore.py | 83 +++++++++++++++++++---------------------------------------- 1 file changed, 27 insertions(+), 56 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 3bf742310..0651f1127 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -48,7 +48,7 @@ from module.plugins.AccountManager import AccountManager from module.interaction.CaptchaManager import CaptchaManager from module.config.ConfigParser import ConfigParser from module.plugins.PluginManager import PluginManager -from module.interaction.PullEvents import PullManager +from module.interaction.EventManager import EventManager from module.network.RequestFactory import RequestFactory from module.web.ServerThread import WebServer from module.Scheduler import Scheduler @@ -58,7 +58,7 @@ from module.remote.RemoteManager import RemoteManager from module.database import DatabaseBackend, FileHandler import module.common.pylgettext as gettext -from module.utils import freeSpace, formatSize, get_console_encoding +from module.utils import freeSpace, formatSize, get_console_encoding, fs_encode from codecs import getwriter @@ -79,6 +79,7 @@ class Core(object): self.running = False self.daemon = False self.remote = True + self.pdb = None self.arg_links = [] self.pidfile = "pyload.pid" self.deleteLinks = False # will delete links on startup @@ -334,8 +335,6 @@ class Core(object): except Exception, e: print _("Failed changing user: %s") % e - self.check_file(self.config['log']['log_folder'], _("folder for logs"), True) - if self.debug: self.init_logger(logging.DEBUG) # logging level else: @@ -356,15 +355,9 @@ class Core(object): self.log.debug("Remote activated: %s" % self.remote) self.check_install("Crypto", _("pycrypto to decode container files")) - #img = self.check_install("Image", _("Python Image Libary (PIL) for captcha reading")) - #self.check_install("pycurl", _("pycurl to download any files"), True, True) - self.check_file("tmp", _("folder for temporary files"), True) - #tesser = self.check_install("tesseract", _("tesseract for captcha reading"), False) if os.name != "nt" else True self.captcha = True # checks seems to fail, althoug tesseract is available - self.check_file(self.config['general']['download_folder'], _("folder for downloads"), True) - if self.config['ssl']['activated']: self.check_install("OpenSSL", _("OpenSSL for secure connection")) @@ -393,7 +386,7 @@ class Core(object): #hell yeah, so many important managers :D self.pluginManager = PluginManager(self) - self.pullManager = PullManager(self) + self.pullManager = EventManager(self) self.accountManager = AccountManager(self) self.threadManager = ThreadManager(self) self.captchaManager = CaptchaManager(self) @@ -410,7 +403,12 @@ class Core(object): if web: self.init_webserver() - spaceLeft = freeSpace(self.config["general"]["download_folder"]) + dl_folder = fs_encode(self.config["general"]["download_folder"]) + + if not exists(dl_folder): + makedirs(dl_folder) + + spaceLeft = freeSpace(dl_folder) self.log.info(_("Free space: %s") % formatSize(spaceLeft)) @@ -433,8 +431,7 @@ class Core(object): #self.scheduler.addJob(0, self.accountManager.getAccountInfos) self.log.info(_("Activating Accounts...")) - self.accountManager.getAccountInfos() - + self.accountManager.refreshAllAccounts() self.threadManager.pause = False self.running = True @@ -458,11 +455,6 @@ class Core(object): # from meliae import scanner # scanner.dump_all_objects('objs.json') - #debugger -# from IPython import embed -# sys.stdout = sys._stdout -# embed() - locals().clear() while True: @@ -497,6 +489,9 @@ class Core(object): console.setFormatter(frm) self.log = logging.getLogger("log") # settable in config + if not exists(self.config['log']['log_folder']): + makedirs(self.config['log']['log_folder'], 0600) + if self.config['log']['file_log']: if self.config['log']['log_rotate']: file_handler = logging.handlers.RotatingFileHandler(join(self.config['log']['log_folder'], 'log.txt'), @@ -534,43 +529,6 @@ class Core(object): return False - def check_file(self, check_names, description="", folder=False, empty=True, essential=False, quiet=False): - """check wether needed files exists""" - tmp_names = [] - if not type(check_names) == list: - tmp_names.append(check_names) - else: - tmp_names.extend(check_names) - file_created = True - file_exists = True - for tmp_name in tmp_names: - if not exists(tmp_name): - file_exists = False - if empty: - try: - if folder: - tmp_name = tmp_name.replace("/", sep) - makedirs(tmp_name) - else: - open(tmp_name, "w") - except: - file_created = False - else: - file_created = False - - if not file_exists and not quiet: - if file_created: - #self.log.info( _("%s created") % description ) - pass - else: - if not empty: - self.log.warning( - _("could not find %(desc)s: %(name)s") % {"desc": description, "name": tmp_name}) - else: - print _("could not create %(desc)s: %(name)s") % {"desc": description, "name": tmp_name} - if essential: - exit() - def isClientConnected(self): return (self.lastClientConnected + 30) > time() @@ -613,6 +571,19 @@ class Core(object): self.deletePidFile() + def shell(self): + """ stop and open a ipython shell inplace""" + if self.debug: + from IPython import embed + sys.stdout = sys._stdout + embed() + + def breakpoint(self): + if self.debug: + from IPython.core.debugger import Pdb + sys.stdout = sys._stdout + if not self.pdb: self.pdb = Pdb() + self.pdb.set_trace() def path(self, *args): return join(pypath, *args) -- cgit v1.2.3 From d35c003cc53d4723d1dfe0d81eeb9bea78cee594 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 31 Dec 2011 16:01:24 +0100 Subject: new crypter plugin API, now decrypting possible for now. --- pyLoadCore.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index b8856accf..b5b4add9e 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -29,8 +29,7 @@ from imp import find_module import logging import logging.handlers import os -from os import _exit, execl, getcwd, makedirs, remove, sep, walk, chdir, close -from os.path import exists, join +from os import _exit, execl, getcwd, remove, walk, chdir, close import signal import sys from sys import argv, executable, exit @@ -58,7 +57,8 @@ from module.remote.RemoteManager import RemoteManager from module.database import DatabaseBackend, FileHandler import module.common.pylgettext as gettext -from module.utils import freeSpace, formatSize, get_console_encoding, fs_encode +from module.utils import formatSize, get_console_encoding +from module.utils.fs import free_space, exists, makedirs, join from codecs import getwriter @@ -376,7 +376,7 @@ class Core(object): # later imported because they would trigger api import, and remote value not set correctly from module import Api from module.HookManager import HookManager - from module.ThreadManager import ThreadManager + from module.threads.ThreadManager import ThreadManager if Api.activated != self.remote: self.log.warning("Import error: API remote status not correct.") @@ -387,13 +387,15 @@ class Core(object): #hell yeah, so many important managers :D self.pluginManager = PluginManager(self) - self.pullManager = EventManager(self) + self.eventManager = EventManager(self) self.accountManager = AccountManager(self) self.threadManager = ThreadManager(self) self.captchaManager = CaptchaManager(self) self.hookManager = HookManager(self) self.remoteManager = RemoteManager(self) + self.files.ev = self.eventManager + self.js = JsEngine() self.log.info(_("Downloadtime: %s") % self.api.isTimeDownload()) @@ -404,12 +406,12 @@ class Core(object): if web: self.init_webserver() - dl_folder = fs_encode(self.config["general"]["download_folder"]) + dl_folder = self.config["general"]["download_folder"] if not exists(dl_folder): makedirs(dl_folder) - spaceLeft = freeSpace(dl_folder) + spaceLeft = free_space(dl_folder) self.log.info(_("Free space: %s") % formatSize(spaceLeft)) -- cgit v1.2.3 From 35742c2cb023ac49ab3056752d2040cdb030cc2b Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 1 Jan 2012 13:36:59 +0100 Subject: Happy new Year ! --- pyLoadCore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index b5b4add9e..d1a557c43 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -151,7 +151,7 @@ class Core(object): def print_help(self): print "" - print "pyLoad v%s 2008-2011 the pyLoad Team" % CURRENT_VERSION + print "pyLoad v%s 2008-2012 the pyLoad Team" % CURRENT_VERSION print "" if sys.argv[0].endswith(".py"): print "Usage: python pyLoadCore.py [options]" -- cgit v1.2.3 From 18466eb7f8f3cd4ca9a0824074d2ff454939fce6 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 4 Jan 2012 17:23:13 +0100 Subject: some fixes --- pyLoadCore.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index d1a557c43..f8b1ad6e8 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -362,6 +362,8 @@ class Core(object): if self.config['ssl']['activated']: self.check_install("OpenSSL", _("OpenSSL for secure connection")) + + self.eventManager = EventManager(self) self.setupDB() if self.deleteLinks: @@ -387,15 +389,13 @@ class Core(object): #hell yeah, so many important managers :D self.pluginManager = PluginManager(self) - self.eventManager = EventManager(self) + self.interActionManager = None #stub self.accountManager = AccountManager(self) self.threadManager = ThreadManager(self) self.captchaManager = CaptchaManager(self) self.hookManager = HookManager(self) self.remoteManager = RemoteManager(self) - self.files.ev = self.eventManager - self.js = JsEngine() self.log.info(_("Downloadtime: %s") % self.api.isTimeDownload()) -- cgit v1.2.3 From b877847094b0ba03a098dff0fd769eb456b48dd1 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 6 Jan 2012 17:54:53 +0100 Subject: several improvements, also closes #486, #487 --- pyLoadCore.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index f8b1ad6e8..54dc9ca39 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -439,9 +439,10 @@ class Core(object): self.running = True self.log.info(_("Activating Plugins...")) - self.hookManager.coreReady() + self.hookManager.activateHooks() self.log.info(_("pyLoad is up and running")) + self.eventManager.dispatchEvent("coreReady") #test api # from module.common.APIExerciser import startApiExerciser @@ -550,10 +551,13 @@ class Core(object): def shutdown(self): self.log.info(_("shutting down...")) + self.eventManager.dispatchEvent("coreShutdown") try: if self.config['webinterface']['activated'] and hasattr(self, "webserver"): self.webserver.quit() + + for thread in self.threadManager.threads: thread.put("quit") pyfiles = self.files.cache.values() @@ -561,7 +565,7 @@ class Core(object): for pyfile in pyfiles: pyfile.abortDownload() - self.hookManager.coreExiting() + self.hookManager.deactivateHooks() except: if self.debug: -- cgit v1.2.3 From 3c65474105713da5a2b7a77a9e20a5f9b7b3bc47 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 6 Jan 2012 20:47:16 +0100 Subject: closed #486 --- pyLoadCore.py | 1 - 1 file changed, 1 deletion(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 54dc9ca39..5e32219f8 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -438,7 +438,6 @@ class Core(object): self.threadManager.pause = False self.running = True - self.log.info(_("Activating Plugins...")) self.hookManager.activateHooks() self.log.info(_("pyLoad is up and running")) -- cgit v1.2.3 From 1ecdd9f6b53fec45e1d48592e3ff56aa7a576bec Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 8 Jan 2012 16:47:52 +0100 Subject: some cleanups, closed #490 --- pyLoadCore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 5e32219f8..233eda335 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -456,7 +456,7 @@ class Core(object): # import memdebug # memdebug.start(8002) # from meliae import scanner -# scanner.dump_all_objects('objs.json') +# scanner.dump_all_objects(self.path('objs.json')) locals().clear() -- cgit v1.2.3 From 26227cfe53f8fd4bc1631d8e1b35031f589682dc Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 15 Jan 2012 15:55:19 +0100 Subject: backend + api test case, nicer format for plugin tester --- pyLoadCore.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 233eda335..cfb2c38d0 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -62,7 +62,10 @@ from module.utils.fs import free_space, exists, makedirs, join from codecs import getwriter -enc = get_console_encoding(sys.stdout.encoding) +# test runner overwrites sys.stdout +if hasattr(sys.stdout, "encoding"): enc = get_console_encoding(sys.stdout.encoding) +else: enc = "utf8" + sys._stdout = sys.stdout sys.stdout = getwriter(enc)(sys.stdout, errors="replace") @@ -265,7 +268,7 @@ class Core(object): print join(path, f) remove(join(path, f)) - def start(self, rpc=True, web=True): + def start(self, rpc=True, web=True, tests=False): """ starts the fun :D """ self.version = CURRENT_VERSION @@ -398,6 +401,9 @@ class Core(object): self.js = JsEngine() + # enough initialization for test cases + if tests: return + self.log.info(_("Downloadtime: %s") % self.api.isTimeDownload()) if rpc: -- cgit v1.2.3 From 247ae6fbec98dbc42c3910df2942842ef5256715 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 15 Jan 2012 21:17:23 +0100 Subject: fix test cases --- pyLoadCore.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index cfb2c38d0..e79da3fc3 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -273,7 +273,7 @@ class Core(object): self.version = CURRENT_VERSION - if not exists("pyload.conf"): + if not exists("pyload.conf") and not tests: from module.setup import Setup print "This is your first start, running configuration assistent now." @@ -312,7 +312,8 @@ class Core(object): self.remote &= self.config['remote']['activated'] pid = self.isAlreadyRunning() - if pid: + # dont exit when in test runner + if pid and not tests: print _("pyLoad already running with pid %s") % pid exit() @@ -350,8 +351,9 @@ class Core(object): self.log.info(_("Starting") + " pyLoad %s" % CURRENT_VERSION) self.log.info(_("Using home directory: %s") % getcwd()) - - self.writePidFile() + + if not tests: + self.writePidFile() #@TODO refractor -- cgit v1.2.3 From dad87afe2f73d6f456e9cb00b0d8ce7f5cee0140 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 1 Feb 2012 22:11:55 +0100 Subject: fix for huge (or wrong) sizes --- pyLoadCore.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index e79da3fc3..45feac1c3 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -198,6 +198,7 @@ class Core(object): f = open(self.pidfile, "wb") f.write(str(pid)) f.close() + chmod(self.pidfile, 0660) def deletePidFile(self): if self.checkPidFile(): -- cgit v1.2.3 From 51ed320a52d01afd1ae852f15f3ccd84db754e0e Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 3 Feb 2012 21:31:01 +0100 Subject: missing import --- pyLoadCore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 45feac1c3..7822fbf54 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -58,7 +58,7 @@ from module.database import DatabaseBackend, FileHandler import module.common.pylgettext as gettext from module.utils import formatSize, get_console_encoding -from module.utils.fs import free_space, exists, makedirs, join +from module.utils.fs import free_space, exists, makedirs, join, chmod from codecs import getwriter -- cgit v1.2.3 From d7eef2c28eae2e43e3ade4441810ecc0cdea6fd7 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 5 Feb 2012 21:21:36 +0100 Subject: option for internal plugins --- pyLoadCore.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 7822fbf54..587dd3cc0 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -72,6 +72,13 @@ sys.stdout = getwriter(enc)(sys.stdout, errors="replace") # TODO List # - configurable auth system ldap/mysql # - cron job like sheduler +# - plugin stack / multi decrypter +# - media plugin type +# - general progress info +# - content attribute for files / sync status +# - sync with disk content / file manager / nested packages +# - would require new/modified link collector concept +# - interaction manager class Core(object): """pyLoad Core, one tool to rule them all... (the filehosters) :D""" @@ -600,6 +607,10 @@ class Core(object): if not self.pdb: self.pdb = Pdb() self.pdb.set_trace() + def print_exc(self): + if self.debug: + print_exc() + def path(self, *args): return join(pypath, *args) -- cgit v1.2.3 From 4df2b77fdf42046fe19bd371be7c7255986b5980 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 6 Mar 2012 13:36:39 +0100 Subject: renamed hooks to addons, new filemanager and database, many new api methods you will loose ALL your LINKS, webinterface will NOT work --- pyLoadCore.py | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 587dd3cc0..c0d636653 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -44,7 +44,6 @@ subprocess.__doc__ = None # the module with the largest doc we are using from module import InitHomeDir from module.plugins.AccountManager import AccountManager -from module.interaction.CaptchaManager import CaptchaManager from module.config.ConfigParser import ConfigParser from module.plugins.PluginManager import PluginManager from module.interaction.EventManager import EventManager @@ -54,7 +53,6 @@ from module.Scheduler import Scheduler from module.common.JsEngine import JsEngine from module import remote from module.remote.RemoteManager import RemoteManager -from module.database import DatabaseBackend, FileHandler import module.common.pylgettext as gettext from module.utils import formatSize, get_console_encoding @@ -77,8 +75,14 @@ sys.stdout = getwriter(enc)(sys.stdout, errors="replace") # - general progress info # - content attribute for files / sync status # - sync with disk content / file manager / nested packages +# - sync between pyload cores +# - new attributes (date|sync status) +# - embedded packages # - would require new/modified link collector concept +# - pausable links/packages +# - toggable accounts # - interaction manager +# - improve external scripts class Core(object): """pyLoad Core, one tool to rule them all... (the filehosters) :D""" @@ -320,7 +324,7 @@ class Core(object): self.remote &= self.config['remote']['activated'] pid = self.isAlreadyRunning() - # dont exit when in test runner + # dont exit when in test runner if pid and not tests: print _("pyLoad already running with pid %s") % pid exit() @@ -360,7 +364,7 @@ class Core(object): self.log.info(_("Starting") + " pyLoad %s" % CURRENT_VERSION) self.log.info(_("Using home directory: %s") % getcwd()) - if not tests: + if not tests: self.writePidFile() #@TODO refractor @@ -386,11 +390,10 @@ class Core(object): self.requestFactory = RequestFactory(self) __builtin__.pyreq = self.requestFactory - self.lastClientConnected = 0 - # later imported because they would trigger api import, and remote value not set correctly from module import Api - from module.HookManager import HookManager + from module.AddonManager import AddonManager + from module.interaction.InteractionManager import InteractionManager from module.threads.ThreadManager import ThreadManager if Api.activated != self.remote: @@ -402,11 +405,10 @@ class Core(object): #hell yeah, so many important managers :D self.pluginManager = PluginManager(self) - self.interActionManager = None #stub + self.interactionManager = InteractionManager(self) self.accountManager = AccountManager(self) self.threadManager = ThreadManager(self) - self.captchaManager = CaptchaManager(self) - self.hookManager = HookManager(self) + self.addonManager = AddonManager(self) self.remoteManager = RemoteManager(self) self.js = JsEngine() @@ -454,7 +456,7 @@ class Core(object): self.threadManager.pause = False self.running = True - self.hookManager.activateHooks() + self.addonManager.activateAddons() self.log.info(_("pyLoad is up and running")) self.eventManager.dispatchEvent("coreReady") @@ -491,10 +493,13 @@ class Core(object): self.scheduler.work() def setupDB(self): + from module.database import DatabaseBackend + from module.FileManager import FileManager + self.db = DatabaseBackend(self) # the backend self.db.setup() - self.files = FileHandler(self) + self.files = FileManager(self) self.db.manager = self.files #ugly? def init_webserver(self): @@ -548,9 +553,6 @@ class Core(object): return False - def isClientConnected(self): - return (self.lastClientConnected + 30) > time() - def restart(self): self.shutdown() chdir(owd) @@ -571,16 +573,11 @@ class Core(object): if self.config['webinterface']['activated'] and hasattr(self, "webserver"): self.webserver.quit() - - for thread in self.threadManager.threads: thread.put("quit") - pyfiles = self.files.cache.values() - - for pyfile in pyfiles: - pyfile.abortDownload() - self.hookManager.deactivateHooks() + self.api.stopAllDownloads() + self.addonManager.deactivateAddons() except: if self.debug: -- cgit v1.2.3 From 50d4df8b4d48b855bd18e9922355b7f3f2b4da4e Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 20 Mar 2012 14:57:45 +0100 Subject: captcha decrypting for all plugin types, new interaction manager --- pyLoadCore.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index c0d636653..b129e2cb7 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -479,7 +479,7 @@ class Core(object): locals().clear() while True: - sleep(2) + sleep(1.5) if self.do_restart: self.log.info(_("restarting pyLoad")) self.restart() @@ -490,6 +490,7 @@ class Core(object): _exit(0) #@TODO thrift blocks shutdown self.threadManager.work() + self.interactionManager.work() self.scheduler.work() def setupDB(self): @@ -580,8 +581,7 @@ class Core(object): self.addonManager.deactivateAddons() except: - if self.debug: - print_exc() + self.print_exc() self.log.info(_("error while shutting down")) finally: -- cgit v1.2.3 From ed131ce9fba4b374586885999029d1743e9feefd Mon Sep 17 00:00:00 2001 From: X3n0m0rph59 Date: Sun, 22 Apr 2012 17:18:52 +0200 Subject: Fixed spelling in the source --- pyLoadCore.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index b129e2cb7..25b4c51c0 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -178,15 +178,15 @@ class Core(object): #print " -a, --add=", " " * 2, "Add the specified links" print " -u, --user", " " * 13, "Manages users" print " -d, --debug", " " * 12, "Enable debug mode" - print " -s, --setup", " " * 12, "Run Setup Assistent" - print " --configdir=", " " * 6, "Run with as config directory" + print " -s, --setup", " " * 12, "Run setup assistant" + print " --configdir=", " " * 6, "Run with as configuration directory" print " -p, --pidfile=", " " * 3, "Set pidfile to " - print " --changedir", " " * 12, "Change config dir permanently" - print " --daemon", " " * 15, "Daemonmize after start" + print " --changedir", " " * 12, "Change configuration directory permanently" + print " --daemon", " " * 15, "Daemonize after startup" print " --no-remote", " " * 12, "Disable remote access (saves RAM)" print " --status", " " * 15, "Display pid if running or False" print " --clean", " " * 16, "Remove .pyc/.pyo files" - print " -q, --quit", " " * 13, "Quit running pyLoad instance" + print " -q, --quit", " " * 13, "Quit a running pyLoad instance" print " -h, --help", " " * 13, "Display this help screen" print "" @@ -288,7 +288,7 @@ class Core(object): if not exists("pyload.conf") and not tests: from module.setup import Setup - print "This is your first start, running configuration assistent now." + print "This is your first start, running configuration assistant now." self.config = ConfigParser() s = Setup(pypath, self.config) res = False @@ -374,7 +374,7 @@ class Core(object): self.check_install("Crypto", _("pycrypto to decode container files")) - self.captcha = True # checks seems to fail, althoug tesseract is available + self.captcha = True # checks seems to fail, although tesseract is available if self.config['ssl']['activated']: self.check_install("OpenSSL", _("OpenSSL for secure connection")) @@ -416,7 +416,7 @@ class Core(object): # enough initialization for test cases if tests: return - self.log.info(_("Downloadtime: %s") % self.api.isTimeDownload()) + self.log.info(_("Download time: %s") % self.api.isTimeDownload()) if rpc: self.remoteManager.startBackends() @@ -512,7 +512,7 @@ class Core(object): console = logging.StreamHandler(sys.stdout) frm = logging.Formatter("%(asctime)s %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S") console.setFormatter(frm) - self.log = logging.getLogger("log") # settable in config + self.log = logging.getLogger("log") # setable in config if not exists(self.config['log']['log_folder']): makedirs(self.config['log']['log_folder'], 0600) @@ -538,7 +538,7 @@ class Core(object): h.close() def check_install(self, check_name, legend, python=True, essential=False): - """check wether needed tools are installed""" + """check whether needed tools are installed""" try: if python: find_module(check_name) @@ -591,7 +591,7 @@ class Core(object): self.deletePidFile() def shell(self): - """ stop and open a ipython shell inplace""" + """ stop and open an ipython shell inplace""" if self.debug: from IPython import embed sys.stdout = sys._stdout @@ -662,7 +662,7 @@ def main(): pyload_core.start() except KeyboardInterrupt: pyload_core.shutdown() - pyload_core.log.info(_("killed pyLoad from Terminal")) + pyload_core.log.info(_("killed pyLoad from terminal")) pyload_core.removeLogger() _exit(1) -- cgit v1.2.3 From 829244a6140763712d50ed046c33f415f2b04301 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 15 May 2012 19:22:34 +0200 Subject: some multiuser db changes --- pyLoadCore.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index 25b4c51c0..ac9fb0133 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -1,18 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . + Copyright(c) 2008-2012 pyLoad Team + http://www.pyload.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + Subjected to the terms and conditions in LICENSE @author: spoob @author: sebnapi -- cgit v1.2.3 From 0d2d6daef850ac6bcc7fafccd230e52d2a862c2c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 3 Jun 2012 17:45:10 +0200 Subject: updates for database + api --- pyLoadCore.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index ac9fb0133..ce87a4c62 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -40,9 +40,9 @@ import subprocess subprocess.__doc__ = None # the module with the largest doc we are using from module import InitHomeDir -from module.plugins.AccountManager import AccountManager +from module.AccountManager import AccountManager from module.config.ConfigParser import ConfigParser -from module.plugins.PluginManager import PluginManager +from module.PluginManager import PluginManager from module.interaction.EventManager import EventManager from module.network.RequestFactory import RequestFactory from module.web.ServerThread import WebServer @@ -321,7 +321,7 @@ class Core(object): self.remote &= self.config['remote']['activated'] pid = self.isAlreadyRunning() - # dont exit when in test runner + # don't exit when in test runner if pid and not tests: print _("pyLoad already running with pid %s") % pid exit() -- cgit v1.2.3 From e0b2c5b8436835254534911d8454ecc1b89c34c2 Mon Sep 17 00:00:00 2001 From: Thammi Date: Mon, 4 Jun 2012 18:55:15 +0200 Subject: Fix permissions for log directory --- pyLoadCore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index ce87a4c62..b69b919d3 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -512,7 +512,7 @@ class Core(object): self.log = logging.getLogger("log") # setable in config if not exists(self.config['log']['log_folder']): - makedirs(self.config['log']['log_folder'], 0600) + makedirs(self.config['log']['log_folder'], 0700) if self.config['log']['file_log']: if self.config['log']['log_rotate']: -- cgit v1.2.3 From 176095687f437632cf33484a4dc38e2a51f5cb6f Mon Sep 17 00:00:00 2001 From: Trigger Hurt Date: Fri, 27 Jul 2012 17:20:57 +0200 Subject: adds "restart failed on startup" option --- pyLoadCore.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index b69b919d3..ac7c785ca 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -450,6 +450,12 @@ class Core(object): #self.scheduler.addJob(0, self.accountManager.getAccountInfos) self.log.info(_("Activating Accounts...")) self.accountManager.refreshAllAccounts() + + #restart failed + if self.config["download"]["restart_failed"]: + self.log.info(_("Restarting failed downloads...")) + self.api.restartFailed() + self.threadManager.pause = False self.running = True -- cgit v1.2.3 From ce9c4cf50b98dfc6cef967d9451918554fbee413 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 8 Aug 2012 20:43:43 +0200 Subject: layout draft --- pyLoadCore.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index ac7c785ca..e3a90575b 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -80,6 +80,7 @@ sys.stdout = getwriter(enc)(sys.stdout, errors="replace") # - toggable accounts # - interaction manager # - improve external scripts +# - make pyload undestructable to fail plugins -> see ConfigParser first class Core(object): """pyLoad Core, one tool to rule them all... (the filehosters) :D""" -- cgit v1.2.3 From 941e3021000e59020f66419cc2156aee30972121 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 13 Aug 2012 17:40:10 +0200 Subject: working login --- pyLoadCore.py | 1 - 1 file changed, 1 deletion(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index e3a90575b..99c01dbf7 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -87,7 +87,6 @@ class Core(object): def __init__(self): self.doDebug = False - self.startedInGui = False self.running = False self.daemon = False self.remote = True -- cgit v1.2.3