summaryrefslogtreecommitdiffstats
path: root/pyload/Core.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 17:20:59 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-13 17:20:59 +0200
commite00ef98491f79ae8aa972ae1473dae4a7b78c07e (patch)
tree31be0c7cdcebb61525bcc387bcf15d265a1c494a /pyload/Core.py
parentFix except (diff)
downloadpyload-e00ef98491f79ae8aa972ae1473dae4a7b78c07e.tar.xz
Cleanup
Diffstat (limited to 'pyload/Core.py')
-rwxr-xr-xpyload/Core.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/pyload/Core.py b/pyload/Core.py
index d3e23309a..c79c832e1 100755
--- a/pyload/Core.py
+++ b/pyload/Core.py
@@ -48,6 +48,7 @@ sys.stdout = getwriter(enc)(sys.stdout, errors="replace")
class Core(object):
"""pyLoad Core, one tool to rule them all... (the filehosters) :D"""
+
def __init__(self):
self.doDebug = False
self.running = False
@@ -122,6 +123,7 @@ class Core(object):
self.print_help()
exit()
+
def print_help(self):
print
print "pyLoad v%s 2008-2015 the pyLoad Team" % CURRENT_VERSION
@@ -149,6 +151,7 @@ class Core(object):
print " -h, --help", " " * 13, "Display this help screen"
print
+
def toggle_pause(self):
if self.threadManager.pause:
self.threadManager.pause = False
@@ -157,11 +160,13 @@ class Core(object):
self.threadManager.pause = True
return True
+
def quit(self, a, b):
self.shutdown()
self.log.info(_("Received Quit signal"))
_exit(1)
+
def writePidFile(self):
self.deletePidFile()
pid = os.getpid()
@@ -169,11 +174,13 @@ class Core(object):
f.write(str(pid))
f.close()
+
def deletePidFile(self):
if self.checkPidFile():
self.log.debug("Deleting old pidfile %s" % self.pidfile)
os.remove(self.pidfile)
+
def checkPidFile(self):
""" return pid as int or 0"""
if os.path.isfile(self.pidfile):
@@ -186,6 +193,7 @@ class Core(object):
return 0
+
def isAlreadyRunning(self):
pid = self.checkPidFile()
if not pid or os.name == "nt": return False
@@ -196,6 +204,7 @@ class Core(object):
return pid
+
def quitInstance(self):
if os.name == "nt":
print "Not supported on windows."
@@ -238,6 +247,7 @@ class Core(object):
print join(path, f)
remove(join(path, f))
+
def start(self, rpc=True, web=True):
""" starts the fun :D """
@@ -436,6 +446,7 @@ class Core(object):
self.threadManager.work()
self.scheduler.work()
+
def setupDB(self):
self.db = DatabaseBackend(self) # the backend
self.db.setup()
@@ -443,11 +454,13 @@ class Core(object):
self.files = FileHandler(self)
self.db.manager = self.files #ugly?
+
def init_webserver(self):
if self.config['webui']['activated']:
self.webserver = WebServer(self)
self.webserver.start()
+
def init_logger(self, level):
console = logging.StreamHandler(sys.stdout)
frm = logging.Formatter("%(asctime)s %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S")
@@ -469,11 +482,13 @@ class Core(object):
self.log.addHandler(console) #if console logging
self.log.setLevel(level)
+
def removeLogger(self):
for h in list(self.log.handlers):
self.log.removeHandler(h)
h.close()
+
def check_install(self, check_name, legend, python=True, essential=False):
"""check wether needed tools are installed"""
try:
@@ -491,6 +506,7 @@ 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 = []
@@ -528,9 +544,11 @@ class Core(object):
if essential:
exit()
+
def isClientConnected(self):
return (self.lastClientConnected + 30) > time()
+
def restart(self):
self.shutdown()
chdir(owd)
@@ -544,6 +562,7 @@ class Core(object):
execl(executable, executable, *sys.argv)
_exit(0)
+
def shutdown(self):
self.log.info(_("shutting down..."))
try: