Beispiel #1
0
    def start(self):
        (self.__options, self.__args) = self.__parser.parse_args()

        if self.__options.quiet:
            self.__options.loglevel = "none"

        if self.__options.loglevel:
            self.__options.loglevel = self.__options.loglevel.lower()

        # Setup the logger
        deluge.log.setupLogger(level=self.__options.loglevel,
                               filename=self.__options.logfile)
        log = deluge.log.LOG

        if self.__options.config:
            if not deluge.configmanager.set_config_dir(self.__options.config):
                log.error(
                    "There was an error setting the config dir! Exiting..")
                sys.exit(1)

        setproctitle("deluge-%s" % self.__name)

        log.info("Deluge ui %s", deluge.common.get_version())
        log.debug("options: %s", self.__options)
        log.debug("args: %s", self.__args)
        log.info("Starting %s ui..", self.__name)
Beispiel #2
0
    def start(self):
        (self.__options, self.__args) = self.__parser.parse_args()

        if self.__options.quiet:
            self.__options.loglevel = "none"

        logfile_mode = 'w'
        if self.__options.rotate_logs:
            logfile_mode = 'a'

        # Setup the logger
        # Setup the logger
        deluge.log.setupLogger(level=self.__options.loglevel,
                               filename=self.__options.logfile,
                               filemode=logfile_mode)

        log = logging.getLogger(__name__)

        if self.__options.config:
            if not deluge.configmanager.set_config_dir(self.__options.config):
                log.error("There was an error setting the config dir! Exiting..")
                sys.exit(1)

        log.info("Deluge ui %s", deluge.common.get_version())
        log.debug("options: %s", self.__options)
        log.debug("args: %s", self.__args)
        log.info("Starting ui..")
Beispiel #3
0
    def start(self):
        # Make sure all arguments are unicode
        argv = deluge.common.unicode_argv()[1:]
        (self.__options, self.__args) = self.__parser.parse_args(argv)

        if self.__options.quiet:
            self.__options.loglevel = "none"

        logfile_mode = 'w'
        if self.__options.rotate_logs:
            logfile_mode = 'a'

        if self.__options.loglevel:
            self.__options.loglevel = self.__options.loglevel.lower()

        # Setup the logger
        deluge.log.setupLogger(level=self.__options.loglevel,
                               filename=self.__options.logfile,
                               filemode=logfile_mode)

        log = logging.getLogger(__name__)

        if self.__options.config:
            if not deluge.configmanager.set_config_dir(self.__options.config):
                log.error(
                    "There was an error setting the config dir! Exiting..")
                sys.exit(1)

        setproctitle("deluge-%s" % self.__name)

        log.info("Deluge ui %s", deluge.common.get_version())
        log.debug("options: %s", self.__options)
        log.debug("args: %s", self.__args)
        log.info("Starting %s ui..", self.__name)
Beispiel #4
0
    def start(self):
        # Make sure all arguments are unicode
        argv = deluge.common.unicode_argv()[1:]
        (self.__options, self.__args) = self.__parser.parse_args(argv)

        if self.__options.quiet:
            self.__options.loglevel = "none"

        logfile_mode = 'w'
        if self.__options.rotate_logs:
            logfile_mode = 'a'

        if self.__options.loglevel:
            self.__options.loglevel = self.__options.loglevel.lower()

        # Setup the logger
        deluge.log.setupLogger(level=self.__options.loglevel,
                               filename=self.__options.logfile,
                               filemode=logfile_mode)

        log = logging.getLogger(__name__)

        if self.__options.config:
            if not deluge.configmanager.set_config_dir(self.__options.config):
                log.error("There was an error setting the config dir! Exiting..")
                sys.exit(1)

        setproctitle("deluge-%s" % self.__name)

        log.info("Deluge ui %s", deluge.common.get_version())
        log.debug("options: %s", self.__options)
        log.debug("args: %s", self.__args)
        log.info("Starting %s ui..", self.__name)
Beispiel #5
0
    def start(self):
        if deluge.common.windows_check():
            (self.__options, self.__args) = self.__parser.parse_args(deluge.common.win32_unicode_argv()[1:])
        else:
            (self.__options, self.__args) = self.__parser.parse_args()

        if self.__options.quiet:
            self.__options.loglevel = "none"

        if self.__options.loglevel:
            self.__options.loglevel = self.__options.loglevel.lower()

        # Setup the logger
        deluge.log.setupLogger(level=self.__options.loglevel, filename=self.__options.logfile)
        log = deluge.log.LOG

        if self.__options.config:
            if not deluge.configmanager.set_config_dir(self.__options.config):
                log.error("There was an error setting the config dir! Exiting..")
                sys.exit(1)

        setproctitle("deluge-%s" % self.__name)

        log.info("Deluge ui %s", deluge.common.get_version())
        log.debug("options: %s", self.__options)
        log.debug("args: %s", self.__args)
        log.info("Starting %s ui..", self.__name)
Beispiel #6
0
    def start(self):
        (self.__options, self.__args) = self.__parser.parse_args()

        if self.__options.quiet:
            self.__options.loglevel = "none"

        logfile_mode = 'w'
        if self.__options.rotate_logs:
            logfile_mode = 'a'

        # Setup the logger
        # Setup the logger
        deluge.log.setupLogger(level=self.__options.loglevel,
                               filename=self.__options.logfile,
                               filemode=logfile_mode)

        deluge.common.setup_translations()

        log = logging.getLogger(__name__)

        if self.__options.config:
            if not deluge.configmanager.set_config_dir(self.__options.config):
                log.error(
                    "There was an error setting the config dir! Exiting..")
                sys.exit(1)

        log.info("Deluge ui %s", deluge.common.get_version())
        log.debug("options: %s", self.__options)
        log.debug("args: %s", self.__args)
        log.info("Starting ui..")
Beispiel #7
0
    def start(self, parser=None):
        args = deluge.common.unicode_argv()[1:]
        if parser is None:
            parser = self.parser
        self.__options = self.parse_args(parser, args)

        setproctitle('deluge-%s' % self.__name)

        log.info('Deluge ui %s', deluge.common.get_version())
        log.debug('options: %s', self.__options)
        log.info('Starting %s ui..', self.__name)
Beispiel #8
0
    def set_config_dir(self, directory):
        """
        Sets the config directory.

        :param directory: str, the directory where the config info should be

        :returns bool: True if successfully changed directory, False if not
        """

        if not directory:
            return False

        # Ensure absolute dirpath
        directory = os.path.abspath(directory)

        log.info('Setting config directory to: %s', directory)
        if not os.path.exists(directory):
            # Try to create the config folder if it doesn't exist
            try:
                os.makedirs(directory)
            except OSError as ex:
                log.error('Unable to make config directory: %s', ex)
                return False
        elif not os.path.isdir(directory):
            log.error('Config directory needs to be a directory!')
            return False

        self.__config_directory = directory

        # Reset the config_files so we don't get config from old config folder
        # XXX: Probably should have it go through the config_files dict and try
        # to reload based on the new config directory
        self.save()
        self.config_files = {}
        deluge.log.tweak_logging_levels()

        return True
Beispiel #9
0
    def set_config_dir(self, directory):
        """
        Sets the config directory.

        :param directory: str, the directory where the config info should be

        :returns bool: True if successfully changed directory, False if not
        """

        if not directory:
            return False

        # Ensure absolute dirpath
        directory = os.path.abspath(directory)

        log.info('Setting config directory to: %s', directory)
        if not os.path.exists(directory):
            # Try to create the config folder if it doesn't exist
            try:
                os.makedirs(directory)
            except OSError as ex:
                log.error('Unable to make config directory: %s', ex)
                return False
        elif not os.path.isdir(directory):
            log.error('Config directory needs to be a directory!')
            return False

        self.__config_directory = directory

        # Reset the config_files so we don't get config from old config folder
        # XXX: Probably should have it go through the config_files dict and try
        # to reload based on the new config directory
        self.save()
        self.config_files = {}
        deluge.log.tweak_logging_levels()

        return True
Beispiel #10
0
    def __init__(self, options, args, ui_args):
        from deluge.log import LOG as log

        log.debug("UI init..")

        # Set the config directory
        deluge.configmanager.set_config_dir(options.config)

        config = deluge.configmanager.ConfigManager("ui.conf", DEFAULT_PREFS)

        if not options.ui:
            selected_ui = config["default_ui"]
        else:
            selected_ui = options.ui

        setproctitle("deluge")

        config.save()
        del config

        try:
            if selected_ui == "gtk":
                log.info("Starting GtkUI..")
                from deluge.ui.gtkui.gtkui import GtkUI

                ui = GtkUI(args)
            elif selected_ui == "web":
                log.info("Starting WebUI..")
                from deluge.ui.web.web import WebUI

                ui = WebUI(args)
            elif selected_ui == "console":
                log.info("Starting ConsoleUI..")
                from deluge.ui.console.main import ConsoleUI

                ui = ConsoleUI(ui_args)
        except ImportError, e:
            import sys
            import traceback

            error_type, error_value, tb = sys.exc_info()
            stack = traceback.extract_tb(tb)
            last_frame = stack[-1]
            if last_frame[0] == __file__:
                log.error(
                    "Unable to find the requested UI: %s.  Please select a different UI with the '-u' option or alternatively use the '-s' option to select a different default UI.",
                    selected_ui,
                )
            else:
                log.exception(e)
                log.error("There was an error whilst launching the request UI: %s", selected_ui)
                log.error("Look at the traceback above for more information.")
            sys.exit(1)
Beispiel #11
0
    def __init__(self, options, args, ui_args):
        import logging
        log = logging.getLogger(__name__)
        log.debug("UI init..")

        # Set the config directory
        deluge.configmanager.set_config_dir(options.config)

        config = deluge.configmanager.ConfigManager("ui.conf", DEFAULT_PREFS)

        if not options.ui:
            selected_ui = config["default_ui"]
        else:
            selected_ui = options.ui

        setproctitle("deluge")

        config.save()
        del config

        try:
            if selected_ui == "gtk":
                log.info("Starting GtkUI..")
                from deluge.ui.gtkui.gtkui import GtkUI
                ui = GtkUI(args)
            elif selected_ui == "web":
                log.info("Starting WebUI..")
                from deluge.ui.web.web import WebUI
                ui = WebUI(args)
            elif selected_ui == "console":
                log.info("Starting ConsoleUI..")
                from deluge.ui.console.main import ConsoleUI
                ui = ConsoleUI(ui_args)
        except ImportError, e:
            import sys
            import traceback
            error_type, error_value, tb = sys.exc_info()
            stack = traceback.extract_tb(tb)
            last_frame = stack[-1]
            if last_frame[0] == __file__:
                log.error(
                    "Unable to find the requested UI: %s.  Please select a different UI with the '-u' option or alternatively use the '-s' option to select a different default UI.",
                    selected_ui)
            else:
                log.exception(e)
                log.error(
                    "There was an error whilst launching the request UI: %s",
                    selected_ui)
                log.error("Look at the traceback above for more information.")
            sys.exit(1)
Beispiel #12
0
    if options.default_ui:
        import deluge.configmanager
        if options.config:
            deluge.configmanager.set_config_dir(options.config)

        config = deluge.configmanager.ConfigManager("ui.conf")
        config["default_ui"] = options.default_ui
        config.save()
        print "The default UI has been changed to", options.default_ui
        sys.exit(0)

    version = deluge.common.get_version()

    import logging
    log = logging.getLogger(__name__)
    log.info("Deluge ui %s", version)
    log.debug("options: %s", options)
    log.debug("args: %s", args)
    log.debug("ui_args: %s", args)

    from deluge.ui.ui import UI
    log.info("Starting ui..")
    UI(options, args, options.args)

def start_daemon():
    """Entry point for daemon script"""
    import deluge.common
    deluge.common.setup_translations()

    if 'dev' not in deluge.common.get_version():
        import warnings
Beispiel #13
0
    if options.default_ui:
        import deluge.configmanager
        if options.config:
            deluge.configmanager.set_config_dir(options.config)

        config = deluge.configmanager.ConfigManager("ui.conf")
        config["default_ui"] = options.default_ui
        config.save()
        print "The default UI has been changed to", options.default_ui
        sys.exit(0)

    version = deluge.common.get_version()

    import logging
    log = logging.getLogger(__name__)
    log.info("Deluge ui %s", version)
    log.debug("options: %s", options)
    log.debug("args: %s", args)
    log.debug("ui_args: %s", args)

    from deluge.ui.ui import UI
    log.info("Starting ui..")
    UI(options, args, options.args)

def start_daemon():
    """Entry point for daemon script"""
    import deluge.common

    if 'dev' not in deluge.common.get_version():
        import warnings
        warnings.filterwarnings('ignore', category=DeprecationWarning, module='twisted')