diff options
-rw-r--r-- | .hgignore | 1 | ||||
-rw-r--r-- | module/web/ServerThread.py | 10 | ||||
-rw-r--r-- | module/web/ServerThread.py.orig | 27 | ||||
-rw-r--r-- | module/web/pyload_default.db (renamed from module/web/pyload.db) | bin | 44032 -> 44032 bytes | |||
-rwxr-xr-x | pyLoadCore.py | 18 |
5 files changed, 21 insertions, 35 deletions
@@ -19,3 +19,4 @@ module/cookies.txt ssl.crt ssl.key cert.pem +module/web/pyload.db diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index cebf0ce2f..2ac39c2c8 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,9 +1,11 @@ #!/usr/bin/env python +from __future__ import with_statement import threading from os.path import join from subprocess import Popen, PIPE, STDOUT from time import sleep from signal import SIGINT +import os class WebServer(threading.Thread): def __init__(self, pycore): @@ -16,13 +18,15 @@ class WebServer(threading.Thread): host = self.pycore.config['webinterface']['host'] port = self.pycore.config['webinterface']['port'] self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) ) - self.p = Popen(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True, stderr=PIPE, stdin=PIPE, stdout=PIPE, shell=False) + self.p = Popen(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True, stderr=PIPE, stdin=PIPE, stdout=PIPE) #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port))) #@TODO: better would be real python code + sleep(1) + with open("webserver.pid", "r") as f: + self.pid = int(f.read().strip()) while self.running: sleep(1) def quit(self): - self.p.terminate() + os.kill(self.pid, SIGINT) self.running = False - diff --git a/module/web/ServerThread.py.orig b/module/web/ServerThread.py.orig deleted file mode 100644 index d092f9348..000000000 --- a/module/web/ServerThread.py.orig +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python
-import threading
-from os.path import join
-from subprocess import Popen, PIPE, STDOUT
-from time import sleep
-from signal import SIGINT
-
-class WebServer(threading.Thread):
- def __init__(self, pycore):
- threading.Thread.__init__(self)
- self.pycore = pycore
- self.running = True
- self.setDaemon(True)
-
- def run(self):
- host = self.pycore.config['webinterface']['host']
- port = self.pycore.config['webinterface']['port']
- self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) )
- self.p = Popen(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True, stderr=PIPE, stdin=PIPE, stdout=PIPE, shell=False)
- #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port)))
- #@TODO: better would be real python code
- while self.running:
- sleep(1)
-
- def quit(self):
- self.p.terminate()
- self.running = False
diff --git a/module/web/pyload.db b/module/web/pyload_default.db Binary files differindex e5e224850..cd39d0ca8 100644 --- a/module/web/pyload.db +++ b/module/web/pyload_default.db diff --git a/pyLoadCore.py b/pyLoadCore.py index 2a9cbbc59..eb43ce840 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -43,7 +43,8 @@ from sys import path from sys import stdout
import thread
import time
-from time import sleep
+from time import sleep +from shutil import copyfile
from module.file_list import File_List
from module.network.Request import Request
@@ -185,7 +186,11 @@ class Core(object): traceback.print_exc()
- def init_webserver(self):
+ def init_webserver(self): + pyloadDBFile = join(self.path, "module", "web", "pyload.db") + pyloadDefaultDBFile = join(self.path, "module", "web", "pyload_default.db") + if not exists(pyloadDBFile): + copyfile(pyloadDefaultDBFile, pyloadDBFile)
if self.config['webinterface']['activated']:
self.webserver = WebServer(self)
self.webserver.start()
@@ -372,7 +377,8 @@ class ServerMethods(): if self.core.thread_list.pause:
self.core.thread_list.pause = False
else:
- self.core.thread_list.pause = True
+ self.core.thread_list.pause = True + return self.core.thread_list.pause
def status_server(self):
status = {}
@@ -394,8 +400,10 @@ class ServerMethods(): return CURRENT_VERSION
def add_urls(self, links):
- for link in links:
- self.core.file_list.collector.addLink(link)
+ for link in links: + link = link.strip() + if link.startswith("http") or exists(link):
+ self.core.file_list.collector.addLink(link)
self.core.file_list.save()
def add_package(self, name, links):
|