queue+add logging
This commit is contained in:
parent
3d76649b78
commit
35446801c6
|
@ -125,8 +125,13 @@ config.register_block('deluge','daemon', Daemon)
|
|||
|
||||
class Plugins(forms.Form):
|
||||
title = _("Enabled Plugins")
|
||||
try:
|
||||
_choices = [(p,p) for p in ws.proxy.get_available_plugins()]
|
||||
enabled_plugins = forms.MultipleChoice(_(""), _choices)
|
||||
except:
|
||||
ws.log.error("Not connected to daemon, Unable to load plugin-list")
|
||||
#TODO: reload on reconnect!
|
||||
|
||||
|
||||
def initial_data(self):
|
||||
return {'enabled_plugins':ws.proxy.get_enabled_plugins()}
|
||||
|
|
|
@ -84,6 +84,7 @@ urls = (
|
|||
"/home", "home",
|
||||
"/about", "about",
|
||||
"/logout", "logout",
|
||||
"/connect","connect",
|
||||
#remote-api:
|
||||
"/remote/torrent/add(.*)", "remote_torrent_add",
|
||||
"/json/(.*)","json_api",
|
||||
|
@ -173,6 +174,7 @@ class torrent_info_inner:
|
|||
|
||||
#next 4 classes: a pattern is emerging here.
|
||||
#todo: DRY (in less lines of code)
|
||||
#deco.deluge_command, or a subclass?
|
||||
class torrent_start:
|
||||
@deco.check_session
|
||||
@deco.torrent_ids
|
||||
|
@ -226,7 +228,7 @@ class torrent_queue_up:
|
|||
torrent_list.sort(lambda x, y : x.queue - y.queue)
|
||||
torrent_ids = [t.id for t in torrent_list]
|
||||
for torrent_id in torrent_ids:
|
||||
ws.proxy.queue_queue_up(torrent_id)
|
||||
ws.async_proxy.get_core().call("queue_queue_up", None, torrent_id)
|
||||
do_redirect()
|
||||
|
||||
class torrent_queue_down:
|
||||
|
@ -237,7 +239,7 @@ class torrent_queue_down:
|
|||
torrent_list.sort(lambda x, y : x.queue - y.queue)
|
||||
torrent_ids = [t.id for t in torrent_list]
|
||||
for torrent_id in reversed(torrent_ids):
|
||||
ws.proxy.queue_queue_down(torrent_id)
|
||||
ws.async_proxy.get_core().call("queue_queue_down", None, torrent_id)
|
||||
do_redirect()
|
||||
|
||||
class torrent_files:
|
||||
|
@ -309,12 +311,35 @@ class logout:
|
|||
def GET(self):
|
||||
return self.POST()
|
||||
#WRONG, but makes it easyer to link with <a href> in the status-bar
|
||||
|
||||
@deco.check_session
|
||||
def POST(self, name):
|
||||
end_session()
|
||||
seeother('/login')
|
||||
|
||||
class connect:
|
||||
@deco.deluge_page
|
||||
def GET(self, name):
|
||||
#if ws.proxy.connected():
|
||||
# error = _("Not Connected to a daemon")
|
||||
#else:
|
||||
error = None
|
||||
connect_list = ["http://localhost:58846"]
|
||||
return render.connect(connect_list, error)
|
||||
|
||||
def POST(self):
|
||||
vars = web.input(uri = None, other_uri = None)
|
||||
uri = ''
|
||||
if vars.uri == 'other_uri':
|
||||
if not vars.other:
|
||||
return error_page(_("no uri"))
|
||||
url = vars.other
|
||||
else:
|
||||
uri = vars.uri
|
||||
#TODO: more error-handling
|
||||
ws.init_06(uri)
|
||||
do_redirect()
|
||||
|
||||
|
||||
#other stuff:
|
||||
class remote_torrent_add:
|
||||
"""
|
||||
|
|
|
@ -24,7 +24,7 @@ $for torrent in torrent_list:
|
|||
<input type="image"
|
||||
src="/static/images/$(torrent.calc_state_str)16.png"
|
||||
name="pauseresume" value="submit" /></form></td>
|
||||
<td>$torrent.queue_pos</td>
|
||||
<td>$torrent.queue</td>
|
||||
<td style="width:100px; overflow:hidden;white-space: nowrap">
|
||||
<a href="/torrent/info/$torrent.id" >
|
||||
$(crop(torrent.name, 40))</a></td>
|
||||
|
|
|
@ -55,7 +55,9 @@ class OptionsForm(forms.Form):
|
|||
default_private = forms.CheckBox(_('Set Private Flag'))
|
||||
|
||||
def initial_data(self):
|
||||
return ws.proxy.get_config()
|
||||
data = ws.proxy.get_config()
|
||||
ws.log.debug("add:Init options with:%s" % data)
|
||||
return data
|
||||
|
||||
class AddForm(forms.Form):
|
||||
url = forms.CharField(label=_("Url"), required=False,
|
||||
|
@ -71,7 +73,7 @@ class torrent_add:
|
|||
|
||||
def add_page(self,error = None):
|
||||
#form_data = utils.get_newforms_data(AddForm)
|
||||
|
||||
ws.log.debug("add-page")
|
||||
#TODO: CLEANUP!!!
|
||||
vars = web.input(url = None)
|
||||
form_data = {'url':vars.url}
|
||||
|
@ -79,6 +81,7 @@ class torrent_add:
|
|||
options_data = None
|
||||
if error:
|
||||
options_data = utils.get_newforms_data(OptionsForm)
|
||||
ws.log.debug("add:(error-state):Init options with:%s" % options_data)
|
||||
return render.torrent_add(AddForm(form_data),OptionsForm(options_data), error)
|
||||
|
||||
@deco.deluge_page
|
||||
|
@ -92,7 +95,6 @@ class torrent_add:
|
|||
allows:
|
||||
*posting of url
|
||||
*posting file-upload
|
||||
*posting of data as string(for greasemonkey-private)
|
||||
"""
|
||||
|
||||
options_form = OptionsForm(utils.get_newforms_data(OptionsForm))
|
||||
|
@ -115,11 +117,13 @@ class torrent_add:
|
|||
return
|
||||
if vars.url:
|
||||
ws.proxy.add_torrent_url(vars.url,options)
|
||||
ws.log.debug("add-url:options :%s" % options)
|
||||
utils.do_redirect()
|
||||
elif torrent_name:
|
||||
data_b64 = base64.b64encode(torrent_data)
|
||||
#b64 because of strange bug-reports related to binary data
|
||||
ws.proxy.add_torrent_filecontent(vars.torrent.filename, data_b64, options)
|
||||
ws.log.debug("add-file:options :%s" % options)
|
||||
utils.do_redirect()
|
||||
else:
|
||||
print self.add_page(error = _("No data"))
|
||||
|
|
|
@ -127,7 +127,7 @@ def get_stats():
|
|||
|
||||
ws.async_proxy.force_call(block=True)
|
||||
|
||||
ws.log.debug(str(stats))
|
||||
#ws.log.debug(str(stats))
|
||||
|
||||
stats.download_rate = fspeed(stats.download_rate)
|
||||
stats.upload_rate = fspeed(stats.upload_rate)
|
||||
|
@ -157,10 +157,10 @@ def enhance_torrent_status(torrent_id,status):
|
|||
for key in TORRENT_KEYS:
|
||||
if not key in status:
|
||||
status[key] = 0
|
||||
ws.log.warning('torrent_status:empty key in status:%s' % key)
|
||||
#ws.log.warning('torrent_status:empty key in status:%s' % key)
|
||||
elif status[key] == None:
|
||||
status[key] = 0
|
||||
ws.log.warning('torrent_status:None key in status:%s' % key)
|
||||
#ws.log.warning('torrent_status:None key in status:%s' % key)
|
||||
|
||||
|
||||
if status.tracker == 0:
|
||||
|
|
Loading…
Reference in New Issue