summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-12-16 23:45:21 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-12-16 23:45:21 +0100
commitaea618c1bffe9ea6eb44b8555f17349b39dfe22b (patch)
tree407b9a864ad9733eecdd4eb7b247af554c450858
parentmerged (diff)
downloadpyload-aea618c1bffe9ea6eb44b8555f17349b39dfe22b.tar.xz
new functions for interacting with core
-rw-r--r--module/web/ajax/urls.py2
-rw-r--r--module/web/ajax/views.py43
-rwxr-xr-xpyLoadCore.py12
3 files changed, 33 insertions, 24 deletions
diff --git a/module/web/ajax/urls.py b/module/web/ajax/urls.py
index 0db240578..d1c90aa21 100644
--- a/module/web/ajax/urls.py
+++ b/module/web/ajax/urls.py
@@ -16,4 +16,6 @@ urlpatterns = patterns('ajax',
(r'^status$', 'views.status'),
(r'^links$', 'views.links'),
(r'^queue$', 'views.queue'),
+ (r'^pause$', 'views.pause'),
+ (r'^unpause$', 'views.unpause'),
) \ No newline at end of file
diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py
index c4395a659..05c91597f 100644
--- a/module/web/ajax/views.py
+++ b/module/web/ajax/views.py
@@ -6,28 +6,7 @@ from django.conf import settings
from django.shortcuts import render_to_response
from django.utils import simplejson
from django.core.serializers import json
-
-def check_server(function):
- def _dec(view_func):
- def _view(request, *args, **kwargs):
- try:
- version = settings.PYLOAD.get_server_version()
- except Exception, e:
- return HttpResponseServerError()
-
- return view_func(request, *args, **kwargs)
-
- _view.__name__ = view_func.__name__
- _view.__dict__ = view_func.__dict__
- _view.__doc__ = view_func.__doc__
-
- return _view
-
- if function is None:
- return _dec
- else:
- return _dec(function)
-
+
def permission(perm):
def _dec(view_func):
def _view(request, *args, **kwargs):
@@ -80,4 +59,22 @@ def queue(request):
return JsonResponse(settings.PYLOAD.get_queue())
except:
- return HttpResponseServerError() \ No newline at end of file
+ return HttpResponseServerError()
+
+
+@permission('pyload.can_change_satus')
+def pause(request):
+ try:
+ return JsonResponse(settings.PYLOAD.pause_server())
+
+ except:
+ return HttpResponseServerError()
+
+
+@permission('pyload.can_change_status')
+def unpause(request):
+ try:
+ return JsonResponse(settings.PYLOAD.unpause_server())
+
+ except:
+ return HttpResponseServerError()
diff --git a/pyLoadCore.py b/pyLoadCore.py
index ee8cd8109..c5be49c1a 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -122,12 +122,16 @@ class Core(object):
self.check_install("django", "Django for webinterface")
self.check_install("tesseract", "tesseract for captcha reading", False)
self.check_install("gocr", "gocr for captcha reading", False)
+
self.check_file(self.config['log']['log_folder'], _("folder for logs"), True)
self.check_file(self.config['general']['download_folder'], _("folder for downloads"), True)
self.check_file(self.config['general']['link_file'], _("file for links"))
self.check_file(self.config['general']['failed_file'], _("file for failed links"))
- script_folders = ['scripts/download_preparing/', 'scripts/download_finished/', 'scripts/package_finished/', 'scripts/reconnected/']
+
+ script_folders = ['scripts/download_preparing/', 'scripts/download_finished/', 'scripts/package_finished/', 'scripts/reconnected/'] # @TODO: windows save?
+
self.check_file(script_folders, _("folders for scripts"), True)
+
if self.config['ssl']['activated']:
self.check_install("OpenSSL", "OpenSSL for secure connection", True)
self.check_file(self.config['ssl']['cert'], _("ssl certificate"), False, True)
@@ -371,6 +375,12 @@ class ServerMethods():
else:
raise Exception("not allowed!")
+ def pause_server(self):
+ self.core.thread_list.pause = True
+
+ def unpause_server(self):
+ self.core.thread_list.pause = False
+
def status_server(self):
status = {}
status['pause'] = self.core.thread_list.pause