def parse_args( args, ): # type: (List[str]) -> Tuple[Dict[str, object], List[str], Dict[str, object], Dict[str, object]] args, pabot_args = _parse_pabot_args(args) options, datasources = ArgumentParser( USAGE, auto_pythonpath=False, auto_argumentfile=True, env_options="ROBOT_OPTIONS", ).parse_args(args) options_for_subprocesses, sources_without_argfile = ArgumentParser( USAGE, auto_pythonpath=False, auto_argumentfile=False, env_options="ROBOT_OPTIONS", ).parse_args(args) if len(datasources) != len(sources_without_argfile): raise DataError( "Pabot does not support datasources in argumentfiles.\nPlease move datasources to commandline." ) if len(datasources) > 1 and options["name"] is None: options["name"] = "Suites" options_for_subprocesses["name"] = "Suites" opts = _delete_none_keys(options) opts_sub = _delete_none_keys(options_for_subprocesses) return opts, datasources, pabot_args, opts_sub
def main(args): from robot.api import ResultWriter opts, datasources = ArgumentParser(USAGE).parse_args(args) keys = set() for k in opts: if opts[k] is None: keys.add(k) for k in keys: del opts[k] opts['dotted'] = True runner(datasources, **opts) ResultWriter(opts.get('output', 'output.xml')).write_results(settings=None, **opts)
def _parse_args(args): pabot_args = {'command': ['pybot'], 'verbose': False, 'pabotlib': False, 'pabotlibhost': '127.0.0.1', 'pabotlibport': 8270, 'processes': max(multiprocessing.cpu_count(), 2), 'argumentfiles': []} while args and args[0] in ['--'+param for param in ['command', 'processes', 'verbose', 'resourcefile', 'pabotlib', 'pabotlibhost', 'pabotlibport', 'suitesfrom']] or \ ARGSMATCHER.match(args[0]): if args[0] == '--command': end_index = args.index('--end-command') pabot_args['command'] = args[1:end_index] args = args[end_index+1:] if args[0] == '--processes': pabot_args['processes'] = int(args[1]) args = args[2:] if args[0] == '--verbose': pabot_args['verbose'] = True args = args[1:] if args[0] == '--resourcefile': pabot_args['resourcefile'] = args[1] args = args[2:] if args[0] == '--pabotlib': pabot_args['pabotlib'] = True args = args[1:] if args[0] == '--pabotlibhost': pabot_args['pabotlibhost'] = args[1] args = args[2:] if args[0] == '--pabotlibport': pabot_args['pabotlibport'] = int(args[1]) args = args[2:] if args[0] == '--suitesfrom': pabot_args['suitesfrom'] = args[1] args = args[2:] match = ARGSMATCHER.match(args[0]) if ARGSMATCHER.match(args[0]): pabot_args['argumentfiles'] += [(match.group(1), args[1])] args = args[2:] options, datasources = ArgumentParser(USAGE, auto_pythonpath=False, auto_argumentfile=False).\ parse_args(args) if len(datasources) > 1 and options['name'] is None: options['name'] = 'Suites' keys = set() for k in options: if options[k] is None: keys.add(k) for k in keys: del options[k] return options, datasources, pabot_args
def _get_arguments(self, additional_arguments): options, _ = ArgumentParser(_get_cmd_arguments()).parse_args( sys.argv[1:]) args = [] for arg in ['loglevel', 'runmode', 'variable', 'variablefile']: args += self._get_type_arguments(options, arg) args += list(additional_arguments) return args
def parse_args(args): ''' Use robot parse_args Remove none keys ''' options, datasources = ArgumentParser(USAGE, auto_pythonpath=False, auto_argumentfile=True, env_options='ROBOT_OPTIONS'). \ parse_args(args) if len(datasources) > 1 and options['name'] is None: options['name'] = 'Suites' opts = _delete_none_keys(options) return opts
def _parse_args(args): pabot_args = { 'command': ['pybot'], 'verbose': False, 'pabotlib': False, 'processes': max(multiprocessing.cpu_count(), 2) } while args and args[0] in [ '--' + param for param in [ 'command', 'processes', 'verbose', 'resourcefile', 'pabotlib', 'hostsfile' ] ]: if args[0] == '--command': end_index = args.index('--end-command') pabot_args['command'] = args[1:end_index] args = args[end_index + 1:] if args[0] == '--processes': pabot_args['processes'] = int(args[1]) args = args[2:] if args[0] == '--verbose': pabot_args['verbose'] = True args = args[1:] if args[0] == '--resourcefile': pabot_args['resourcefile'] = args[1] args = args[2:] if args[0] == '--pabotlib': pabot_args['pabotlib'] = True args = args[1:] if args[0] == '--hostsfile': pabot_args['hostsfile'] = args[1] args = args[2:] options, datasources = ArgumentParser( USAGE, auto_pythonpath=False, auto_argumentfile=False).parse_args(args) keys = set() for k in options: if options[k] is None: keys.add(k) for k in keys: del options[k] return options, datasources, pabot_args
def _parse_args(args): pabot_args = { 'command': ['pybot' if ROBOT_VERSION < '3.1' else 'robot'], 'verbose': False, 'tutorial': False, 'help': False, 'testlevelsplit': False, 'pabotlib': False, 'pabotlibhost': '127.0.0.1', 'pabotlibport': 8270, 'processes': _processes_count(), 'argumentfiles': [] } while args and (args[0] in [ '--' + param for param in [ 'command', 'processes', 'verbose', 'tutorial', 'resourcefile', 'testlevelsplit', 'pabotlib', 'pabotlibhost', 'pabotlibport', 'suitesfrom', 'help' ] ] or ARGSMATCHER.match(args[0])): if args[0] == '--command': end_index = args.index('--end-command') pabot_args['command'] = args[1:end_index] args = args[end_index + 1:] if args[0] == '--processes': pabot_args['processes'] = int(args[1]) args = args[2:] if args[0] == '--verbose': pabot_args['verbose'] = True args = args[1:] if args[0] == '--resourcefile': pabot_args['resourcefile'] = args[1] args = args[2:] if args[0] == '--pabotlib': pabot_args['pabotlib'] = True args = args[1:] if args[0] == '--testlevelsplit': pabot_args['testlevelsplit'] = True args = args[1:] if args[0] == '--pabotlibhost': pabot_args['pabotlibhost'] = args[1] args = args[2:] if args[0] == '--pabotlibport': pabot_args['pabotlibport'] = int(args[1]) args = args[2:] if args[0] == '--suitesfrom': pabot_args['suitesfrom'] = args[1] args = args[2:] match = ARGSMATCHER.match(args[0]) if ARGSMATCHER.match(args[0]): pabot_args['argumentfiles'] += [(match.group(1), args[1])] args = args[2:] if args[0] == '--tutorial': pabot_args['tutorial'] = True args = args[1:] if args and args[0] == '--help': pabot_args['help'] = True args = args[1:] options, datasources = ArgumentParser(USAGE, auto_pythonpath=False, auto_argumentfile=True, env_options='ROBOT_OPTIONS'). \ parse_args(args) options_for_subprocesses, _ = ArgumentParser(USAGE, auto_pythonpath=False, auto_argumentfile=False, env_options='ROBOT_OPTIONS'). \ parse_args(args) if len(datasources) > 1 and options['name'] is None: options['name'] = 'Suites' options_for_subprocesses['name'] = 'Suites' _delete_none_keys(options) _delete_none_keys(options_for_subprocesses) return options, datasources, pabot_args, options_for_subprocesses
def _process_args(cliargs): ap = ArgumentParser(__doc__, arg_limits=(2, )) try: return ap.parse_args(cliargs) except Information, msg: _exit(msg)