def main():
    command_list = ('start', 'stop', 'restart', 'upgrade')
    args = sys.argv
    if len(args) < 2 or command_list not in args[1]:
        print "usage: playa [command] [options]"
        print
        print "Available subcommands:"
        for cmd in command_list:
            print "  ", cmd
        sys.exit(1)

    parser = OptionParser(version="%%prog %s" % VERSION)
    parser.add_option('--config', metavar='CONFIG')
    if args[1] == 'start':
        parser.add_option('--debug', action='store_true', default=False, dest='debug')
        parser.add_option('--host', metavar='HOSTNAME')
        parser.add_option('--port', type=int, metavar='PORT')
        parser.add_option('--daemon', action='store_true', default=False, dest='daemonize')
        parser.add_option('--no-daemon', action='store_false', default=False, dest='daemonize')
        parser.add_option('--pidfile', dest='pidfile')
        parser.add_option('--logfile', dest='logfile')
    elif args[1] == 'stop':
        parser.add_option('--pidfile', dest='pidfile')
        parser.add_option('--logfile', dest='logfile')

    (options, args) = parser.parse_args()

    if options.config:
        # assumed to be a file
        app.config.from_pyfile(options.config)
    else:
        config_path = os.path.expanduser(os.path.join('~', '.playa', 'playa.conf.py'))
        if os.path.exists(config_path):
            app.config.from_pyfile(config_path)

    if args[0] == 'upgrade':
        upgrade()

    elif args[0] == 'start':
        web = PlayaServer(host=options.host, port=options.port,
                           pidfile=options.pidfile, logfile=options.logfile,
                           daemonize=options.daemonize, debug=options.debug)
        web.execute(args[0])

    elif args[0] == 'restart':
        web = PlayaServer()
        web.execute(args[0])
  
    elif args[0] == 'stop':
        web = PlayaServer(pidfile=options.pidfile, logfile=options.logfile)
        web.execute(args[0])

    sys.exit(0)
dataset/ETHPy150Open disqus/playa/playa/runner.py/main/swapped operands of `not in`