Add some more stuff to the new ui class
This commit is contained in:
parent
c754fc7c74
commit
65583cfe12
|
@ -25,6 +25,8 @@
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
import deluge.log
|
||||||
|
import os
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"default_ui": "gtk"
|
"default_ui": "gtk"
|
||||||
|
@ -44,8 +46,6 @@ class _UI(object):
|
||||||
help="Set the config folder location", action="store", type="str")
|
help="Set the config folder location", action="store", type="str")
|
||||||
group.add_option("-l", "--logfile", dest="logfile",
|
group.add_option("-l", "--logfile", dest="logfile",
|
||||||
help="Output to designated logfile instead of stdout", action="store", type="str")
|
help="Output to designated logfile instead of stdout", action="store", type="str")
|
||||||
group.add_option("-a", "--args", dest="args",
|
|
||||||
help="Arguments to pass to UI, -a '--option args'", action="store", type="str")
|
|
||||||
group.add_option("-L", "--loglevel", dest="loglevel",
|
group.add_option("-L", "--loglevel", dest="loglevel",
|
||||||
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
||||||
group.add_option("-q", "--quiet", dest="quiet",
|
group.add_option("-q", "--quiet", dest="quiet",
|
||||||
|
@ -70,22 +70,36 @@ class _UI(object):
|
||||||
|
|
||||||
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"
|
|
||||||
|
if self.__options.quiet:
|
||||||
|
self.__options.loglevel = "none"
|
||||||
|
|
||||||
|
if self.__options.config:
|
||||||
|
if not os.path.isdir(self.__options.config):
|
||||||
|
print "Config option needs to be a directory!"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not os.path.exists(self.__options.config):
|
||||||
|
# Try to create the config folder if it doesn't exist
|
||||||
|
try:
|
||||||
|
os.makedirs(self.__options.config)
|
||||||
|
except Exception, e:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if not os.path.exists(deluge.common.get_default_config_dir()):
|
||||||
|
os.makedirs(deluge.common.get_default_config_dir())
|
||||||
|
|
||||||
# Setup the logger
|
# Setup the logger
|
||||||
import deluge.log
|
deluge.log.setupLogger(level=self.__options.loglevel, filename=self.__options.logfile)
|
||||||
deluge.log.setupLogger(
|
|
||||||
level=self.options.loglevel,
|
version = deluge.common.get_version()
|
||||||
filename=self.options.logfile
|
|
||||||
)
|
|
||||||
|
|
||||||
import deluge.common
|
|
||||||
log = deluge.log.LOG
|
log = deluge.log.LOG
|
||||||
log.info('Deluge %s ui %s', self.name, deluge.common.get_version())
|
log.info("Deluge ui %s", version)
|
||||||
log.debug('options: %s', self.options)
|
log.debug("options: %s", self.__options)
|
||||||
log.debug('args: %s', self.args)
|
log.debug("args: %s", self.__args)
|
||||||
log.info('Starting ui...')
|
log.info("Starting ui..")
|
||||||
|
|
||||||
class UI:
|
class UI:
|
||||||
def __init__(self, options, args, ui_args):
|
def __init__(self, options, args, ui_args):
|
||||||
|
|
Loading…
Reference in New Issue