Esempio n. 1
0
File: cli.py Progetto: keto/spotty
def main():
    """Commandline entry point."""
    DBusGMainLoop(set_as_default=True)
    options, _ = parse_opts()
    if options.debug:
        LOG.setLevel(logging.DEBUG)
    if not options.command:
        return

    gobject.threads_init()
    cli = SpottyCLI(options.quiet)
    cli.start()
    cli.send_command(options.command)
    if options.command not in ["Previous"]:
        cli.join(2)
    cli.terminate()
    return 0
Esempio n. 2
0
File: core.py Progetto: keto/spotty
def main():
    """Entry point"""
    # TODO configuration file handling and commandline options
    options, _ = parse_args()
    if options.debug:
        LOG.setLevel(logging.DEBUG)
    DBusGMainLoop(set_as_default=True)
    spotify = SpotifyControl()
    # Load plugins
    enabled = ["GnomeMediaKeys", "Notify", "CoverFetcher"]
    plugins = {}
    LOG.debug("Loading plugins...")
    for entry in pkg_resources.iter_entry_points("spotty.plugin"):
        plugin = entry.load()
        if plugin.__name__ not in enabled:
            LOG.debug("%s not enabled, skipping...", plugin.__name__)
            continue
        LOG.debug("Loading plugin %s", plugin.__name__)
        try:
            plugins[plugin.__name__] = plugin.load(spotify)
        except Exception:
            LOG.error("Failed to load %s", plugin.__name__)
            traceback.print_exc()
    
    # Start the mainloop
    spotify.connect()
    loop = gobject.MainLoop()
    signal.signal(signal.SIGINT, lambda *args: loop.quit())
    loop.run()
    # Unload plugins
    for name, plugin in plugins.iteritems():
        LOG.debug("Unloading %s", name)
        try:
            plugin.unload()
        except Exception:
            LOG.error("Failed to unload %s", name)
            traceback.print_exc()