From 95d09b338ac7aed2b387bf143a5cfd1c4b29f612 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 15 Dec 2009 17:48:30 +0100 Subject: new Django webinterface(in development), small fixes --- module/web/ServerThread.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 module/web/ServerThread.py (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py new file mode 100644 index 000000000..803dc5dc5 --- /dev/null +++ b/module/web/ServerThread.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import threading +import os +from os.path import join + +class WebServer(threading.Thread): + def __init__(self, pycore): + threading.Thread.__init__(self) + self.pycore = pycore + self.setDaemon(True) + + def run(self): + self.pycore.logger.info("Starting Webserver @ Port 8000") + os.system("python " + join(self.pycore.path,"module","web","manage.py runserver")) + #@TODO: really bad approach, better would be real python code, or subprocess \ No newline at end of file -- cgit v1.2.3 From 511ae48877f8f3fae2a3ba282d979c33f2ea5491 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 17 Dec 2009 16:14:26 +0100 Subject: webinterface: config working, downloadable files --- module/web/ServerThread.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 803dc5dc5..790ac152b 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -2,6 +2,7 @@ import threading import os from os.path import join +import subprocess class WebServer(threading.Thread): def __init__(self, pycore): @@ -10,6 +11,12 @@ class WebServer(threading.Thread): self.setDaemon(True) def run(self): - self.pycore.logger.info("Starting Webserver @ Port 8000") - os.system("python " + join(self.pycore.path,"module","web","manage.py runserver")) - #@TODO: really bad approach, better would be real python code, or subprocess \ No newline at end of file + host = self.pycore.config['webinterface']['host'] + port = self.pycore.config['webinterface']['port'] + self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) ) + try: + subprocess.call(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True) + except Exception, e: + print e + #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port))) + #@TODO: better would be real python code \ No newline at end of file -- cgit v1.2.3 From 1d7dc2ca5db0119e01547cd7b01fb77720450d1c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 19 Dec 2009 00:26:38 +0100 Subject: cleaned --- module/web/ServerThread.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 790ac152b..6113ac297 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,6 +1,5 @@ #!/usr/bin/env python import threading -import os from os.path import join import subprocess @@ -19,4 +18,4 @@ class WebServer(threading.Thread): except Exception, e: print e #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port))) - #@TODO: better would be real python code \ No newline at end of file + #@TODO: better would be real python code -- cgit v1.2.3 From c003c8a342cbe9609f8e6b21669a8b4a90a213bf Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 20 Dec 2009 20:54:30 +0100 Subject: fixed file_list again, webserver terminates correctly when killing pyload over xmlrpc --- module/web/ServerThread.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 6113ac297..2279296d8 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,21 +1,27 @@ #!/usr/bin/env python import threading from os.path import join -import subprocess +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) ) - try: - subprocess.call(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True) - except Exception, e: - print e + 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=True) #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 -- cgit v1.2.3 From 77ebea73401f00f9150299317bdddaa24beddd2a Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 20 Dec 2009 23:22:46 +0100 Subject: file_list fix, webinterface termination fix AGAIN -.-' --- module/web/ServerThread.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 2279296d8..d9f0f8cdc 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -4,6 +4,7 @@ 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,12 +17,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=True) + 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 -- cgit v1.2.3 From b22eaf5d8b1e472eaaebb176234843f38d97e102 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 20 Dec 2009 23:30:43 +0100 Subject: python 2.5 compatibility --- module/web/ServerThread.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index d9f0f8cdc..2ac39c2c8 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import with_statement import threading from os.path import join from subprocess import Popen, PIPE, STDOUT -- cgit v1.2.3 From 7dd0c96037b0f91f761126d20e477e0e83e20825 Mon Sep 17 00:00:00 2001 From: Wugy Date: Mon, 21 Dec 2009 18:15:56 +0100 Subject: total progressbar bullshit --- module/web/ServerThread.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 2ac39c2c8..cebf0ce2f 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,11 +1,9 @@ #!/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): @@ -18,15 +16,13 @@ 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) + 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 - sleep(1) - with open("webserver.pid", "r") as f: - self.pid = int(f.read().strip()) while self.running: sleep(1) def quit(self): - os.kill(self.pid, SIGINT) + self.p.terminate() self.running = False + -- cgit v1.2.3 From 63d4273065f475719e63e5785abdbf11be43dae3 Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 21 Dec 2009 19:19:28 +0100 Subject: reverted files, pyload.db fix --- module/web/ServerThread.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'module/web/ServerThread.py') 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 - -- cgit v1.2.3 From f6af404831d166412f2aa507636ed2825e0e4c0d Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 21 Dec 2009 23:03:12 +0100 Subject: webserver for win --- module/web/ServerThread.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 2ac39c2c8..0d6044562 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -17,16 +17,27 @@ class WebServer(threading.Thread): def run(self): host = self.pycore.config['webinterface']['host'] port = self.pycore.config['webinterface']['port'] + command = ['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,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) - #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: + + if os.name == 'posix': + self.p = Popen(command, 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) + else: + self.p = Popen(command, stderr=PIPE, stdin=PIPE, stdout=PIPE) + while self.running: + sleep(1) def quit(self): - os.kill(self.pid, SIGINT) + if os.name == 'posix': + os.kill(self.pid, SIGINT) + else: + self.p.kill() + self.running = False -- cgit v1.2.3 From 5c7e9f0f1325523347a52869cebbf03463550bca Mon Sep 17 00:00:00 2001 From: mkaay Date: Thu, 24 Dec 2009 01:41:13 +0100 Subject: clean shutdown --- module/web/ServerThread.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 0d6044562..069cabafe 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -36,7 +36,10 @@ class WebServer(threading.Thread): def quit(self): if os.name == 'posix': - os.kill(self.pid, SIGINT) + try: + os.kill(self.pid, SIGINT) + except: + pass else: self.p.kill() -- cgit v1.2.3 From d56dcab5d48c8c4ec05f200f92bd35a1f977cd4f Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 6 Jan 2010 17:38:53 +0100 Subject: cli fix, webinterface db check --- module/web/ServerThread.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 069cabafe..8be3892b5 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -2,6 +2,7 @@ from __future__ import with_statement import threading from os.path import join +from os.path import exists from subprocess import Popen, PIPE, STDOUT from time import sleep from signal import SIGINT @@ -18,6 +19,16 @@ class WebServer(threading.Thread): host = self.pycore.config['webinterface']['host'] port = self.pycore.config['webinterface']['port'] command = ['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)] + + if not exists(join(self.pycore.path,"module","web","pyload.db")): + print "########## IMPORTANT ###########" + print "### Database for Webinterface doesnt exitst, it will not be available." + print "### Please run: python %s syncdb" % join(self.pycore.path,"module","web","manage.py") + print "### You have to add at least one User, to gain access to webinterface: python %s createsuperuser" % join(self.pycore.path,"module","web","manage.py") + print "### Dont forget to restart pyLoad if you are done." + print "################################" + raise Exception, "Database doesnt exists, please use syncdb" + self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) ) if os.name == 'posix': -- cgit v1.2.3 From 3d655ddbfbd96abecb9a9c9bebf6e43eb710ab12 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 10 Jan 2010 16:20:31 +0100 Subject: fixed manage.py, addBox working, some code formatted and cleaned --- module/web/ServerThread.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/web/ServerThread.py') diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 8be3892b5..1276966ef 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -18,7 +18,6 @@ class WebServer(threading.Thread): def run(self): host = self.pycore.config['webinterface']['host'] port = self.pycore.config['webinterface']['port'] - command = ['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)] if not exists(join(self.pycore.path,"module","web","pyload.db")): print "########## IMPORTANT ###########" @@ -32,6 +31,7 @@ class WebServer(threading.Thread): self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) ) if os.name == 'posix': + command = ['python',join(self.pycore.path,"module","web","run_unix.py"), "runserver", "%s:%s" % (host,port)] self.p = Popen(command, 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 @@ -41,6 +41,7 @@ class WebServer(threading.Thread): while self.running: sleep(1) else: + command = ['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)] self.p = Popen(command, stderr=PIPE, stdin=PIPE, stdout=PIPE) while self.running: sleep(1) -- cgit v1.2.3