diff --git a/plugins/WebUi/__init__.py b/plugins/WebUi/__init__.py index d4548b990..4202d21ba 100644 --- a/plugins/WebUi/__init__.py +++ b/plugins/WebUi/__init__.py @@ -47,7 +47,10 @@ Other contributors: import deluge.common import deluge.pref from deluge.dialogs import show_popup_warning -from dbus_interface import get_dbus_manager +try: + from dbus_interface import get_dbus_manager +except: + pass #for unit-test. import webserver_common import time diff --git a/plugins/WebUi/dbus_interface.py b/plugins/WebUi/dbus_interface.py index c42395f70..f14a382e0 100644 --- a/plugins/WebUi/dbus_interface.py +++ b/plugins/WebUi/dbus_interface.py @@ -232,6 +232,11 @@ class DbusManager(dbus.service.Object): def get_upload_rate(self): return self.core.get_state()['upload_rate'] + @dbus.service.method(dbus_interface=dbus_interface, + in_signature="", out_signature="v") + def get_num_connections(self): + core_state = self.core.get_state() + return core_state['num_connections'] #internal def _add_torrent(self, filename): diff --git a/plugins/WebUi/debugerror.py b/plugins/WebUi/debugerror.py index a0ee5f52a..f1ef73001 100644 --- a/plugins/WebUi/debugerror.py +++ b/plugins/WebUi/debugerror.py @@ -133,8 +133,11 @@ $def with (exception_type, exception_value, frames, exception_message, version_i
+
Oops, Deluge Broke :-( , You might have found a bug, or you did something really stupid ;-).
-
If the error persists : Try downloading the latest version at
+
If the error persists :
+ Read the Faq.
+ Try downloading the latest version at
deluge-torrent.org
Visit the forum
or the buglist for more info.
@@ -290,7 +293,10 @@ def djangoerror():
exception_type, exception_value, tback = sys.exc_info()
exception_message = 'Error'
- exception_message = exception_value.message # dir(exception_value)
+ try:
+ exception_message = exception_value.message
+ except AttributeError:
+ exception_message = 'no message'
exception_type = exception_type.__name__
version_info = (
@@ -349,8 +355,9 @@ def deluge_debugerror():
(Based on the beautiful 500 page from [Django](http://djangoproject.com/),
designed by [Wilson Miner](http://wilsonminer.com/).)
"""
-
- web.ctx.headers = [('Content-Type', 'text/html')]
+ web.ctx.headers = [
+ ('Content-Type', 'text/html')
+ ]
web.ctx.output = djangoerror()
if __name__ == "__main__":
diff --git a/plugins/WebUi/deluge_webserver.py b/plugins/WebUi/deluge_webserver.py
index 437eac133..69ddb495c 100644
--- a/plugins/WebUi/deluge_webserver.py
+++ b/plugins/WebUi/deluge_webserver.py
@@ -43,29 +43,29 @@ import os
#routing:
urls = (
- "/login(.*)", "login",
- "/index(.*)", "index",
+ "/login", "login",
+ "/index", "index",
"/torrent/info/(.*)", "torrent_info",
- "/torrent/pause(.*)", "torrent_pause",
+ "/torrent/pause", "torrent_pause",
"/torrent/reannounce/(.*)", "torrent_reannounce",
- "/torrent/add(.*)", "torrent_add",
+ "/torrent/add", "torrent_add",
"/torrent/delete/(.*)", "torrent_delete",
"/torrent/queue/up/(.*)", "torrent_queue_up",
"/torrent/queue/down/(.*)", "torrent_queue_down",
"/pause_all", "pause_all",
"/resume_all", "resume_all",
- "/refresh/set(.*)", "refresh_set",
+ "/refresh/set", "refresh_set",
"/refresh/(.*)", "refresh",
- "/config","config",
+ "/config", "config",
"/home", "home",
"/about", "about",
"/logout", "logout",
#remote-api:
"/remote/torrent/add(.*)", "remote_torrent_add",
#static:
- "/static/(.*)","static",
- "/template/static/(.*)","template_static",
- #"/downloads/(.*)","downloads" disabled until it can handle large downloads.
+ "/static/(.*)", "static",
+ "/template/static/(.*)", "template_static",
+ #"/downloads/(.*)","downloads" disabled until it can handle large downloads
#default-pages
"/", "home",
"", "home"
@@ -79,15 +79,15 @@ class login:
vars = web.input(error = None)
return ws.render.login(vars.error)
- def POST(self, name):
- vars = web.input(pwd = None ,redir = None)
+ def POST(self):
+ vars = web.input(pwd = None, redir = None)
if check_pwd(vars.pwd):
#start new session
start_session()
do_redirect()
elif vars.redir:
- seeother(url('/login',error=1, redir=vars.redir))
+ seeother(url('/login', error=1, redir=vars.redir))
else:
seeother('/login?error=1')
@@ -146,13 +146,13 @@ class torrent_add:
if vars.url and vars.torrent.filename:
error_page(_("Choose an url or a torrent, not both."))
if vars.url:
- ws.proxy.add_torrent_url(vars.url )
+ ws.proxy.add_torrent_url(vars.url)
do_redirect()
elif vars.torrent.filename:
data = vars.torrent.file.read()
data_b64 = base64.b64encode(data)
#b64 because of strange bug-reports related to binary data
- ws.proxy.add_torrent_filecontent(vars.torrent.filename,data_b64)
+ ws.proxy.add_torrent_filecontent(vars.torrent.filename, data_b64)
do_redirect()
else:
error_page(_("no data."))
@@ -170,7 +170,7 @@ class remote_torrent_add:
return 'error:wrong password'
data_b64 = base64.b64encode(vars.torrent.file.read())
- ws.proxy.add_torrent_filecontent(vars.torrent.filename,data_b64)
+ ws.proxy.add_torrent_filecontent(vars.torrent.filename, data_b64)
return 'ok'
class torrent_delete:
@@ -186,7 +186,6 @@ class torrent_delete:
ws.proxy.remove_torrent(torrent_id, data_also, torrent_also)
do_redirect()
-
class torrent_queue_up:
@check_session
def POST(self, torrent_id):
@@ -214,8 +213,10 @@ class resume_all:
class refresh:
@check_session
def POST(self, name):
- auto_refresh = {'off':'0', 'on':'1'}[name]
- setcookie('auto_refresh',auto_refresh)
+ auto_refresh = {'off': '0', 'on': '1'}[name]
+ setcookie('auto_refresh', auto_refresh)
+ if not getcookie('auto_refresh_secs'):
+ setcookie('auto_refresh_secs', 10)
do_redirect()
class refresh_set:
@@ -228,7 +229,7 @@ class refresh_set:
vars = web.input(refresh = 0)
refresh = int(vars.refresh)
if refresh > 0:
- setcookie('auto_refresh','1')
+ setcookie('auto_refresh', '1')
setcookie('auto_refresh_secs', str(refresh))
do_redirect()
else:
@@ -270,12 +271,13 @@ class about:
return ws.render.about()
class logout:
+ @check_session
def POST(self, name):
end_session()
seeother('/login')
class static(static_handler):
- base_dir = os.path.join(os.path.dirname(__file__),'static')
+ base_dir = os.path.join(os.path.dirname(__file__), 'static')
class template_static(static_handler):
def get_base_dir(self):
diff --git a/plugins/WebUi/revno b/plugins/WebUi/revno
index 5bc6609e3..c75acbe2f 100644
--- a/plugins/WebUi/revno
+++ b/plugins/WebUi/revno
@@ -1 +1 @@
-117
+127
diff --git a/plugins/WebUi/scripts/extract_template_strings.py b/plugins/WebUi/scripts/extract_template_strings.py
index 46e39c863..c653ac095 100644
--- a/plugins/WebUi/scripts/extract_template_strings.py
+++ b/plugins/WebUi/scripts/extract_template_strings.py
@@ -13,8 +13,8 @@ all_strings = []
for filename in files:
with open(filename,'r') as f:
content = f.read()
- all_strings += re.findall("\$\_\(\'(.*)\'\)",content)
- all_strings += re.findall("\$\_\(\"(.*)\"\)",content)
+ all_strings += re.findall("_\(\"(.*?)\"\)",content)
+ all_strings += re.findall("_\(\'(.*?)\'\)",content)
all_strings = sorted(set(all_strings))
diff --git a/plugins/WebUi/scripts/template_strings.py b/plugins/WebUi/scripts/template_strings.py
index 8512c1788..0c057c757 100644
--- a/plugins/WebUi/scripts/template_strings.py
+++ b/plugins/WebUi/scripts/template_strings.py
@@ -1,32 +1,59 @@
_('# Of Files')
_('About')
+_('Add Torrent')
+_('Add torrent')
_('Apply')
_('Auto refresh:')
+_('Ava')
_('Availability')
+_('Config')
+_('Connections')
_('Debug:Data Dump')
_('Delete .torrent file')
_('Delete downloaded files.')
_('Details')
+_('Disable')
_('Down Speed')
+_('Download')
_('Downloaded')
_('ETA')
+_('Enable')
+_('Error')
+_('Eta')
+_('Login')
+_('Logout')
+_('Name')
_('Next Announce')
_('Off')
_('Password')
_('Password is invalid,try again')
+_('Pause all')
_('Peers')
_('Pieces')
+_('Progress')
+_('Queue Down')
+_('Queue Up')
+_('Queue pos:')
+_('Ratio')
+_('Reannounce')
_('Refresh page every:')
_('Remove')
+_('Remove %s ')
+_('Remove %s?')
+_('Resume all')
_('Seeders')
_('Set')
+_('Set Timeout')
_('Share Ratio')
+_('Size')
_('Speed')
_('Submit')
+_('Torrent list')
_('Total Size')
_('Tracker')
_('Tracker Status')
_('Up Speed')
+_('Upload')
_('Upload torrent')
_('Uploaded')
_('Url')
diff --git a/plugins/WebUi/templates/deluge/about.html b/plugins/WebUi/templates/deluge/about.html
index c882c8fad..b34b7877a 100644
--- a/plugins/WebUi/templates/deluge/about.html
+++ b/plugins/WebUi/templates/deluge/about.html
@@ -25,6 +25,7 @@ $:render.header(_('About'))
| $_('Total Size'): | -$fsize(torrent.total_size) | $fspeed(torrent.total_size) |
| $_('# Of Files'): | $torrent.num_files |