How to use the feeluown.cli.print_error function in feeluown

To help you get started, we’ve selected a few feeluown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feeluown / FeelUOwn / feeluown / __main__.py View on Github external
def run_forever(args, config):
    is_daemon_started = is_port_used(23333) or is_port_used(23334)
    if config.MODE & App.DaemonMode and is_daemon_started:
        print_error('Fuo daemon is already started.')
        sys.exit(1)

    if config.MODE & App.GuiMode:
        prepare_gui()
    app = setup_app(args, config)
    if sys.platform.lower() == 'darwin':
        enable_mac_hotkey()
    loop = asyncio.get_event_loop()
    try:
        if not config.MODE & App.GuiMode:
            if config.MODE & App.DaemonMode:
                # when started with daemon mode, show some message to tell user
                # that the program is running.
                print('Fuo daemon running on 0.0.0.0:23333 (tcp)')
            else:
                print('Fuo running with no daemon and no window')
github feeluown / FeelUOwn / feeluown / __main__.py View on Github external
3: run loop
    """
    # 根据命令行参数来更新配置
    # 注:用户在 rcfile 文件中也可以配置这些选项的值
    # 所以我们不能这样实现 config.DEBUG = args.debug,而是像下面这样
    config.DEBUG = args.debug or config.DEBUG
    config.MPV_AUDIO_DEVICE = args.mpv_audio_device or config.MPV_AUDIO_DEVICE
    config.LOG_TO_FILE = bool(args.log_to_file or config.LOG_TO_FILE)

    if args.cmd is not None:
        is_daemon_started = is_port_used(23333) or is_port_used(23334)
        if is_daemon_started:
            return 1  # run_cli
        cli_cmds = ('show', 'play', 'search')
        if args.cmd not in cli_cmds:
            print_error('Fuo daemon not started.')
            sys.exit(1)
        return 2  # run_once

    if not args.no_window:
        try:
            import PyQt5  # noqa
        except ImportError:
            logger.warning('PyQt5 is not installed, can only use daemon mode.')
        else:
            config.MODE |= App.GuiMode
    if not args.no_server:
        config.MODE |= App.DaemonMode
    return 3