mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
add the improvements to the export deco
This commit is contained in:
parent
11e42db767
commit
fc68ec2929
1 changed files with 15 additions and 9 deletions
|
@ -29,6 +29,7 @@ import hashlib
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from types import FunctionType
|
||||||
from twisted.internet.defer import Deferred
|
from twisted.internet.defer import Deferred
|
||||||
from twisted.web import http, resource, server
|
from twisted.web import http, resource, server
|
||||||
|
|
||||||
|
@ -56,6 +57,11 @@ def export(auth_level=AUTH_LEVEL_DEFAULT):
|
||||||
func._json_auth_level = auth_level
|
func._json_auth_level = auth_level
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
if type(auth_level) is FunctionType:
|
||||||
|
func = auth_level
|
||||||
|
auth_level = AUTH_LEVEL_DEFAULT
|
||||||
|
return wrap(func)
|
||||||
|
else:
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
class JSONException(Exception):
|
class JSONException(Exception):
|
||||||
|
@ -252,7 +258,7 @@ class WebApi(JSONComponent):
|
||||||
super(WebApi, self).__init__("Web")
|
super(WebApi, self).__init__("Web")
|
||||||
self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS)
|
self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS)
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def connect(self, host_id):
|
def connect(self, host_id):
|
||||||
d = Deferred()
|
d = Deferred()
|
||||||
def on_connected(methods):
|
def on_connected(methods):
|
||||||
|
@ -263,13 +269,13 @@ class WebApi(JSONComponent):
|
||||||
self._json.connect(*host[1:]).addCallback(on_connected)
|
self._json.connect(*host[1:]).addCallback(on_connected)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def connected(self):
|
def connected(self):
|
||||||
d = Deferred()
|
d = Deferred()
|
||||||
d.callback(client.connected())
|
d.callback(client.connected())
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def update_ui(self, keys, filter_dict):
|
def update_ui(self, keys, filter_dict):
|
||||||
|
|
||||||
ui_info = {
|
ui_info = {
|
||||||
|
@ -294,7 +300,7 @@ class WebApi(JSONComponent):
|
||||||
client.core.get_torrents_status(filter_dict, keys).addCallback(got_torrents)
|
client.core.get_torrents_status(filter_dict, keys).addCallback(got_torrents)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def download_torrent_from_url(self, url):
|
def download_torrent_from_url(self, url):
|
||||||
"""
|
"""
|
||||||
input:
|
input:
|
||||||
|
@ -310,7 +316,7 @@ class WebApi(JSONComponent):
|
||||||
d.callback(filename)
|
d.callback(filename)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def get_torrent_info(self, filename):
|
def get_torrent_info(self, filename):
|
||||||
"""
|
"""
|
||||||
Goal:
|
Goal:
|
||||||
|
@ -332,7 +338,7 @@ class WebApi(JSONComponent):
|
||||||
d.callback(uicommon.get_torrent_info(filename.strip()))
|
d.callback(uicommon.get_torrent_info(filename.strip()))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def add_torrents(self, torrents):
|
def add_torrents(self, torrents):
|
||||||
"""
|
"""
|
||||||
input:
|
input:
|
||||||
|
@ -349,7 +355,7 @@ class WebApi(JSONComponent):
|
||||||
d.callback(True)
|
d.callback(True)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def login(self, password):
|
def login(self, password):
|
||||||
"""Method to allow the webui to authenticate
|
"""Method to allow the webui to authenticate
|
||||||
"""
|
"""
|
||||||
|
@ -361,7 +367,7 @@ class WebApi(JSONComponent):
|
||||||
d.callback(m.hexdigest() == config['pwd_md5'])
|
d.callback(m.hexdigest() == config['pwd_md5'])
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export()
|
@export
|
||||||
def get_hosts(self):
|
def get_hosts(self):
|
||||||
"""Return the hosts in the hostlist"""
|
"""Return the hosts in the hostlist"""
|
||||||
hosts = dict((host[0], host[:]) for host in self.host_list["hosts"])
|
hosts = dict((host[0], host[:]) for host in self.host_list["hosts"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue