def dumbo(argv=sys.argv): if len(argv) < 2: print 'Usages:' print ' dumbo start <python program> [<options>]' print ' dumbo cat <path> [<options>]' print ' dumbo ls <path> [<options>]' print ' dumbo exists <path> [<options>]' print ' dumbo rm <path> [<options>]' print ' dumbo put <path1> <path2> [<options>]' print ' dumbo get <path1> <path2> [<options>]' print ' dumbo encodepipe [<options>]' print ' dumbo decodepipe [<options>]' print ' dumbo doctest <python program>' print ' dumbo version' print ' dumbo configdump' return 1 if argv[1] == 'start': retval = start(argv[2], parseargs(argv[2:])) elif argv[1] == 'cat': retval = cat(argv[2], parseargs(argv[2:])) elif argv[1] == 'ls': retval = ls(argv[2], parseargs(argv[2:])) elif argv[1] == 'exists': retval = exists(argv[2], parseargs(argv[2:])) elif argv[1] == 'rm': retval = rm(argv[2], parseargs(argv[2:])) elif argv[1] == 'put': retval = put(argv[2], argv[3], parseargs(argv[3:])) elif argv[1] == 'get': retval = get(argv[2], argv[3], parseargs(argv[3:])) elif argv[1] == 'encodepipe': retval = encodepipe(parseargs(argv[2:])) elif argv[1] == 'decodepipe': retval = decodepipe(parseargs(argv[2:])) elif argv[1] == 'doctest': retval = doctest(argv[2]) elif argv[1].endswith('.py'): retval = start(argv[1], parseargs(argv[1:])) elif argv[1] in ('version', '-v', '--version'): print version() return 0 elif argv[1] == 'configdump': retval = config_dump() else: print >> sys.stderr, 'ERROR: unknown dumbo command:', argv[1] retval = 1 return retval
def dumbo(): if len(sys.argv) < 2: print 'Usages:' print ' dumbo start <python program> [<options>]' print ' dumbo cat <path> [<options>]' print ' dumbo ls <path> [<options>]' print ' dumbo exists <path> [<options>]' print ' dumbo rm <path> [<options>]' print ' dumbo put <path1> <path2> [<options>]' print ' dumbo get <path1> <path2> [<options>]' print ' dumbo encodepipe [<options>]' print ' dumbo decodepipe [<options>]' print ' dumbo doctest <python program>' return 1 if sys.argv[1] == 'start': retval = start(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'cat': retval = cat(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'ls': retval = ls(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'exists': retval = exists(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'rm': retval = rm(sys.argv[2], parseargs(sys.argv[2:])) elif sys.argv[1] == 'put': retval = put(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == 'get': retval = get(sys.argv[2], sys.argv[3], parseargs(sys.argv[3:])) elif sys.argv[1] == 'encodepipe': retval = encodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == 'decodepipe': retval = decodepipe(parseargs(sys.argv[2:])) elif sys.argv[1] == 'doctest': retval = doctest(sys.argv[2]) elif sys.argv[1].endswith('.py'): retval = start(sys.argv[1], parseargs(sys.argv[1:])) else: print >> sys.stderr, 'ERROR: unknown dumbo command:', sys.argv[1] retval = 1 return retval
def main(module=None): if module is None: import __main__ module = __main__ intask = len(sys.argv) > 1 and sys.argv[1][0] != '-' opts = parseargs(sys.argv[1:]) if intask: input_paths = os.environ['FLOW_INPUTS'].split(';') output_paths = os.environ['FLOW_OUTPUTS'].split(';') else: sequential = 'yes' in getopt(opts, 'seq') input_paths = getopt(opts, 'input') output_paths = getopt(opts, 'output') if any(';' in path for path in input_paths): print >> sys.stderr, "ERROR: Input paths cannot contain semi-colons" sys.exit(1) if any(';' in path for path in output_paths): print >> sys.stderr, "ERROR: Output paths cannot contain semi-colons" sys.exit(1) if any(',' in path for path in output_paths): print >> sys.stderr, "ERROR: Output paths cannot contain commas" sys.exit(1) print >> sys.stderr, "INFO: Flow inputs: %s" % input_paths print >> sys.stderr, "INFO: Flow outputs: %s" % output_paths flow = Flow(opts, input_paths, output_paths) # call special init function to initialize the flow positional_inputs = [] named_inputs = {} for path_string in input_paths: if '=' in path_string: name, value = path_string.split('=',1) named_inputs[name] = ResultSet.from_string(value) else: positional_inputs.append(ResultSet.from_string(path_string)) outputs = module.init(flow, *positional_inputs, **named_inputs) if type(outputs) is ResultSet: outputs = [outputs] for resultset, path in zip(outputs, output_paths): if len(resultset) > 1: print >> sys.stderr, "ERROR: Final outputs must be singleton resultsets" sys.exit(1) output = resultset[0] output.path = path output.temporary = False if intask: iterarg = 0 if len(sys.argv) > 2: iterarg = int(sys.argv[2]) flow.run_task(iterarg) else: if sequential: flow.run_all_sequential() else: flow.run_all()