[UI] Use a shared DEFAULT_HOSTS dict in ui/common
Instead of defining a DEFAULT_HOSTS dict for each UI use a shared dict.
This commit is contained in:
parent
d65ebb80c6
commit
5e493f2d3f
|
@ -14,6 +14,7 @@ The ui common module contains methods and classes that are deemed useful for all
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
from hashlib import sha1 as sha
|
from hashlib import sha1 as sha
|
||||||
|
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
@ -30,6 +31,7 @@ log = logging.getLogger(__name__)
|
||||||
# No need to import these, just simply use the `_()` function around a status variable.
|
# No need to import these, just simply use the `_()` function around a status variable.
|
||||||
def _(message):
|
def _(message):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
STATE_TRANSLATION = {
|
STATE_TRANSLATION = {
|
||||||
"All": _("All"),
|
"All": _("All"),
|
||||||
"Active": _("Active"),
|
"Active": _("Active"),
|
||||||
|
@ -50,6 +52,12 @@ TRACKER_STATUS_TRANSLATION = {
|
||||||
}
|
}
|
||||||
del _
|
del _
|
||||||
|
|
||||||
|
DEFAULT_HOST = "127.0.0.1"
|
||||||
|
DEFAULT_PORT = 58846
|
||||||
|
DEFAULT_HOSTS = {
|
||||||
|
"hosts": [(sha(str(time.time())).hexdigest(), DEFAULT_HOST, DEFAULT_PORT, "", "")]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TorrentInfo(object):
|
class TorrentInfo(object):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -16,6 +16,7 @@ from collections import deque
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
|
from deluge.ui import common as uicommon
|
||||||
from deluge.ui.client import Client, client
|
from deluge.ui.client import Client, client
|
||||||
from deluge.ui.console.modes.alltorrents import AllTorrents
|
from deluge.ui.console.modes.alltorrents import AllTorrents
|
||||||
from deluge.ui.console.modes.basemode import BaseMode
|
from deluge.ui.console.modes.basemode import BaseMode
|
||||||
|
@ -29,13 +30,6 @@ except ImportError:
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_HOST = "127.0.0.1"
|
|
||||||
DEFAULT_PORT = 58846
|
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
|
||||||
"hosts": [(hashlib.sha1(str(time.time())).hexdigest(), DEFAULT_HOST, DEFAULT_PORT, "", "")]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ConnectionManager(BaseMode):
|
class ConnectionManager(BaseMode):
|
||||||
|
|
||||||
|
@ -43,7 +37,7 @@ class ConnectionManager(BaseMode):
|
||||||
self.popup = None
|
self.popup = None
|
||||||
self.statuses = {}
|
self.statuses = {}
|
||||||
self.messages = deque()
|
self.messages = deque()
|
||||||
self.config = ConfigManager("hostlist.conf.1.2", DEFAULT_CONFIG)
|
self.config = ConfigManager("hostlist.conf.1.2", uicommon.DEFAULT_HOSTS)
|
||||||
BaseMode.__init__(self, stdscr, encoding)
|
BaseMode.__init__(self, stdscr, encoding)
|
||||||
self.__update_statuses()
|
self.__update_statuses()
|
||||||
self.__update_popup()
|
self.__update_popup()
|
||||||
|
|
|
@ -253,13 +253,7 @@ class JSON(resource.Resource, component.Component):
|
||||||
log.debug("Registering method: %s", name + "." + d)
|
log.debug("Registering method: %s", name + "." + d)
|
||||||
self._local_methods[name + "." + d] = getattr(obj, d)
|
self._local_methods[name + "." + d] = getattr(obj, d)
|
||||||
|
|
||||||
DEFAULT_HOST = "127.0.0.1"
|
|
||||||
DEFAULT_PORT = 58846
|
|
||||||
|
|
||||||
DEFAULT_HOSTS = {
|
|
||||||
"hosts": [(hashlib.sha1(str(time.time())).hexdigest(),
|
|
||||||
DEFAULT_HOST, DEFAULT_PORT, "", "")]
|
|
||||||
}
|
|
||||||
HOSTLIST_ID = 0
|
HOSTLIST_ID = 0
|
||||||
HOSTLIST_NAME = 1
|
HOSTLIST_NAME = 1
|
||||||
HOSTLIST_PORT = 2
|
HOSTLIST_PORT = 2
|
||||||
|
@ -368,7 +362,7 @@ class WebApi(JSONComponent):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(WebApi, self).__init__("Web", depend=["SessionProxy"])
|
super(WebApi, self).__init__("Web", depend=["SessionProxy"])
|
||||||
self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS)
|
self.host_list = ConfigManager("hostlist.conf.1.2", uicommon.DEFAULT_HOSTS)
|
||||||
if not os.path.isfile(self.host_list.config_file):
|
if not os.path.isfile(self.host_list.config_file):
|
||||||
self.host_list.save()
|
self.host_list.save()
|
||||||
self.core_config = CoreConfig()
|
self.core_config = CoreConfig()
|
||||||
|
|
Loading…
Reference in New Issue