Ejemplo n.º 1
0
def main():
    signal.signal(signal.SIGTERM, process.exit_handler)
    signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)

    loop = gobject.MainLoop()
    options = parse_options()

    try:
        log.setup_logging(options.verbosity_level, options.save_debug_log)
        check_old_folders()
        setup_settings(options.interactive)
        audio = setup_audio()
        backends = setup_backends(audio)
        core = setup_core(audio, backends)
        setup_frontends(core)
        loop.run()
    except exceptions.SettingsError as ex:
        logger.error(ex.message)
    except KeyboardInterrupt:
        logger.info('Interrupted. Exiting...')
    except Exception as ex:
        logger.exception(ex)
    finally:
        loop.quit()
        stop_frontends()
        stop_core()
        stop_backends()
        stop_audio()
        process.stop_remaining_actors()
Ejemplo n.º 2
0
def main():
    signal.signal(signal.SIGTERM, process.exit_handler)
    signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)

    args = commands.parser.parse_args(args=mopidy_args)
    if args.show_config:
        commands.show_config(args)
    if args.show_deps:
        commands.show_deps()

    # TODO: figure out a way to make the boilerplate in this file reusable in
    # scanner and other places we need it.

    try:
        # Initial config without extensions to bootstrap logging.
        logging_initialized = False
        logging_config, _ = config_lib.load(args.config_files, [],
                                            args.config_overrides)

        # TODO: setup_logging needs defaults in-case config values are None
        log.setup_logging(logging_config, args.verbosity_level,
                          args.save_debug_log)
        logging_initialized = True

        create_file_structures()
        check_old_locations()

        installed_extensions = ext.load_extensions()

        config, config_errors = config_lib.load(args.config_files,
                                                installed_extensions,
                                                args.config_overrides)

        # Filter out disabled extensions and remove any config errors for them.
        enabled_extensions = []
        for extension in installed_extensions:
            enabled = config[extension.ext_name]['enabled']
            if ext.validate_extension(extension) and enabled:
                enabled_extensions.append(extension)
            elif extension.ext_name in config_errors:
                del config_errors[extension.ext_name]

        log_extension_info(installed_extensions, enabled_extensions)
        check_config_errors(config_errors)

        # Read-only config from here on, please.
        proxied_config = config_lib.Proxy(config)

        log.setup_log_levels(proxied_config)
        ext.register_gstreamer_elements(enabled_extensions)

        # Anything that wants to exit after this point must use
        # mopidy.utils.process.exit_process as actors have been started.
        start(proxied_config, enabled_extensions)
    except KeyboardInterrupt:
        pass
    except Exception as ex:
        if logging_initialized:
            logger.exception(ex)
        raise
Ejemplo n.º 3
0
def main():
    signal.signal(signal.SIGTERM, exit_handler)
    loop = gobject.MainLoop()
    try:
        options = parse_options()
        setup_logging(options.verbosity_level, options.save_debug_log)
        check_old_folders()
        setup_settings(options.interactive)
        setup_gstreamer()
        setup_mixer()
        setup_backend()
        setup_frontends()
        loop.run()
    except SettingsError as e:
        logger.error(e.message)
    except KeyboardInterrupt:
        logger.info(u'Interrupted. Exiting...')
    except Exception as e:
        logger.exception(e)
    finally:
        loop.quit()
        stop_frontends()
        stop_backend()
        stop_mixer()
        stop_gstreamer()
        stop_remaining_actors()
Ejemplo n.º 4
0
def main():
    signal.signal(signal.SIGTERM, exit_handler)
    loop = gobject.MainLoop()
    try:
        options = parse_options()
        setup_logging(options.verbosity_level, options.save_debug_log)
        check_old_folders()
        setup_settings(options.interactive)
        setup_gstreamer()
        setup_mixer()
        setup_backend()
        setup_frontends()
        loop.run()
    except SettingsError as e:
        logger.error(e.message)
    except KeyboardInterrupt:
        logger.info(u'Interrupted. Exiting...')
    except Exception as e:
        logger.exception(e)
    finally:
        loop.quit()
        stop_frontends()
        stop_backend()
        stop_mixer()
        stop_gstreamer()
        stop_remaining_actors()
Ejemplo n.º 5
0
def main():
    signal.signal(signal.SIGTERM, process.exit_handler)
    signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)

    args = commands.parser.parse_args(args=mopidy_args)
    if args.show_config:
        commands.show_config(args)
    if args.show_deps:
        commands.show_deps()

    # TODO: figure out a way to make the boilerplate in this file reusable in
    # scanner and other places we need it.

    try:
        # Initial config without extensions to bootstrap logging.
        logging_initialized = False
        logging_config, _ = config_lib.load(
            args.config_files, [], args.config_overrides)

        # TODO: setup_logging needs defaults in-case config values are None
        log.setup_logging(
            logging_config, args.verbosity_level, args.save_debug_log)
        logging_initialized = True

        create_file_structures()
        check_old_locations()

        installed_extensions = ext.load_extensions()

        config, config_errors = config_lib.load(
            args.config_files, installed_extensions, args.config_overrides)

        # Filter out disabled extensions and remove any config errors for them.
        enabled_extensions = []
        for extension in installed_extensions:
            enabled = config[extension.ext_name]['enabled']
            if ext.validate_extension(extension) and enabled:
                enabled_extensions.append(extension)
            elif extension.ext_name in config_errors:
                del config_errors[extension.ext_name]

        log_extension_info(installed_extensions, enabled_extensions)
        check_config_errors(config_errors)

        # Read-only config from here on, please.
        proxied_config = config_lib.Proxy(config)

        log.setup_log_levels(proxied_config)
        ext.register_gstreamer_elements(enabled_extensions)

        # Anything that wants to exit after this point must use
        # mopidy.utils.process.exit_process as actors have been started.
        start(proxied_config, enabled_extensions)
    except KeyboardInterrupt:
        pass
    except Exception as ex:
        if logging_initialized:
            logger.exception(ex)
        raise
Ejemplo n.º 6
0
Archivo: core.py Proyecto: Amli/mopidy
def main():
    signal.signal(signal.SIGTERM, exit_handler)
    try:
        options = parse_options()
        setup_logging(options.verbosity_level, options.save_debug_log)
        setup_settings(options.interactive)
        setup_gobject_loop()
        setup_gstreamer()
        setup_mixer()
        setup_backend()
        setup_frontends()
        while True:
            time.sleep(1)
    except SettingsError as e:
        logger.error(e.message)
    except KeyboardInterrupt:
        logger.info(u'Interrupted. Exiting...')
    except Exception as e:
        logger.exception(e)
    finally:
        stop_all_actors()
Ejemplo n.º 7
0
def main():
    log.bootstrap_delayed_logging()
    logger.info('Starting Mopidy %s', versioning.get_version())

    signal.signal(signal.SIGTERM, process.exit_handler)
    # Windows does not have signal.SIGUSR1
    if hasattr(signal, 'SIGUSR1'):
        signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)

    try:
        registry = ext.Registry()

        root_cmd = commands.RootCommand()
        config_cmd = commands.ConfigCommand()
        deps_cmd = commands.DepsCommand()

        root_cmd.set(extension=None, registry=registry)
        root_cmd.add_child('config', config_cmd)
        root_cmd.add_child('deps', deps_cmd)

        installed_extensions = ext.load_extensions()

        for extension in installed_extensions:
            ext_cmd = extension.get_command()
            if ext_cmd:
                ext_cmd.set(extension=extension)
                root_cmd.add_child(extension.ext_name, ext_cmd)

        args = root_cmd.parse(mopidy_args)

        create_file_structures_and_config(args, installed_extensions)
        check_old_locations()

        config, config_errors = config_lib.load(
            args.config_files, installed_extensions, args.config_overrides)

        verbosity_level = args.base_verbosity_level
        if args.verbosity_level:
            verbosity_level += args.verbosity_level

        log.setup_logging(config, verbosity_level, args.save_debug_log)

        extensions = {
            'validate': [], 'config': [], 'disabled': [], 'enabled': []}
        for extension in installed_extensions:
            if not ext.validate_extension(extension):
                config[extension.ext_name] = {'enabled': False}
                config_errors[extension.ext_name] = {
                    'enabled': 'extension disabled by self check.'}
                extensions['validate'].append(extension)
            elif not config[extension.ext_name]['enabled']:
                config[extension.ext_name] = {'enabled': False}
                config_errors[extension.ext_name] = {
                    'enabled': 'extension disabled by user config.'}
                extensions['disabled'].append(extension)
            elif config_errors.get(extension.ext_name):
                config[extension.ext_name]['enabled'] = False
                config_errors[extension.ext_name]['enabled'] = (
                    'extension disabled due to config errors.')
                extensions['config'].append(extension)
            else:
                extensions['enabled'].append(extension)

        log_extension_info(installed_extensions, extensions['enabled'])

        # Config and deps commands are simply special cased for now.
        if args.command == config_cmd:
            return args.command.run(
                config, config_errors, installed_extensions)
        elif args.command == deps_cmd:
            return args.command.run()

        check_config_errors(config, config_errors, extensions)

        if not extensions['enabled']:
            logger.error('No extension enabled, exiting...')
            sys.exit(1)

        # Read-only config from here on, please.
        proxied_config = config_lib.Proxy(config)

        if args.extension and args.extension not in extensions['enabled']:
            logger.error(
                'Unable to run command provided by disabled extension %s',
                args.extension.ext_name)
            return 1

        for extension in extensions['enabled']:
            extension.setup(registry)

        # Anything that wants to exit after this point must use
        # mopidy.utils.process.exit_process as actors can have been started.
        try:
            return args.command.run(args, proxied_config)
        except NotImplementedError:
            print(root_cmd.format_help())
            return 1

    except KeyboardInterrupt:
        pass
    except Exception as ex:
        logger.exception(ex)
        raise
Ejemplo n.º 8
0
Archivo: core.py Proyecto: bok/mopidy
 def setup_logging(self):
     setup_logging(self.options.verbosity_level,
         self.options.save_debug_log)
     logger.info(u'-- Starting Mopidy --')
Ejemplo n.º 9
0
def main():
    signal.signal(signal.SIGTERM, process.exit_handler)
    signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)

    loop = gobject.MainLoop()
    options = parse_options()
    config_files = options.config.split(b':')
    config_overrides = options.overrides

    enabled_extensions = []  # Make sure it is defined before the finally block
    logging_initialized = False

    # TODO: figure out a way to make the boilerplate in this file reusable in
    # scanner and other places we need it.

    try:
        # Initial config without extensions to bootstrap logging.
        logging_config, _ = config_lib.load(config_files, [], config_overrides)

        # TODO: setup_logging needs defaults in-case config values are None
        log.setup_logging(logging_config, options.verbosity_level,
                          options.save_debug_log)
        logging_initialized = True

        installed_extensions = ext.load_extensions()

        # TODO: wrap config in RO proxy.
        config, config_errors = config_lib.load(config_files,
                                                installed_extensions,
                                                config_overrides)

        # Filter out disabled extensions and remove any config errors for them.
        for extension in installed_extensions:
            enabled = config[extension.ext_name]['enabled']
            if ext.validate_extension(extension) and enabled:
                enabled_extensions.append(extension)
            elif extension.ext_name in config_errors:
                del config_errors[extension.ext_name]

        log_extension_info(installed_extensions, enabled_extensions)
        check_config_errors(config_errors)

        # Read-only config from here on, please.
        proxied_config = config_lib.Proxy(config)

        log.setup_log_levels(proxied_config)
        create_file_structures()
        check_old_locations()
        ext.register_gstreamer_elements(enabled_extensions)

        # Anything that wants to exit after this point must use
        # mopidy.utils.process.exit_process as actors have been started.
        audio = setup_audio(proxied_config)
        backends = setup_backends(proxied_config, enabled_extensions, audio)
        core = setup_core(audio, backends)
        setup_frontends(proxied_config, enabled_extensions, core)
        loop.run()
    except KeyboardInterrupt:
        if logging_initialized:
            logger.info('Interrupted. Exiting...')
    except Exception as ex:
        if logging_initialized:
            logger.exception(ex)
        raise
    finally:
        loop.quit()
        stop_frontends(enabled_extensions)
        stop_core()
        stop_backends(enabled_extensions)
        stop_audio()
        process.stop_remaining_actors()
Ejemplo n.º 10
0
def main():
    signal.signal(signal.SIGTERM, process.exit_handler)
    signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)

    loop = gobject.MainLoop()
    options = parse_options()
    config_files = options.config.split(b':')
    config_overrides = options.overrides

    enabled_extensions = []  # Make sure it is defined before the finally block
    logging_initialized = False

    # TODO: figure out a way to make the boilerplate in this file reusable in
    # scanner and other places we need it.

    try:
        # Initial config without extensions to bootstrap logging.
        logging_config, _ = config_lib.load(config_files, [], config_overrides)

        # TODO: setup_logging needs defaults in-case config values are None
        log.setup_logging(
            logging_config, options.verbosity_level, options.save_debug_log)
        logging_initialized = True

        installed_extensions = ext.load_extensions()

        # TODO: wrap config in RO proxy.
        config, config_errors = config_lib.load(
            config_files, installed_extensions, config_overrides)

        # Filter out disabled extensions and remove any config errors for them.
        for extension in installed_extensions:
            enabled = config[extension.ext_name]['enabled']
            if ext.validate_extension(extension) and enabled:
                enabled_extensions.append(extension)
            elif extension.ext_name in config_errors:
                del config_errors[extension.ext_name]

        log_extension_info(installed_extensions, enabled_extensions)
        check_config_errors(config_errors)

        # Read-only config from here on, please.
        proxied_config = config_lib.Proxy(config)

        log.setup_log_levels(proxied_config)
        create_file_structures()
        check_old_locations()
        ext.register_gstreamer_elements(enabled_extensions)

        # Anything that wants to exit after this point must use
        # mopidy.utils.process.exit_process as actors have been started.
        audio = setup_audio(proxied_config)
        backends = setup_backends(proxied_config, enabled_extensions, audio)
        core = setup_core(audio, backends)
        setup_frontends(proxied_config, enabled_extensions, core)
        loop.run()
    except KeyboardInterrupt:
        if logging_initialized:
            logger.info('Interrupted. Exiting...')
    except Exception as ex:
        if logging_initialized:
            logger.exception(ex)
        raise
    finally:
        loop.quit()
        stop_frontends(enabled_extensions)
        stop_core()
        stop_backends(enabled_extensions)
        stop_audio()
        process.stop_remaining_actors()