summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-15 16:51:28 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-08-15 16:51:28 +0200
commit975bcfe972f18026ac6c1e74711fa50a72295490 (patch)
tree9c178c3db1310a1d4341d8be309cc71a57392a76
parentsome fixes, fixed #125 (diff)
downloadpyload-975bcfe972f18026ac6c1e74711fa50a72295490.tar.xz
permanent config dir change possible
-rw-r--r--module/InitHomeDir.py11
-rwxr-xr-xmodule/web/run_server.py118
2 files changed, 67 insertions, 62 deletions
diff --git a/module/InitHomeDir.py b/module/InitHomeDir.py
index d7f98180a..7db0e7cbc 100644
--- a/module/InitHomeDir.py
+++ b/module/InitHomeDir.py
@@ -20,7 +20,7 @@
"""
-from os import mkdir
+from os import makedirs
from os import path
from os import chdir
from sys import platform
@@ -56,7 +56,12 @@ args = " ".join(argv[1:])
# dirty method to set configdir from commandline arguments
-if "--configdir=" in args:
+if path.exists(path.join(pypath, "module", "config", "configdir")):
+ f = open(path.join(pypath, "module", "config", "configdir"), "rb")
+ c = f.read().strip()
+ configdir = c
+
+elif "--configdir=" in args:
pos = args.find("--configdir=")
end = args.find("-", pos+12)
@@ -71,7 +76,7 @@ else:
configdir = path.join(homedir, "pyload")
if not path.exists(configdir):
- mkdir(configdir, 0700)
+ makedirs(configdir, 0700)
__builtin__.configdir = configdir
chdir(configdir)
diff --git a/module/web/run_server.py b/module/web/run_server.py
index 9957276ad..34fca46c8 100755
--- a/module/web/run_server.py
+++ b/module/web/run_server.py
@@ -9,81 +9,81 @@ from django.core.handlers.wsgi import WSGIHandler
os.environ["DJANGO_SETTINGS_MODULE"] = 'settings'
class Output:
- def __init__(self, stream):
- self.stream = stream
- def write(self, data): # Do nothing
- return None
- #self.stream.write(data)
- #self.stream.flush()
- def __getattr__(self, attr):
- return getattr(self.stream, attr)
+ def __init__(self, stream):
+ self.stream = stream
+ def write(self, data): # Do nothing
+ return None
+ #self.stream.write(data)
+ #self.stream.flush()
+ def __getattr__(self, attr):
+ return getattr(self.stream, attr)
#sys.stderr = Output(sys.stderr)
#sys.stdout = Output(sys.stdout)
def handle(* args):
- try:
- if len(args) == 1:
- try:
- addr, port = args[0].split(":")
- except:
- addr = "127.0.0.1"
- port = args[0]
- else:
- addr = args[0]
- port = args[1]
- except:
- addr = '127.0.0.1'
- port = '8000'
+ try:
+ if len(args) == 1:
+ try:
+ addr, port = args[0].split(":")
+ except:
+ addr = "127.0.0.1"
+ port = args[0]
+ else:
+ addr = args[0]
+ port = args[1]
+ except:
+ addr = '127.0.0.1'
+ port = '8000'
- #print addr, port
+ #print addr, port
- admin_media_path = ''
- shutdown_message = ''
- quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
+ admin_media_path = ''
+ shutdown_message = ''
+ quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
- from django.conf import settings
- from django.utils import translation
+ from django.conf import settings
+ from django.utils import translation
- #print "Django version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
- #print "Development server is running at http://%s:%s/" % (addr, port)
- #print "Quit the server with %s." % quit_command
+ #print "Django version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
+ #print "Development server is running at http://%s:%s/" % (addr, port)
+ #print "Quit the server with %s." % quit_command
- translation.activate(settings.LANGUAGE_CODE)
+ translation.activate(settings.LANGUAGE_CODE)
- try:
- handler = AdminMediaHandler(WSGIHandler(), admin_media_path)
- run(addr, int(port), handler)
+ try:
+ handler = AdminMediaHandler(WSGIHandler(), admin_media_path)
+ run(addr, int(port), handler)
- except WSGIServerException, e:
- # Use helpful error messages instead of ugly tracebacks.
- ERRORS = {
- 13: "You don't have permission to access that port.",
- 98: "That port is already in use.",
- 99: "That IP address can't be assigned-to.",
- }
- try:
- error_text = ERRORS[e.args[0].args[0]]
- except (AttributeError, KeyError):
- error_text = str(e)
- sys.stderr.write(("Error: %s" % error_text) + '\n')
- # Need to use an OS exit because sys.exit doesn't work in a thread
- #os._exit(1)
- except KeyboardInterrupt:
- if shutdown_message:
- print shutdown_message
- sys.exit(0)
+ except WSGIServerException, e:
+ # Use helpful error messages instead of ugly tracebacks.
+ ERRORS = {
+ 13: "You don't have permission to access that port.",
+ 98: "That port is already in use.",
+ 99: "That IP address can't be assigned-to.",
+ }
+ try:
+ error_text = ERRORS[e.args[0].args[0]]
+ except (AttributeError, KeyError):
+ error_text = str(e)
+ sys.stderr.write(("Error: %s" % error_text) + '\n')
+ # Need to use an OS exit because sys.exit doesn't work in a thread
+ #os._exit(1)
+ except KeyboardInterrupt:
+ if shutdown_message:
+ print shutdown_message
+ sys.exit(0)
class ownRequestHandler(WSGIRequestHandler):
- def log_message(self, format, *args):
- return
+ def log_message(self, format, *args):
+ return
def run(addr, port, wsgi_handler):
- server_address = (addr, port)
- httpd = WSGIServer(server_address, ownRequestHandler)
- httpd.set_app(wsgi_handler)
- httpd.serve_forever()
+ server_address = (addr, port)
+ httpd = WSGIServer(server_address, ownRequestHandler)
+ httpd.set_app(wsgi_handler)
+ httpd.serve_forever()
if __name__ == "__main__":
- handle(*sys.argv[1:])
+ handle(*sys.argv[1:])