improve the new style ui class to start the logging
This commit is contained in:
parent
972393d9ea
commit
c846d584a0
|
@ -26,8 +26,6 @@ from optparse import OptionParser, OptionGroup
|
|||
import deluge.common
|
||||
import deluge.configmanager
|
||||
|
||||
from deluge.log import LOG as log
|
||||
|
||||
DEFAULT_PREFS = {
|
||||
"default_ui": "gtk"
|
||||
}
|
||||
|
@ -35,7 +33,6 @@ DEFAULT_PREFS = {
|
|||
class _UI(object):
|
||||
|
||||
def __init__(self, name="gtk"):
|
||||
log.debug("NewUI init...")
|
||||
self.__name = name
|
||||
|
||||
usage="%prog [options] [actions]",
|
||||
|
@ -69,13 +66,30 @@ class _UI(object):
|
|||
|
||||
@property
|
||||
def args(self):
|
||||
return self._args
|
||||
return self.__args
|
||||
|
||||
def start(self):
|
||||
(self.__options, self.__args) = self.__parser.parse_args()
|
||||
if self.options.quiet:
|
||||
self.options.loglevel = "none"
|
||||
|
||||
# Setup the logger
|
||||
import deluge.log
|
||||
deluge.log.setupLogger(
|
||||
level=self.options.loglevel,
|
||||
filename=self.options.logfile
|
||||
)
|
||||
|
||||
import deluge.common
|
||||
log = deluge.log.LOG
|
||||
log.info('Deluge %s ui %s', self.name, deluge.common.get_version())
|
||||
log.debug('options: %s', self.options)
|
||||
log.debug('args: %s', self.args)
|
||||
log.info('Starting ui...')
|
||||
|
||||
class UI:
|
||||
def __init__(self, options, args, ui_args):
|
||||
from deluge.log import LOG as log
|
||||
log.debug("UI init..")
|
||||
|
||||
# Set the config directory
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import server
|
||||
from deluge.ui.ui import _UI, UI
|
||||
from optparse import OptionGroup
|
||||
|
||||
|
@ -38,7 +37,7 @@ class Web(_UI):
|
|||
|
||||
def __init__(self):
|
||||
super(Web, self).__init__("web")
|
||||
self.__server = server.DelugeWeb()
|
||||
self.__server = None
|
||||
|
||||
group = OptionGroup(self.parser, "Web Options")
|
||||
group.add_option("-p", "--port", dest="port", type="int",
|
||||
|
@ -52,7 +51,13 @@ class Web(_UI):
|
|||
|
||||
def start(self):
|
||||
super(Web, self).start()
|
||||
if self.options.port: self.server.port = self.options.port
|
||||
|
||||
import server
|
||||
self.__server = server.DelugeWeb()
|
||||
|
||||
if self.options.port:
|
||||
self.server.port = self.options.port
|
||||
|
||||
self.server.start()
|
||||
|
||||
def start():
|
||||
|
|
Loading…
Reference in New Issue