improve the new style ui class to start the logging

This commit is contained in:
Damien Churchill 2009-04-24 19:07:00 +00:00
parent 972393d9ea
commit c846d584a0
2 changed files with 26 additions and 7 deletions

View File

@ -26,8 +26,6 @@ from optparse import OptionParser, OptionGroup
import deluge.common import deluge.common
import deluge.configmanager import deluge.configmanager
from deluge.log import LOG as log
DEFAULT_PREFS = { DEFAULT_PREFS = {
"default_ui": "gtk" "default_ui": "gtk"
} }
@ -35,7 +33,6 @@ DEFAULT_PREFS = {
class _UI(object): class _UI(object):
def __init__(self, name="gtk"): def __init__(self, name="gtk"):
log.debug("NewUI init...")
self.__name = name self.__name = name
usage="%prog [options] [actions]", usage="%prog [options] [actions]",
@ -69,13 +66,30 @@ class _UI(object):
@property @property
def args(self): def args(self):
return self._args return self.__args
def start(self): def start(self):
(self.__options, self.__args) = self.__parser.parse_args() (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: class UI:
def __init__(self, options, args, ui_args): def __init__(self, options, args, ui_args):
from deluge.log import LOG as log
log.debug("UI init..") log.debug("UI init..")
# Set the config directory # Set the config directory

View File

@ -22,7 +22,6 @@
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
# #
import server
from deluge.ui.ui import _UI, UI from deluge.ui.ui import _UI, UI
from optparse import OptionGroup from optparse import OptionGroup
@ -38,7 +37,7 @@ class Web(_UI):
def __init__(self): def __init__(self):
super(Web, self).__init__("web") super(Web, self).__init__("web")
self.__server = server.DelugeWeb() self.__server = None
group = OptionGroup(self.parser, "Web Options") group = OptionGroup(self.parser, "Web Options")
group.add_option("-p", "--port", dest="port", type="int", group.add_option("-p", "--port", dest="port", type="int",
@ -52,7 +51,13 @@ class Web(_UI):
def start(self): def start(self):
super(Web, self).start() 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() self.server.start()
def start(): def start():