summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-29 12:09:42 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-29 12:09:42 +0200
commit2ba07aa53d2af572af2c5a43e77725abd46e1b13 (patch)
tree89ff915a3a476dd9431d38c6e2b39b9de1aeb0f5 /module/web
parentAdded tag working for changeset 3cca18acfe7d (diff)
downloadpyload-2ba07aa53d2af572af2c5a43e77725abd46e1b13.tar.xz
many new stuff, some things already working
Diffstat (limited to 'module/web')
-rw-r--r--module/web/ServerThread.py51
-rw-r--r--module/web/ajax/views.py3
-rw-r--r--module/web/pyload/views.py8
-rw-r--r--module/web/settings.py16
-rw-r--r--module/web/templates/default/collector.html16
-rw-r--r--module/web/templates/default/queue.html20
6 files changed, 60 insertions, 54 deletions
diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py
index 4ced2e1e4..f7bf11b3c 100644
--- a/module/web/ServerThread.py
+++ b/module/web/ServerThread.py
@@ -12,13 +12,13 @@ import sys
import logging
core = None
-logger = logging.getLogger("log")
+log = logging.getLogger("log")
class WebServer(threading.Thread):
def __init__(self, pycore):
global core
threading.Thread.__init__(self)
- self.pycore = pycore
+ self.core = pycore
core = pycore
self.running = True
self.server = pycore.config['webinterface']['server']
@@ -26,23 +26,25 @@ class WebServer(threading.Thread):
self.setDaemon(True)
def run(self):
- sys.path.append(join(self.pycore.path, "module", "web"))
+ sys.path.append(join(pypath, "module", "web"))
avail = ["builtin"]
- host = self.pycore.config['webinterface']['host']
- port = self.pycore.config['webinterface']['port']
- path = join(self.pycore.path, "module", "web")
+ host = self.core.config['webinterface']['host']
+ port = self.core.config['webinterface']['port']
+ path = join(pypath, "module", "web")
out = StringIO()
- if not exists(join(self.pycore.path, "module", "web", "pyload.db")):
+ #@TODO rewrite, maybe as hook
+
+ if exists(join("module", "web", "pyload.db")):
#print "########## IMPORTANT ###########"
#print "### Database for Webinterface does not 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."
- logger.warning(_("Database for Webinterface does not exitst, it will not be available."))
- logger.warning(_("Please run: python %s syncdb") % join(self.pycore.path, "module", "web", "manage.py"))
- logger.warning(_("You have to add at least one User, to gain access to webinterface: python %s createsuperuser") % join(self.pycore.path, "module", "web", "manage.py"))
- logger.warning(_("Dont forget to restart pyLoad if you are done."))
+ log.warning(_("Database for Webinterface does not exitst, it will not be available."))
+ log.warning(_("Please run: python %s syncdb") % join(pypath, "module", "web", "manage.py"))
+ log.warning(_("You have to add at least one User, to gain access to webinterface: python %s createsuperuser") % join(configdir, "module", "web", "manage.py"))
+ log.warning(_("Dont forget to restart pyLoad if you are done."))
return None
try:
@@ -68,10 +70,10 @@ class WebServer(threading.Thread):
try:
- if exists(self.pycore.config["ssl"]["cert"]) and exists(self.pycore.config["ssl"]["key"]):
+ if exists(self.core.config["ssl"]["cert"]) and exists(self.core.config["ssl"]["key"]):
if not exists("ssl.pem"):
- key = file(self.pycore.config["ssl"]["key"], "rb")
- cert = file(self.pycore.config["ssl"]["cert"], "rb")
+ key = file(self.core.config["ssl"]["key"], "rb")
+ cert = file(self.core.config["ssl"]["cert"], "rb")
pem = file("ssl.pem", "wb")
pem.writelines(key.readlines())
@@ -94,7 +96,7 @@ class WebServer(threading.Thread):
if self.server == "nginx":
- self.pycore.logger.info(_("Starting nginx Webserver: %s:%s") % (host, port))
+ self.core.logger.info(_("Starting nginx Webserver: %s:%s") % (host, port))
config = file(join(path, "servers", "nginx_default.conf"), "rb")
content = config.readlines()
config.close()
@@ -111,7 +113,7 @@ class WebServer(threading.Thread):
ssl on;
ssl_certificate %s;
ssl_certificate_key %s;
- """ % (self.pycore.config["ssl"]["cert"], self.pycore.config["ssl"]["key"]))
+ """ % (self.core.config["ssl"]["cert"], self.core.config["ssl"]["key"]))
else:
content = content.replace("%(ssl)", "")
@@ -127,7 +129,7 @@ class WebServer(threading.Thread):
elif self.server == "lighttpd":
- self.pycore.logger.info(_("Starting lighttpd Webserver: %s:%s") % (host, port))
+ self.core.logger.info(_("Starting lighttpd Webserver: %s:%s") % (host, port))
config = file(join(path, "servers", "lighttpd_default.conf"), "rb")
content = config.readlines()
config.close()
@@ -144,7 +146,7 @@ class WebServer(threading.Thread):
ssl.engine = "enable"
ssl.pemfile = "%s"
ssl.ca-file = "%s"
- """ % (join(self.pycore.path, "ssl.pem"), self.pycore.config["ssl"]["cert"]))
+ """ % (join(selcorere.path, "ssl.pem"), self.core.config["ssl"]["cert"]))
else:
content = content.replace("%(ssl)", "")
new_config = file(join(path, "servers", "lighttpd.conf"), "wb")
@@ -158,17 +160,14 @@ class WebServer(threading.Thread):
run_fcgi.handle("daemonize=false", "method=threaded", "host=127.0.0.1", "port=9295")
- elif self.server == "builtin":
- self.pycore.logger.info(_("Starting django builtin Webserver: %s:%s") % (host, port))
-
- import run_server
- run_server.handle(host, port)
- #command = ['python', join(self.pycore.path, "module", "web", "run_server.py"), "%s:%s" % (host, port)]
- #self.p = Popen(command, stderr=Output(out), stdin=Output(out), stdout=Output(out))
- else:
+ elif self.server == "fastcgi":
#run fastcgi on port
import run_fcgi
run_fcgi.handle("daemonize=false", "method=threaded", "host=127.0.0.1", "port=%s" % str(port))
+ else:
+ self.core.log.info(_("Starting django builtin Webserver: %s:%s") % (host, port))
+ import run_server
+ run_server.handle(host, port)
def quit(self):
diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py
index c52be119f..5e4d4710b 100644
--- a/module/web/ajax/views.py
+++ b/module/web/ajax/views.py
@@ -75,6 +75,7 @@ def add_package(request):
links = map(lambda x: x.strip(), links)
links = filter(lambda x: x != "", links)
+
settings.PYLOAD.add_package(name, links, queue)
return JsonResponse("success")
@@ -199,7 +200,7 @@ def remove_package(request, id):
try:
settings.PYLOAD.del_packages([int(id)])
return JsonResponse("sucess")
- except:
+ except Exception, e:
return HttpResponseServerError()
@permission('pyload.can_add_dl')
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py
index 47ef0a864..52b58cd03 100644
--- a/module/web/pyload/views.py
+++ b/module/web/pyload/views.py
@@ -74,7 +74,7 @@ def home(request):
@permission('pyload.can_see_dl')
@check_server
def queue(request):
- queue = settings.PYLOAD.get_full_queue()
+ queue = settings.PYLOAD.get_queue()
return render_to_response(join(settings.TEMPLATE, 'queue.html'), RequestContext(request, {'content': queue}, [status_proc]))
@@ -159,10 +159,8 @@ def logs(request, page=0):
@permission('pyload.can_add_dl')
@check_server
def collector(request):
- coll = settings.PYLOAD.get_collector_packages()
- for pack in coll:
- pack["children"] = map(settings.PYLOAD.get_file_info, settings.PYLOAD.get_package_files(pack["id"]))
- return render_to_response(join(settings.TEMPLATE, 'collector.html'), RequestContext(request, {'content': coll}, [status_proc]))
+ queue = settings.PYLOAD.get_collector()
+ return render_to_response(join(settings.TEMPLATE, 'collector.html'), RequestContext(request, {'content': queue}, [status_proc]))
@login_required
diff --git a/module/web/settings.py b/module/web/settings.py
index 8f9425198..7380541e6 100644
--- a/module/web/settings.py
+++ b/module/web/settings.py
@@ -15,9 +15,17 @@ PROJECT_DIR = os.path.dirname(__file__)
PYLOAD_DIR = os.path.join(PROJECT_DIR,"..","..")
+sys.path.append(PYLOAD_DIR)
+
+
sys.path.append(os.path.join(PYLOAD_DIR, "module"))
-from XMLConfigParser import XMLConfigParser
-config = XMLConfigParser(os.path.join(PYLOAD_DIR,"module","config","core.xml"))
+
+import InitHomeDir
+sys.path.append(pypath)
+
+
+from module.ConfigParser import ConfigParser
+config = ConfigParser()
#DEBUG = config.get("general","debug")
@@ -35,8 +43,8 @@ except:
server_url = "http%s://%s:%s@%s:%s/" % (
ssl,
- config.get("remote", "username"),
- config.get("remote", "password"),
+ config.username,
+ config.password,
config.get("remote", "listenaddr"),
config.get("remote", "port")
)
diff --git a/module/web/templates/default/collector.html b/module/web/templates/default/collector.html
index 73625136c..b0d5b1839 100644
--- a/module/web/templates/default/collector.html
+++ b/module/web/templates/default/collector.html
@@ -106,10 +106,10 @@ document.addEvent("domready", function(){
</li>{% endblock %}
{% block content %}
-{% for package in content %}
-<div id="package_{{package.id}}" class="package">
+{% for id,package in content.iteritems %}
+<div id="package_{{id}}" class="package">
<div class="packagename" style="cursor: pointer;">
- {{ package.package_name }}
+ {{ package.name }}
&nbsp;&nbsp;
<img title="{% trans "Delete Package" %}" width="12px" height="12px" src="{{ MEDIA_URL }}img/delete.png" />
&nbsp;&nbsp;
@@ -117,15 +117,15 @@ document.addEvent("domready", function(){
&nbsp;&nbsp;
<img title="{% trans "Push Package to Queue" %}" style="margin-left: -10px" height="12px" src="{{ MEDIA_URL }}img/package_go.png" />
</div>
- <div id="children_{{package.id}}" style="display: none;" class="children">
- {% for child in package.children %}
- <div class="child" id="file_{{child.id}}">
+ <div id="children_{{id}}" style="display: none;" class="children">
+ {% for lid, child in package.links.iteritems %}
+ <div class="child" id="file_{{lid}}">
<span class="child_status">
<img src="/media/default/img/status_{{child.status_type}}.png" style="width: 12px; height:12px;"/>
</span>
- <span style="font-size: 15px">{{ child.filename }}</span><br />
+ <span style="font-size: 15px">{{ child.name }}</span><br />
<div class="child_secrow">
- <span class="child_status">{{ child.status_type }}</span>{{child.status_error}}&nbsp;
+ <span class="child_status">{{ child.status }}</span>{{child.error}}&nbsp;
<span class="child_status">{{ child.size }} KB</span>
<span class="child_status">{{ child.plugin }}</span>
<span class="child_status">{% trans "Folder:" %} {{child.folder}}</span>
diff --git a/module/web/templates/default/queue.html b/module/web/templates/default/queue.html
index d33a11032..d149853d5 100644
--- a/module/web/templates/default/queue.html
+++ b/module/web/templates/default/queue.html
@@ -96,27 +96,27 @@ document.addEvent("domready", function(){
</li>{% endblock %}
{% block content %}
-{% for package in content %}
-<div id="package_{{package.data.id}}" class="package">
+{% for id, package in content.iteritems %}
+<div id="package_{{id}}" class="package">
<div class="packagename" style="cursor: pointer;">
- {{ package.data.package_name }}
+ {{ package.name }}
&nbsp;&nbsp;
<img title="{% trans "Delete Package" %}" width="12px" height="12px" src="{{ MEDIA_URL }}img/delete.png" />
&nbsp;&nbsp;
<img title="{% trans "Restart Package" %}" style="margin-left: -10px" height="12px" src="{{ MEDIA_URL }}img/arrow_refresh.png" />
</div>
- <div id="children_{{package.data.id}}" style="display: none;" class="children">
- {% for child in package.children %}
- <div class="child" id="file_{{child.id}}">
+ <div id="children_{{id}}" style="display: none;" class="children">
+ {% for lid, child in package.links.iteritems %}
+ <div class="child" id="file_{{lid}}">
<span class="child_status">
- <img src="/media/default/img/status_{{child.status_type}}.png" style="width: 12px; height:12px;"/>
+ <img src="/media/default/img/status_{{child.status}}.png" style="width: 12px; height:12px;"/>
</span>
- <span style="font-size: 15px">{{ child.filename }}</span><br />
+ <span style="font-size: 15px">{{ child.name }}</span><br />
<div class="child_secrow">
- <span class="child_status">{{ child.status_type }}</span>{{child.status_error}}&nbsp;
+ <span class="child_status">{{ child.status }}</span>{{child.error}}&nbsp;
<span class="child_status">{{ child.size }} KB</span>
<span class="child_status">{{ child.plugin }}</span>
- <span class="child_status">{% trans "Folder:" %} {{child.folder}}</span>
+ <span class="child_status">{% trans "Folder:" %} {{package.folder}}</span>
&nbsp;&nbsp;
<img title="{% trans "Delete Link" %}" style="cursor: pointer;" width="10px" height="10px" src="{{ MEDIA_URL }}img/delete.png" />
&nbsp;&nbsp;