def main(argv):
    global _PROG, _VERBOSE
    # defaults
    set_env = True
    no_open = False
    ignore_down = False
    empty_ok = False
    no_done = False
    host = False
    hosts = []
    max_rate = None

    _PROG = argv[0]
    try:
        opts, args = getopt.getopt(argv[1:], 'hveEnilLkDt:m:S:T:F:aA:r:', ( 'help',
                                   'env', 'no-env', 'no-open', 'ignore-down',
                                   'lock', 'no-lock', 'empty-ok', 'no-done',
                                   'ttl=', 'max-tries=', 'success-code=',
                                   'fail-tmp-code=', 'fail-perm-code=',
                                   'verbose', 'all-hosts', 'host=', 'max-rate='))
    except getopt.GetoptError, e:
        barf('invalid flag: -{0}{1}'.format('-' if 1 < len(e.opt) else '',
             e.opt))
    try:
        for flag, opt in opts:
            if '-v' == flag or '--verbose' == flag:
                _VERBOSE = True
            elif '-e' == flag or '--env' == flag:
                set_env = True
            elif '-E' == flag or '--no-env' == flag:
                set_env = False
            elif '-n' == flag or '--no-open' == flag:
                no_open = True
            elif '-i' == flag or '--ignore-down' == flag:
                ignore_down = True
            elif '-l' == flag or '--lock' == flag:
                fsq.set_const('FSQ_LOCK', True)
            elif '-L' == flag or '--no-lock' == flag:
                fsq.set_const('FSQ_LOCK', False)
            elif '-k' == flag or '--empty-ok' == flag:
                empty_ok = True
            elif '-D' == flag or '--no-done' == flag:
                no_done = True
            elif '-a' == flag or '--all-hosts' == flag:
                host = True
            elif '-A' == flag or '--hosts' == flag:
                hosts.append(opt)
                host = True
            elif '-t' == flag or '--ttl' == flag:
                fsq.set_const('FSQ_TTL', opt)
            elif '-m' == flag or '--max-tries' == flag:
                fsq.set_const('FSQ_MAX_TRIES', opt)
            elif '-S' == flag or '--success-code' == flag:
                fsq.set_const('FSQ_SUCCESS', opt)
            elif '-T' == flag or '--fail-tmp-code' == flag:
                fsq.set_const('FSQ_FAIL_TMP', opt)
            elif '-F' == flag or '--fail-perm-code' == flag:
                fsq.set_const('FSQ_FAIL_PERM', opt)
            elif '-r' == flag or '--max-rate' == flag:
                try:
                    max_rate = int(opt)
                except ValueError:
                    raise fsq.FSQCoerceError
            elif '-h' == flag or '--help' == flag:
                usage(1)
    except ( fsq.FSQEnvError, fsq.FSQCoerceError, ):
        barf('invalid argument for flag: {0}'.format(flag))

    # validate args
    num_required = 1 if empty_ok else 2
    if len(args) > num_required:
        usage()
    exec_args = tuple(args[1:])
    fsq.fork_exec_items(args[0], ignore_down=ignore_down, host=host,
                        no_open=no_open, hosts=hosts if hosts else None,
                        no_done=no_done, set_env=set_env, exec_args=exec_args,
                        verbose=_VERBOSE, empty_ok=empty_ok, max_rate=max_rate)
dataset/ETHPy150Open axialmarket/fsq/libexec/fsq/scan.py/main/swapped operands of `>`