revert webui

This commit is contained in:
Marcos Pinto 2007-11-22 04:20:42 +00:00
parent 74f739a693
commit cc0d1502cc
16 changed files with 158 additions and 311 deletions

View File

@ -45,20 +45,13 @@ Other contributors:
""" """
import deluge.common import deluge.common
try: import deluge.pref
import deluge.pref from deluge.dialogs import show_popup_warning
from deluge.dialogs import show_popup_warning
import webserver_common
except ImportError:
print 'WebUi:not imported as a plugin'
try: try:
from dbus_interface import get_dbus_manager from dbus_interface import get_dbus_manager
except: except:
pass #for unit-test. pass #for unit-test.
import webserver_common
import time import time
import gtk import gtk
@ -124,9 +117,6 @@ class plugin_WebUi(object):
else: else:
self.config.set("run_in_thread", False) self.config.set("run_in_thread", False)
if self.config.get("use_https") == None:
self.config.set("use_https", False)
self.dbus_manager = get_dbus_manager(deluge_core, deluge_interface, self.dbus_manager = get_dbus_manager(deluge_core, deluge_interface,
self.config, self.config_file) self.config, self.config_file)
@ -177,6 +167,8 @@ class plugin_WebUi(object):
def __del__(self): def __del__(self):
self.kill_server() self.kill_server()
class ConfigDialog(gtk.Dialog): class ConfigDialog(gtk.Dialog):
""" """
sorry, can't get used to gui builders. sorry, can't get used to gui builders.
@ -203,12 +195,6 @@ class ConfigDialog(gtk.Dialog):
gtk.combo_box_new_text()) gtk.combo_box_new_text())
self.cache_templates = self.add_widget(_('Cache Templates'), self.cache_templates = self.add_widget(_('Cache Templates'),
gtk.CheckButton()) gtk.CheckButton())
"""
temporary disable for 0.5.7
self.use_https = self.add_widget(_('Use https://'),
gtk.CheckButton())
"""
#self.share_downloads = self.add_widget(_('Share Download Directory'), #self.share_downloads = self.add_widget(_('Share Download Directory'),
# gtk.CheckButton()) # gtk.CheckButton())
@ -236,7 +222,6 @@ class ConfigDialog(gtk.Dialog):
# bool(self.config.get("share_downloads"))) # bool(self.config.get("share_downloads")))
self.cache_templates.set_active(self.config.get("cache_templates")) self.cache_templates.set_active(self.config.get("cache_templates"))
"""0.5.7.. self.use_https.set_active(self.config.get("use_https"))"""
self.vbox.pack_start(self.vb, True, True, 0) self.vbox.pack_start(self.vb, True, True, 0)
self.vb.show_all() self.vb.show_all()
@ -272,7 +257,6 @@ class ConfigDialog(gtk.Dialog):
self.config.set("template", self.template.get_active_text()) self.config.set("template", self.template.get_active_text())
self.config.set("button_style", self.button_style.get_active()) self.config.set("button_style", self.button_style.get_active())
self.config.set("cache_templates", self.cache_templates.get_active()) self.config.set("cache_templates", self.cache_templates.get_active())
#0.5.7.. self.config.set("use_https", self.use_https.get_active())
#self.config.set("share_downloads", self.share_downloads.get_active()) #self.config.set("share_downloads", self.share_downloads.get_active())
self.config.save(self.plugin.config_file) self.config.save(self.plugin.config_file)
self.plugin.start_server() #restarts server self.plugin.start_server() #restarts server

View File

@ -95,8 +95,7 @@ class DbusManager(dbus.service.Object):
"total_size": state["total_size"], "total_size": state["total_size"],
"num_pieces": state["num_pieces"], "num_pieces": state["num_pieces"],
"state": state['state'], "state": state['state'],
"user_paused": self.core.is_user_paused(torrent_id), "paused": self.core.is_user_paused(torrent_id),
"paused":state['is_paused'],
"progress": int(state["progress"] * 100), "progress": int(state["progress"] * 100),
"next_announce": state["next_announce"], "next_announce": state["next_announce"],
"total_payload_download":state["total_payload_download"], "total_payload_download":state["total_payload_download"],
@ -154,22 +153,16 @@ class DbusManager(dbus.service.Object):
self.core.update_tracker(torrent_id) self.core.update_tracker(torrent_id)
@dbus.service.method(dbus_interface=dbus_interface, @dbus.service.method(dbus_interface=dbus_interface,
in_signature="asbb", out_signature="") in_signature="sbb", out_signature="")
def remove_torrent(self, torrent_ids, data_also, torrent_also): def remove_torrent(self, torrent_id, data_also, torrent_also):
"""remove a torrent,and optionally data and torrent """remove a torrent,and optionally data and torrent
additions compared to 0.6 interface: (data_also, torrent_also) additions compared to 0.6 interface: (data_also, torrent_also)
""" """
for torrent_id in torrent_ids: torrent_id = int(torrent_id)
torrent_id = int(torrent_id) self.core.remove_torrent(torrent_id, bool(data_also)
self.core.remove_torrent(torrent_id, bool(data_also) ,bool( torrent_also))
,bool( torrent_also)) #this should not be needed:
self.interface.torrent_model_remove(torrent_id)
#this should not be needed:
gtk.gdk.threads_enter()
try:
self.interface.torrent_model_remove(torrent_id)
except:
pass
@dbus.service.method(dbus_interface=dbus_interface, @dbus.service.method(dbus_interface=dbus_interface,
in_signature="s", out_signature="b") in_signature="s", out_signature="b")
@ -181,6 +174,7 @@ class DbusManager(dbus.service.Object):
@dbus.service.method(dbus_interface=dbus_interface, @dbus.service.method(dbus_interface=dbus_interface,
in_signature="s", out_signature="b") in_signature="s", out_signature="b")
def queue_up(self, torrent_id): def queue_up(self, torrent_id):
print 'UP!'
self.core.queue_up(int(torrent_id)) self.core.queue_up(int(torrent_id))
return True return True

View File

@ -46,9 +46,7 @@ urls = (
"/login", "login", "/login", "login",
"/index", "index", "/index", "index",
"/torrent/info/(.*)", "torrent_info", "/torrent/info/(.*)", "torrent_info",
"/torrent/info_inner/(.*)", "torrent_info_inner", "/torrent/pause", "torrent_pause",
"/torrent/stop/(.*)", "torrent_stop",
"/torrent/start/(.*)", "torrent_start",
"/torrent/reannounce/(.*)", "torrent_reannounce", "/torrent/reannounce/(.*)", "torrent_reannounce",
"/torrent/add", "torrent_add", "/torrent/add", "torrent_add",
"/torrent/delete/(.*)", "torrent_delete", "/torrent/delete/(.*)", "torrent_delete",
@ -117,38 +115,19 @@ class index:
class torrent_info: class torrent_info:
@deluge_page @deluge_page
@auto_refreshed @auto_refreshed
def GET(self, name): def GET(self, torrent_id):
torrent_id = name.split(',')[0]
return ws.render.torrent_info(get_torrent_status(torrent_id)) return ws.render.torrent_info(get_torrent_status(torrent_id))
class torrent_info_inner: class torrent_pause:
@deluge_page
def GET(self, torrent_ids):
torrent_ids = torrent_ids.split(',')
info = get_torrent_status(torrent_ids[0])
if len(torrent_ids) > 1:
#todo : hmm, lots of manual stuff here :(
pass
return ws.render.torrent_info_inner(info)
class torrent_start:
@check_session @check_session
def POST(self, name): def POST(self, name):
torrent_ids = name.split(',') vars = web.input(stop = None, start = None, redir = None)
ws.proxy.resume_torrent(torrent_ids) if vars.stop:
ws.proxy.pause_torrent([vars.stop])
elif vars.start:
ws.proxy.resume_torrent([vars.start])
do_redirect() do_redirect()
class torrent_stop:
@check_session
def POST(self, name):
torrent_ids = name.split(',')
ws.proxy.pause_torrent(torrent_ids)
do_redirect()
class torrent_reannounce: class torrent_reannounce:
@check_session @check_session
def POST(self, torrent_id): def POST(self, torrent_id):
@ -196,32 +175,27 @@ class remote_torrent_add:
class torrent_delete: class torrent_delete:
@deluge_page @deluge_page
def GET(self, name): def GET(self, torrent_id):
torrent_ids = name.split(',') return ws.render.torrent_delete(get_torrent_status(torrent_id))
torrent_list = [get_torrent_status(id) for id in torrent_ids]
return ws.render.torrent_delete(name, torrent_list)
@check_session @check_session
def POST(self, name): def POST(self, torrent_id):
torrent_ids = name.split(',')
vars = web.input(data_also = None, torrent_also = None) vars = web.input(data_also = None, torrent_also = None)
data_also = bool(vars.data_also) data_also = bool(vars.data_also)
torrent_also = bool(vars.torrent_also) torrent_also = bool(vars.torrent_also)
ws.proxy.remove_torrent(torrent_ids, data_also, torrent_also) ws.proxy.remove_torrent(torrent_id, data_also, torrent_also)
do_redirect() do_redirect()
class torrent_queue_up: class torrent_queue_up:
@check_session @check_session
def POST(self, name): def POST(self, torrent_id):
for torrent_id in sorted(name.split(',')): ws.proxy.queue_up(torrent_id)
ws.proxy.queue_up(torrent_id)
do_redirect() do_redirect()
class torrent_queue_down: class torrent_queue_down:
@check_session @check_session
def POST(self, name): def POST(self, torrent_id):
for torrent_id in reversed(sorted(name.split(','))): ws.proxy.queue_down(torrent_id)
ws.proxy.queue_down(torrent_id)
do_redirect() do_redirect()
class pause_all: class pause_all:

View File

@ -1 +1 @@
143 127

View File

@ -26,16 +26,11 @@ form.deluge_button {
} }
button.deluge_button { button.deluge_button {
background-color: #37506f; background-color: #37506f;
border:1px solid #68a; border:1px solid #23344b;
background: #99acc3; background: #99acc3;
color: #000; color: #000;
vertical-align:middle;
-moz-border-radius:7px;
}
button.deluge_button:hover {
background-color:#68a;
} }
div.error { div.error {
background-color:#FFFFFF; background-color:#FFFFFF;
color:#AA0000; color:#AA0000;
@ -47,28 +42,4 @@ div.error {
} }
/*tr.torrent_table:hover {
background-color:#68a;
}*/
tr.torrent_table_selected {
background-color:#900;
}
th.torrent_table:hover {
background-color:#68a;
}
img.button {
margin-bottom:0px;
padding:0px;
position:relative;
top:2px;
}
body.inner {
background:none;
}
/* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */ /* Hides from IE-mac \*/ * html .clearfix {height: 1%;} .clearfix {display: block;} /* End hide from IE-mac */

View File

@ -1,6 +1,7 @@
$def with (torrent_list) $def with (torrent_list)
$:render.header(_('Torrent list')) $:render.header(_('Torrent list'))
<form action="/torrent/pause" method="POST">
<table class="torrent_list" border=1> <table class="torrent_list" border=1>
<tr> <tr>
$:(sort_head('calc_state_str', 'S')) $:(sort_head('calc_state_str', 'S'))
@ -18,19 +19,14 @@ $:render.header(_('Torrent list'))
</tr> </tr>
$#4-space indentation is mandatory for for-loops in templetor! $#4-space indentation is mandatory for for-loops in templetor!
$for torrent in torrent_list: $for torrent in torrent_list:
<tr class="torrent_table" id="torrent_$torrent.id"> <tr>
<td> <td><input type="image"
<form action="/torrent/$torrent.action/$torrent.id" method="POST"> src="/static/images/$(torrent.calc_state_str)16.png"
<input type="image" name="$torrent.action" value="$torrent.id">
src="/static/images/$(torrent.calc_state_str)16.png"
name="pauseresume" value="submit" />
</form>
</td> </td>
<td>$torrent.queue_pos</td> <td>$torrent.queue_pos</td>
<td style="width:100px; overflow:hidden;white-space: nowrap"> <td style="width:100px; overflow:hidden;white-space: nowrap">
<a href="/torrent/info/$torrent.id" > <a href="/torrent/info/$torrent.id">$(crop(torrent.name, 40))</a></td>
$(crop(torrent.name, 40))</a></td>
<td>$fsize(torrent.total_size)</td> <td>$fsize(torrent.total_size)</td>
<td class="progress_bar"> <td class="progress_bar">
<div class="progress_bar_outer"> <div class="progress_bar_outer">
@ -49,7 +45,7 @@ $for torrent in torrent_list:
</tr> </tr>
</table> </table>
</form>
<div class="panel"> <div class="panel">
$:render.part_button('GET', '/torrent/add', _('Add torrent'), 'tango/list-add.png') $:render.part_button('GET', '/torrent/add', _('Add torrent'), 'tango/list-add.png')

View File

@ -14,7 +14,7 @@ $else:
$#end $#end
</div> </div>
<div class="panel" id='stats_panel'> <div class="panel" id='refresh_panel'>
<!--<a href='/config'>--> <!--<a href='/config'>-->
$_('Connections') : $stats.num_connections ($stats.max_num_connections) $_('Connections') : $stats.num_connections ($stats.max_num_connections)
@ -26,9 +26,8 @@ $#end
<!--</a>--> <!--</a>-->
<span id=#about>
(<a href='/about'>$_('About')</a>) (<a href='/about'>$_('About')</a>)
</span>
</div> </div>

View File

@ -1,5 +1,5 @@
$def with (column_id, column_name, order, active_up, active_down) $def with (column_id, column_name, order, active_up, active_down)
<th class="torrent_table"> <th>
<a href="/index?sort=$column_id&order=$order"> <a href="/index?sort=$column_id&order=$order">
$column_name\ $column_name\
$if active_up: $if active_up:

View File

@ -1,85 +0,0 @@
$def with (torrent)
<table width="100%"><tr>
<td colspan=3 style="background-color:#999;-moz-border-radius:5px;">
<div class="progress_bar" style="width:$torrent.progress%;
text-align:center;font-weight:bold;">
$torrent.progress %</div>
</td>
</tr><td width=30%%>
<table>
<tr><td class="info_label">$_('Downloaded'):</td>
<td class="info_value">$torrent.calc_total_downloaded</td></tr>
<tr><td class="info_label">$_('Uploaded'):</td>
<td class="info_value">$torrent.calc_total_uploaded</td>
</tr>
<tr><td class="info_label">$_('Seeders'):</td>
<td class="info_value">$torrent.num_seeds ($torrent.total_seeds )</td></tr>
<tr><td class="info_label">$_('Share Ratio'):</td>
<td class="info_value">$("%.3f" % torrent.ratio)</td></tr>
<tr><td class="info_label">$_('Pieces'):</td>
<td class="info_value">$torrent.num_pieces x $fsize(torrent.piece_length) </td>
</tr>
<tr><td class="info_label">&nbsp;</td>
<td class="info_value">&nbsp; </td>
</table>
</td><td width=30%%>
<table>
<tr><td class="info_label">$_('Speed'):</td><td class="info_value">
$fspeed(torrent.download_rate)</td></td></tr>
<tr><td class="info_label">$_('Speed'):</td>
<td class="info_value">$fspeed(torrent.upload_rate)</td></tr>
<tr><td class="info_label">$_('Peers'):</td>
<td class="info_value">$torrent.num_peers ($torrent.total_peers )</td></tr>
<tr><td class="info_label">$_('ETA'):</td>
<td class="info_value">$torrent.eta </td></tr>
<tr><td class="info_label">$_('Availability'):</td>
<td class="info_value">$("%.3f" % torrent.distributed_copies)</td></td></tr>
<tr><td class="info_label">&nbsp;</td>
<td class="info_value">&nbsp; </td>
</tr>
</table>
</td><td width=30%%>
<table>
<tr><td class="info_label">$_('Total Size'):</td>
<td class="info_value">$fspeed(torrent.total_size)</td></tr>
<tr><td class="info_label">$_('# Of Files'):</td>
<td class="info_value">$torrent.num_files</td></tr>
<tr><td class="info_label">$_('Tracker'):</td>
<td class="info_value">$(crop(torrent.tracker, 30))</td></tr>
<tr><td class="info_label">$_('Tracker Status'):</td>
<td class="info_value">$torrent.tracker_status </td></tr>
<tr><td class="info_label">$_('Next Announce'):</td>
<td class="info_value">$torrent.next_announce </td></tr>
<tr><td class="info_label">$_('Queue Position'):</td>
<td class="info_value">$torrent.queue_pos </td>
</tr>
</table>
</table>

View File

@ -1,15 +1,10 @@
$def with (torrent_ids, torrent_list) $def with (torrent)
$:render.header(_("Remove torrent")) $:render.header(_("Remove %s ") % torrent.name)
<div class="panel"> <div class="panel">
<form method="POST" action='/torrent/delete/$torrent_ids'> <form method="POST" action='/torrent/delete/$torrent.id'>
<div id="del_torrent"> <div id="del_torrent">
<h2>$_("Remove torrent")</h2> $(_("Remove %s?") % torrent.name)
<ul>
$for torrent in torrent_list:
<li>$torrent.name</li>
</ul>
<div class="form_row2"> <div class="form_row2">
<span class="form_label2"> <span class="form_label2">
<input type="checkbox" name="torrent_also" class="form_input" checked <input type="checkbox" name="torrent_also" class="form_input" checked

View File

@ -1,23 +1,88 @@
$def with (torrent) $def with (torrent)
$:(render.header(torrent.message + '/' + torrent.name)) $:(render.header(torrent.message + '/' + torrent.name))
<div class="panel"> <div class="panel">
<h3>$_('Details')</h3> <h3>$_('Details')</h3>
<table width="100%"><tr>
<td colspan=3 style="background-color:#999;-moz-border-radius:5px;">
$:render.tab_meta(torrent) <div class="progress_bar" style="width:$torrent.progress%;
text-align:center;font-weight:bold;">
$if (torrent.action == 'start'): $torrent.progress %</div>
$:render.part_button('POST', '/torrent/start/' + str(torrent.id), _('Resume'), 'tango/start.png') </td>
$else: </tr><td width=30%%>
$:render.part_button('POST', '/torrent/stop/' + str(torrent.id), _('Pause'), 'tango/pause.png') <table>
<tr><td class="info_label">$_('Downloaded'):</td>
<td class="info_value">$torrent.calc_total_downloaded</td></tr>
<tr><td class="info_label">$_('Uploaded'):</td>
<td class="info_value">$torrent.calc_total_uploaded</td>
</tr>
<tr><td class="info_label">$_('Seeders'):</td>
<td class="info_value">$torrent.num_seeds ($torrent.total_seeds )</td></tr>
<tr><td class="info_label">$_('Share Ratio'):</td>
<td class="info_value">$("%.3f" % torrent.ratio)</td></tr>
<tr><td class="info_label">$_('Pieces'):</td>
<td class="info_value">$torrent.num_pieces x $fsize(torrent.piece_length) </td>
</tr>
</table>
</td><td width=30%%>
<table>
<tr><td class="info_label">$_('Speed'):</td><td class="info_value">
$fspeed(torrent.download_rate)</td></td></tr>
<tr><td class="info_label">$_('Speed'):</td>
<td class="info_value">$fspeed(torrent.upload_rate)</td></tr>
<tr><td class="info_label">$_('Peers'):</td>
<td class="info_value">$torrent.num_peers ($torrent.total_peers )</td></tr>
<tr><td class="info_label">$_('ETA'):</td>
<td class="info_value">$torrent.eta </td></tr>
<tr><td class="info_label">$_('Availability'):</td>
<td class="info_value">$("%.3f" % torrent.distributed_copies)</td></td></tr>
</table>
</td><td width=30%%>
<table>
<tr><td class="info_label">$_('Total Size'):</td>
<td class="info_value">$fspeed(torrent.total_size)</td></tr>
<tr><td class="info_label">$_('# Of Files'):</td>
<td class="info_value">$torrent.num_files</td></tr>
<tr><td class="info_label">$_('Tracker'):</td>
<td class="info_value">$(crop(torrent.tracker, 30))</td></tr>
<tr><td class="info_label">$_('Tracker Status'):</td>
<td class="info_value">$torrent.tracker_status </td></tr>
<tr><td class="info_label">$_('Next Announce'):</td>
<td class="info_value">$torrent.next_announce </td></tr>
</table>
</table>
<form action="/torrent/pause?redir=/torrent/info/$torrent.id" method="POST"
class="deluge_button">
<input type="image" src="/static/images/$(torrent.calc_state_str)16.png"
name="$torrent.action" value="$torrent.id">
</form>
$:render.part_button('GET', '/torrent/delete/' + str(torrent.id), _('Remove'), 'tango/user-trash.png') $:render.part_button('GET', '/torrent/delete/' + str(torrent.id), _('Remove'), 'tango/user-trash.png')
$:render.part_button('POST', '/torrent/reannounce/' + str(torrent.id), _('Reannounce'), 'tango/view-refresh.png') $:render.part_button('POST', '/torrent/reannounce/' + str(torrent.id), _('Reannounce'), 'tango/view-refresh.png')
$:render.part_button('POST', '/torrent/queue/up/' + str(torrent.id), _('Queue Up'), 'tango/queue-up.png')
$:render.part_button('POST', '/torrent/queue/down/' + str(torrent.id), _('Queue Down'), 'tango/queue-down.png')
<br> <br>
<!-- <!--
[<a onclick="javascript:toggle_dump()">$_('Debug:Data Dump')</a>] [<a onclick="javascript:toggle_dump()">$_('Debug:Data Dump')</a>]
@ -44,6 +109,13 @@ function toggle_dump(){
<div class='panel'>
$_('Queue pos:') $torrent.queue_pos
$:render.part_button('POST', '/torrent/queue/up/' + str(torrent.id), _('Queue Up'), 'tango/up.png')
$:render.part_button('POST', '/torrent/queue/down/' + str(torrent.id), _('Queue Down'), 'tango/down.png')
</div>
$:part_stats() $:part_stats()

View File

@ -3,35 +3,28 @@ Just copy and rename an existing template.
-The settings panel will see all directory's in this folder ,and let you choose your new template. -The settings panel will see all directory's in this folder ,and let you choose your new template.
-Clicking Ok in the settings panel will restart the webserver and reload your template. -Clicking Ok in the settings panel will restart the webserver and reload your template.
Limited "Subclassing":
All templates are "subclassed" from the /deluge/ template.
If a html file is not found in the template dir, the file from /deluge/ will be used.
Notes: Notes:
Please configure your editor to use 4-space indents instead of tabs. Please configure your editor to use 4-space indents instead of tabs.
Or use scite and my config: http://mvoncken.sohosted.com/deluge/SciTEUser.properties.txt Or use scite and my config: http://mvoncken.sohosted.com/deluge/SciTEUser.properties.txt
template language: http://webpy.org/templetor template language: http://webpy.org/templetor
Exposed methods and variables (c&p from webserver_framework.py): Exposed methods and variables (c&p from deluge_webserver):
template.Template.globals.update({
'sort_head': template_sort_head, 'sort_head': template_sort_head,
'part_stats':template_part_stats,
'crop': template_crop, 'crop': template_crop,
'_': _ , #gettext/translations '_': _ , #gettext/translations
'str': str, #because % in templetor is broken. 'str': str, #because % in templetor is broken.
'sorted': sorted, 'sorted': sorted,
'get_config': get_config, 'get_config': proxy.get_webui_config,
'self_url': self_url, 'self_url': web.changequery,
'fspeed': common.fspeed, 'fspeed': common.fspeed,
'fsize': common.fsize, 'fsize': common.fsize,
'render': ws.render, #for easy resuse of templates 'render': render, #for easy resuse of templates
'rev': 'rev.%s' % (REVNO, ), 'button_style': (proxy.get_webui_config('button_style')),
'version': VERSION, 'rev': ('rev.' +
'getcookie':getcookie, open(os.path.join(os.path.dirname(__file__),'revno')).read()),
'get': lambda (var): getattr(web.input(**{var:None}), var) # unreadable :-( 'version': (
}) open(os.path.join(os.path.dirname(__file__),'version')).read())
I will update this file if there is interest in making templates. I will update this file if there is interest in making templates.

View File

@ -9,11 +9,7 @@ import cookielib, urllib2 , urllib
import WebUi.webserver_common as ws import WebUi.webserver_common as ws
import operator import operator
ws.init_05() ws.init_05()
print 'test-env=',ws.ENV
#CONFIG: #CONFIG:
BASE_URL = 'http://localhost:8112' BASE_URL = 'http://localhost:8112'
@ -41,7 +37,6 @@ class TestWebUiBase(unittest.TestCase):
def open_url(self, page, post=None): def open_url(self, page, post=None):
url = BASE_URL + page url = BASE_URL + page
if post == 1: if post == 1:
post = {'Force_a_post' : 'spam'} post = {'Force_a_post' : 'spam'}
if post: if post:
@ -97,10 +92,6 @@ class TestWebUiBase(unittest.TestCase):
else: else:
pass pass
first_torrent_id = property(lambda self: ws.proxy.get_session_state()[0])
first_torrent = property(lambda self: get_status(self.first_torrent_id))
class TestNoAuth(TestWebUiBase): class TestNoAuth(TestWebUiBase):
def test303(self): def test303(self):
self.assert_303('/','/login') self.assert_303('/','/login')
@ -226,12 +217,8 @@ class TestIntegration(TestWebUiBase):
else: else:
#test correctness of existing-list #test correctness of existing-list
#The setup makes 0.6 fail everything, added an else..
for url in self.urls: for url in self.urls:
if ws.ENV.startswith('0.5'): self.assert_500('/torrent/add',{'url':url,'torrent':None})
self.assert_500('/torrent/add',{'url':url,'torrent':None})
else:
self.assert_303('/torrent/add','/index',{'url':url,'torrent':None})
def testPauseResume(self): def testPauseResume(self):
#pause all #pause all
@ -250,12 +237,12 @@ class TestIntegration(TestWebUiBase):
#pause again. #pause again.
self.assert_303('/pause_all','/index', post=1) self.assert_303('/pause_all','/index', post=1)
torrent_id = self.first_torrent_id torrent_id = ws.proxy.get_session_state()[0]
#single resume. #single resume.
self.assert_303('/torrent/start/%s' % torrent_id ,'/index', post=1) self.assert_303('/torrent/pause','/index', post={'start':torrent_id})
self.assertEqual(get_status(torrent_id)["paused"] ,False) self.assertEqual(get_status(torrent_id)["paused"] ,False)
#single pause #single pause
self.assert_303('/torrent/stop/%s' % torrent_id,'/index', post=1) self.assert_303('/torrent/pause','/index', post={'stop':torrent_id})
self.assertEqual(get_status(torrent_id)["paused"] , True) self.assertEqual(get_status(torrent_id)["paused"] , True)
def testQueue(self): def testQueue(self):
@ -310,6 +297,8 @@ class TestIntegration(TestWebUiBase):
#add torrrent-file #add torrrent-file
#./test01.torrent #./test01.torrent
def testReannounce(self):
pass
def test_do_redirect(self): def test_do_redirect(self):
self.assert_303('/home','/index') self.assert_303('/home','/index')
@ -325,16 +314,17 @@ class TestIntegration(TestWebUiBase):
assert self.cookies['order'] == 'up' assert self.cookies['order'] == 'up'
#redir after pause-POST? in /index. #redir after pause-POST? in /index.
self.assert_exists('/index?sort=name&order=down') self.assert_exists('/index?sort=name&order=down')
torrent_id = self.first_torrent_id torrent_id = ws.proxy.get_session_state()[0]
self.assert_303('/torrent/stop/%s' % torrent_id, self.assert_303('/torrent/pause','/index?sort=name&order=down',
'/index?sort=name&order=down', post=1) post={'stop':torrent_id})
#redir in details 1 #redir in details 1
self.assert_303('/torrent/stop/%s?redir=/torrent/info/%s' %(torrent_id,torrent_id) self.assert_303('/torrent/pause?redir=/torrent/info/' + torrent_id
,'/torrent/info/' + torrent_id, post = 1) ,'/torrent/info/' + torrent_id, post = {'stop':torrent_id})
#redir in details 2 #redir in details 2
self.assert_303('/torrent/stop/%s' % torrent_id self.assert_303('/torrent/pause'
,'/torrent/info/' + torrent_id , ,'/torrent/info/' + torrent_id ,
post={'redir': '/torrent/info/' + torrent_id}) post={'stop':torrent_id,
'redir': '/torrent/info/' + torrent_id})
def testRemote(self): def testRemote(self):
pass pass
@ -342,26 +332,6 @@ class TestIntegration(TestWebUiBase):
def test_redir_after_login(self): def test_redir_after_login(self):
pass pass
def testReannounce(self):
torrent_id = self.first_torrent_id
self.assert_303(
'/torrent/reannounce/%(id)s?redir=/torrent/info/%(id)s'
% {'id':torrent_id}
,'/torrent/info/' + torrent_id, post = 1)
def testRecheck(self):
#add test before writing code..
#RELEASE-->disable
"""
torrent_id = self.first_torrent_id
self.assert_303(
'/torrent/recheck/%(id)s?redir=/torrent/info/%(id)s'
% {'id':torrent_id}
,'/torrent/info/' + torrent_id, post = 1)
"""
# #
if False: if False:

View File

@ -1,5 +1,5 @@
revision-id: mvoncken@gmail.com-20070930083408-sv8mo0mi1rbjnfvk revision-id: mvoncken@gmail.com-20070930083408-sv8mo0mi1rbjnfvk
date: 2007-11-21 15:10:08 +0200 date: 2007-11-06 15:10:08 +0200
build-date: 2007-11-21 15:34:50 +0200 build-date: 2007-11-06 15:34:50 +0200
revno: 143 revno: 127
branch-nick: WebUi branch-nick: WebUi

View File

@ -44,8 +44,6 @@ from webpy022 import template
random.seed() random.seed()
path = os.path.dirname(__file__) path = os.path.dirname(__file__)
ENV = 'UNKNOWN'
try: try:
_('translate something') _('translate something')
except: except:
@ -92,7 +90,6 @@ def init_06():
init_process() init_process()
globals()['proxy'] = proxy globals()['proxy'] = proxy
globals()['ENV'] = '0.6'
def init_05(): def init_05():
import dbus import dbus
@ -101,7 +98,6 @@ def init_05():
proxy = bus.get_object("org.deluge_torrent.dbusplugin" proxy = bus.get_object("org.deluge_torrent.dbusplugin"
, "/org/deluge_torrent/DelugeDbusPlugin") , "/org/deluge_torrent/DelugeDbusPlugin")
globals()['proxy'] = proxy globals()['proxy'] = proxy
globals()['ENV'] = '0.5_process'
def init_gtk_05(): def init_gtk_05():
#appy possibly changed config-vars, only called in when runing inside gtk. #appy possibly changed config-vars, only called in when runing inside gtk.
@ -110,16 +106,12 @@ def init_gtk_05():
globals()['config'] = deluge.pref.Preferences(config_file, False) globals()['config'] = deluge.pref.Preferences(config_file, False)
globals()['render'] = subclassed_render(config.get('template'), globals()['render'] = subclassed_render(config.get('template'),
config.get('cache_templates')) config.get('cache_templates'))
globals()['ENV'] = '0.5_gtk'
#hacks to determine environment, TODO: clean up. #hacks to determine environment, TODO: clean up.
if 'env=0.5' in sys.argv: if 'env=0.5' in sys.argv:
init_05() init_05()
elif 'env=0.6' in sys.argv: elif not hasattr(deluge, 'common'):
init_06()
elif hasattr(deluge, 'ui'):
init_06() init_06()
elif not hasattr(deluge,'pref'): elif not hasattr(deluge,'pref'):
init_05() init_05()
@ -136,7 +128,7 @@ TORRENT_KEYS = ['distributed_copies', 'download_payload_rate',
'total_payload_download', 'total_payload_upload', 'total_peers', 'total_payload_download', 'total_payload_upload', 'total_peers',
'total_seeds', 'total_size', 'total_upload', 'total_wanted', 'total_seeds', 'total_size', 'total_upload', 'total_wanted',
'tracker_status', 'upload_payload_rate', 'upload_rate', 'tracker_status', 'upload_payload_rate', 'upload_rate',
'uploaded_memory','tracker','state','queue_pos','user_paused'] 'uploaded_memory','tracker','state','queue_pos']
STATE_MESSAGES = (_("Queued"), STATE_MESSAGES = (_("Queued"),
_("Checking"), _("Checking"),

View File

@ -224,10 +224,8 @@ def get_torrent_status(torrent_id):
else: else:
status.action = "stop" status.action = "stop"
if status.user_paused: if status.paused:
status.message = _("Paused %s%%") % status.progress status.message = _("Paused %s%%") % status.progress
elif status.paused:
status.message = _("Queued %s%%") % status.progress
else: else:
status.message = "%s %i%%" % (ws.STATE_MESSAGES[status.state] status.message = "%s %i%%" % (ws.STATE_MESSAGES[status.state]
, status.progress) , status.progress)
@ -295,7 +293,6 @@ template.Template.globals.update({
'rev': 'rev.%s' % (REVNO, ), 'rev': 'rev.%s' % (REVNO, ),
'version': VERSION, 'version': VERSION,
'getcookie':getcookie, 'getcookie':getcookie,
'js_enabled': lambda : ws.config.get('use_javascript'),
'get': lambda (var): getattr(web.input(**{var:None}), var) # unreadable :-( 'get': lambda (var): getattr(web.input(**{var:None}), var) # unreadable :-(
}) })
#/template-defs #/template-defs
@ -307,12 +304,7 @@ def create_webserver(urls, methods):
func = webapi.wsgifunc(webpyfunc(urls, methods, False)) func = webapi.wsgifunc(webpyfunc(urls, methods, False))
server_address=("0.0.0.0", int(ws.config.get('port'))) server_address=("0.0.0.0", int(ws.config.get('port')))
server = CherryPyWSGIServer(server_address, func, server_name="localhost") server = CherryPyWSGIServer(server_address, func, server_name="localhost")
if ws.config.get('use_https'):
server.ssl_certificate = ws.config.get('ssl_certificate')
server.ssl_private_key = ws.config.get('ssl_private_key')
print "http://%s:%d/" % server_address print "http://%s:%d/" % server_address
return server return server