def main(argv):
    global _PROG, _VERBOSE
    protocol = 'jsonrpc'
    lock, trigger, ignore_listener = True, False, False

    _PROG = argv[0]
    try:
        opts, args = getopt.getopt(argv[1:], 'vhLtip:',
                     ( '--verbose', '--help', '--no-lock', '--trigger',
                       '--ignore-listener', '--protocol=', ))
        for flag, opt in opts:
            if flag in ( '-v', '--verbose', ):
                _VERBOSE = True
            if flag in ( '-p', '--protocol', ):
                protocol = opt
            if flag in ( '-L', '--no-lock', ):
                lock = False
            if flag in ( '-t', '--trigger', ):
                trigger = True
            if flag in ( '-i', '--ignore-listener', ):
                ignore_listener = True
            elif flag in ( '-h', '--help', ):
                return usage(1)

        if 5 > len(args):
            return usage()
        remote = args[0]
        src_queue = args[1]
        trg_queue = args[2]
        host = args[3]

        for item_id in args[4:]:
            chirp('pushing item {0} to remote {1} from queue {2}, host queue '\
                  '{3} to queue {4}'.format(item_id, remote, src_queue, host,
                                            trg_queue))
            item = fsq.FSQWorkItem(src_queue, item_id , host=host, lock=lock)
            fsq.push(item, remote, trg_queue, protocol=protocol)
            if trigger:
                fsq.remote_trigger_pull(remote, trg_queue,
                                   ignore_listener=ignore_listener,
                                   protocol=protocol)

    except ( fsq.FSQEnvError, fsq.FSQCoerceError, ):
        shout('invalid argument for flag: {0}'.format(flag))
        return fsq.const('FSQ_FAIL_PERM')
    except fsq.FSQInstallError, e:
        shout(e.strerror)
        return fsq.const('FSQ_FAIL_TMP')
    except getopt.GetoptError, e:
        shout('invalid flag: -{0}{1}'.format('-' if 1 < len(e.opt) else '',
              e.opt))
        return fsq.const('FSQ_FAIL_TMP')
dataset/ETHPy150Open axialmarket/fsq/libexec/fsq/push.py/main/original