diff --git a/deluge/ui/webui/webui_plugin/config_tabs_deluge.py b/deluge/ui/webui/webui_plugin/config_tabs_deluge.py index 281fda2ea..e8489e79b 100644 --- a/deluge/ui/webui/webui_plugin/config_tabs_deluge.py +++ b/deluge/ui/webui/webui_plugin/config_tabs_deluge.py @@ -134,3 +134,23 @@ class Plugins(config.Form): raise forms.ValidationError("SAVE:TODO") config.register_block('deluge','plugins', Plugins) + + +class Queue(config.Form): + title = _("Queue") + info = _("queue-cfg not finished") + + queue_top = config.CheckBox(_("Queue new torrents to top")) + total_active = config.DelugeInt(_("Total active torrents")) + total_seeding = config.DelugeInt(_("Total active seeding")) + total_downloading = config.DelugeInt(_("Total active downloading")) + + queue_bottom = config.CheckBox(_("Queue completed torrents to bottom")) + stop_on_ratio = config.CheckBox(_("Stop seeding when ratio reaches")) + stop_ratio = config.DelugeInt(_("TODO:float-edit-box")) + remove_after_stop = config.CheckBox(_("Remve torrent when ratio reached")) + + def save(self, value): + raise forms.ValidationError("SAVE:TODO") + +config.register_block('plugins','queue', Queue) \ No newline at end of file diff --git a/deluge/ui/webui/webui_plugin/config_tabs_webui.py b/deluge/ui/webui/webui_plugin/config_tabs_webui.py index 74845a947..5937ca699 100644 --- a/deluge/ui/webui/webui_plugin/config_tabs_webui.py +++ b/deluge/ui/webui/webui_plugin/config_tabs_webui.py @@ -55,9 +55,16 @@ class Template(config.WebCfgForm): class Server(config.WebCfgForm): title = _("Server") + try: + import OpenSSL + except ImportError: + info = _("pyopenssl not installed, install this for https.") + port = forms.IntegerField(label = _("Port"),min_value=80) + use_https = config.CheckBox(_("Use https")) + def post_save(self): pass #raise forms.ValidationError( diff --git a/deluge/ui/webui/webui_plugin/debugerror.py b/deluge/ui/webui/webui_plugin/debugerror.py index 259dcac72..eed0b2cab 100644 --- a/deluge/ui/webui/webui_plugin/debugerror.py +++ b/deluge/ui/webui/webui_plugin/debugerror.py @@ -1,15 +1,42 @@ """ -pretty debug errors -(part of web.py) +adapted for deluge-webui: +-edit-box with traceback for cut+paste. +-pretty errors for well known exceptions. + +web.py : adapted from Django Copyright (c) 2005, the Lawrence Journal-World Used under the modified BSD license: http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 """ - __all__ = ["debugerror", "djangoerror"] +import utils +print utils +print dir(utils) + + +pretty_errors_str = { +"org.freedesktop.DBus.Error.ServiceUnknown": + """ Webui Lost the connection to deluge
+ Unable to reconnect, please restart deluge. + """, +"InvalidUniqueIDError:": + """ + this torrent was removed, + click here to go to the torrent-list + """ +} + + +pretty_errors_cls = { + type(utils.UnknownTorrentError):""" + this torrent was removed, + click here to go to the torrent-list + """ +} + import sys, urlparse, pprint from lib.webpy022.net import websafe from lib.webpy022.template import Template @@ -299,6 +326,16 @@ def djangoerror(): exception_message = 'no message' exception_type = exception_type.__name__ + """ + for err_str in pretty_errors: + if err_str in exception_message: + #from render import render + return render.error(pretty_errors[err_str]) + """ + if exception_type in pretty_errors_cls: + from render import render + return render.error(pretty_errors_cls[exception_type]) + version_info = ( "WebUi : rev." + ws.REVNO + "Python : " + str(sys.version) diff --git a/deluge/ui/webui/webui_plugin/pages.py b/deluge/ui/webui/webui_plugin/pages.py index 86761b05e..79474248b 100644 --- a/deluge/ui/webui/webui_plugin/pages.py +++ b/deluge/ui/webui/webui_plugin/pages.py @@ -39,6 +39,10 @@ import config_tabs_webui #auto registers import config_tabs_deluge #auto registers from config import config_page #import forms +# +from debugerror import deluge_debugerror +web.webapi.internalerror = deluge_debugerror +# import lib.webpy022 as web from lib.webpy022.http import seeother, url diff --git a/deluge/ui/webui/webui_plugin/templates/advanced/index.html b/deluge/ui/webui/webui_plugin/templates/advanced/index.html index bb84f9d52..5313ac739 100644 --- a/deluge/ui/webui/webui_plugin/templates/advanced/index.html +++ b/deluge/ui/webui/webui_plugin/templates/advanced/index.html @@ -1,6 +1,15 @@ $def with (torrent_list, all_torrents) $:render.header(_('Torrent list')) + + +
-
@@ -142,6 +150,6 @@ $:part_stats() - $:render.footer() + diff --git a/deluge/ui/webui/webui_plugin/utils.py b/deluge/ui/webui/webui_plugin/utils.py index 78bcfa75b..036f9b5e9 100644 --- a/deluge/ui/webui/webui_plugin/utils.py +++ b/deluge/ui/webui/webui_plugin/utils.py @@ -48,10 +48,7 @@ from urlparse import urlparse from webserver_common import REVNO, VERSION, TORRENT_KEYS, STATE_MESSAGES from webserver_common import ws -from debugerror import deluge_debugerror -#init: -web.webapi.internalerror = deluge_debugerror debug_unicode = False #methods: @@ -146,6 +143,10 @@ def get_torrent_status(torrent_id): ws.log.warning('torrent_status:None key in status:%s' % key) + if status.tracker == 0: + #0.6 does not raise a decent error on non-existing torrent. + raise UnknownTorrentError(torrent_id) + status["id"] = torrent_id url = urlparse(status.tracker) @@ -253,3 +254,10 @@ def get_category_choosers(torrent_list): #/utils +class WebUiError(Exception): + """the message of these exceptions will be rendered in + render.error(e.message) in debugerror.py""" + pass + +class UnknownTorrentError(WebUiError): + pass diff --git a/deluge/ui/webui/webui_plugin/webserver_common.py b/deluge/ui/webui/webui_plugin/webserver_common.py index 743ad20e2..ed257461c 100644 --- a/deluge/ui/webui/webui_plugin/webserver_common.py +++ b/deluge/ui/webui/webui_plugin/webserver_common.py @@ -108,6 +108,36 @@ CONFIG_DEFAULTS = { #/constants +class SyncProxyFunction(): + """ + helper class for SyncProxy + """ + def __init__(self,client, func_name): + self.func_name = func_name + self.client = client + + def __call__(self,*args,**kwargs): + sync_result = [] + + def callback( result): + sync_result.append(result) + func = getattr(self.client,self.func_name) + + func(callback,*args) + + self.client.force_call(block=True) + + return sync_result[0] + +class SyncProxy(object): + """acts like the old synchonous proxy""" + def __init__(self, client): + self.client = client + + def __getattr__(self, attr,*args,**kwargs): + return SyncProxyFunction(self.client, attr) + + class Ws: """ singleton @@ -141,11 +171,15 @@ class Ws: self.config = pickle.load(open(self.config_file)) def init_06(self, uri = 'http://localhost:58846'): - import deluge.ui.client as proxy + import deluge.ui.client as async_proxy from deluge.log import LOG as log self.log = log - proxy.set_core_uri(uri) - self.proxy = proxy + async_proxy.set_core_uri(uri) + self.async_proxy = async_proxy + + self.proxy = SyncProxy(self.async_proxy) + + #MONKEY PATCH, TODO->REMOVE!!! def add_torrent_filecontent(name , data_b64): @@ -174,7 +208,6 @@ class Ws: f.close() self.init_process() - self.proxy = proxy self.env = '0.6' def init_05(self):