コード例 #1
0
                             help='Location of configuration file.')
    option_parser.add_option('-c',
                             '--cmus-host',
                             dest='cmus_host',
                             help='Name of cmus host.',
                             default='localhost')
    option_parser.add_option('-w',
                             '--cmus-passwd',
                             dest='cmus_passwd',
                             help='Cmus password.',
                             default='')
    option_parser.add_option('-a',
                             '--app-host',
                             dest='app_host',
                             help='Name of cmus_app host.',
                             default='localhost')
    option_parser.add_option('-p',
                             '--app-port',
                             dest='app_port',
                             help='Port cmus_app is listening on.',
                             default=8080)
    options, _ = option_parser.parse_args()
    if options.config_file:
        settings = read_config(options.config_file)
    else:
        settings = vars(options)
    Remote = cmus_remote.bake([
        '--server', settings['cmus_host'], '--passwd', settings['cmus_passwd']
    ])
    run(host=settings['app_host'], port=settings['app_port'])
コード例 #2
0
ファイル: app.py プロジェクト: nogizhopaboroda/cmus_app
def static(file):
    response.set_header('Cache-Control', 'max-age=604800')
    return static_file(file, root='static')

@route('/favicon.ico')
def favicon():
    response.set_header('Cache-Control', 'max-age=604800')
    return static_file('favicon.ico', root='static')
if __name__ == '__main__':
    # configuration file either supplied via command line  
    # or assumed to be in one of the default locations

    (options, args) = parser.parse_args()
    if options.noconfig is True:
        settings = {
            'cmus_host': 'localhost'
        }
        Remote = cmus_remote.bake()
        run(host=options.app_host, port=options.port)
    else:
        if len(sys.argv) > 1:
            print sys.argv
            CONFIG=sys.argv[1:]
        else:
            CONFIG=['config','config.ini','.config']

        settings = read_config(CONFIG)
        Remote = cmus_remote.bake(['--server', settings['cmus_host'], '--passwd', settings['cmus_passwd']])
        run(host=settings['app_host'], port=settings['app_port'])