我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用argparse.REMAINDER。
def init_config(self, arguments): # TODO: refactor this method... sooo ugly :S parser = self.parser_base parser.add_argument('args', nargs=argparse.REMAINDER) base_parser = parser.parse_args(arguments) params = {} if getattr(base_parser, "project", False) and base_parser.project is not None: params["path"] = base_parser.project if getattr(base_parser, "conffile", False) and base_parser.conffile is not None: params["filename"] = base_parser.conffile self.config = GlobalConfig(**params) return self.parser_base
def doArchive(argv, bobRoot): subHelp = "\n ... ".join(sorted( [ "{:8} {}".format(c, d[1]) for (c, d) in availableArchiveCmds.items() ])) parser = argparse.ArgumentParser(prog="bob archive", formatter_class=argparse.RawDescriptionHelpFormatter, description="""Manage binary artifacts archive. The following subcommands are available: bob archive {} """.format(subHelp)) parser.add_argument('subcommand', help="Subcommand") parser.add_argument('args', nargs=argparse.REMAINDER, help="Arguments for subcommand") args = parser.parse_args(argv) if args.subcommand in availableArchiveCmds: availableArchiveCmds[args.subcommand][0](args.args) else: parser.error("Unknown subcommand '{}'".format(args.subcommand))
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--resource-whitelist', help='Generate a resource whitelist for this target.', metavar='PATH') parser.add_argument('command', nargs=argparse.REMAINDER, help='Compilation command') args = parser.parse_args() returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(args.command)) used_resources = wrapper_utils.ExtractResourceIdsFromPragmaWarnings(stderr) sys.stderr.write(stderr) if args.resource_whitelist: with open(args.resource_whitelist, 'w') as f: if used_resources: f.write('\n'.join(str(resource) for resource in used_resources)) f.write('\n') return returncode
def main(): parser = argparse.ArgumentParser(description='PySketch - Write easy sketches in python.\n' 'Add "#!/usr/bin/env pysketch" to a sketchfile and make it executable to run from the shell') parser.add_argument('sketchfile', type=str, help="file to load and execute") parser.add_argument('sketch arguments', nargs=argparse.REMAINDER, help="arguments to the sketch") parser.add_argument('-v, --version', action='version', version=__version__) # Set up logger logger = logging.getLogger('sketches') ch = logging.StreamHandler() formatter = logging.Formatter('[%(levelname)s]: %(message)s') ch.setFormatter(formatter) logger.addHandler(ch) args = parser.parse_args().__dict__ try: runner = SketchRunner(args['sketchfile']) except FileNotFoundError: exit() runner.run(args['sketch arguments'])
def ideinit(args, refreshOnly=False, buildProcessorJars=True): """(re)generate IDE project configurations""" parser = ArgumentParser(prog='mx ideinit') parser.add_argument('--no-python-projects', action='store_false', dest='pythonProjects', help='Do not generate projects for the mx python projects.') parser.add_argument('remainder', nargs=REMAINDER, metavar='...') args = parser.parse_args(args) mx_ide = os.environ.get('MX_IDE', 'all').lower() all_ides = mx_ide == 'all' if all_ides or mx_ide == 'eclipse': eclipseinit(args.remainder, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars, doFsckProjects=False, pythonProjects=args.pythonProjects) if all_ides or mx_ide == 'netbeans': netbeansinit(args.remainder, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars, doFsckProjects=False) if all_ides or mx_ide == 'intellij': intellijinit(args.remainder, refreshOnly=refreshOnly, doFsckProjects=False, mx_python_modules=args.pythonProjects) if not refreshOnly: fsckprojects([])
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Test a ADGM Network') parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--dataset', dest='dataset', help='dataset to test', default='voc_2007_test', type=str) parser.add_argument('--tag', dest='tag', help='tag of the model', default='', type=str) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def main(): parser = argparse.ArgumentParser() parser.add_argument("pidfile", help="pid file location") parser.add_argument("command", help="command to run (with args)", nargs=argparse.REMAINDER) parser.add_argument("--daemon", "-d", help="handle proxies processes which fork to background and terminate " "by waiting for a valid pid file, then monitor the pid in order " "to track the process lifetime", action="store_true") parser.add_argument("--start-wait", "-s", help="amount of seconds to wait for a valid pid file to appear " "(default: 60, ignored if not using --daemon)", default=60, type=int) params = parser.parse_args() wait_pidfile_time=None if params.daemon: wait_pidfile_time = params.start_wait pp = PidProxy(pidfile=params.pidfile, cmdargs=params.command, wait_pidfile_time=wait_pidfile_time) pp.go()
def auth_stored_credentials(self, client_secrets_file, scopes=[]): """Authorize stored credentials.""" try: import argparse parser = argparse.ArgumentParser(parents=[tools.argparser]) parser.add_argument('args', nargs=argparse.REMAINDER) flags = parser.parse_args() flags.noauth_local_webserver = True except ImportError: flags = None store = Storage(self.credentials_file) credentials = store.get() if not credentials or credentials.invalid: flow = client.flow_from_clientsecrets( client_secrets_file, scopes, ) flow.user_agent = self.app_name if flags: credentials = tools.run_flow(flow, store, flags) else: # Needed only for compatibility with Python 2.6 credentials = tools.run(flow, store) print 'Saved credentials to ' + self.credentials_file return credentials
def get_parser(self, prog_name): parser = super(ExecContainer, self).get_parser(prog_name) parser.add_argument( 'container', metavar='<container>', help='ID or name of the container to execute command in.') parser.add_argument( 'command', metavar='<command>', nargs=argparse.REMAINDER, help='The command to execute.') parser.add_argument( '--interactive', dest='interactive', action='store_true', default=False, help='Keep STDIN open and allocate a pseudo-TTY for interactive') return parser
def cinch_generic(playbook): # Parse the command line arguments parser = ArgumentParser(description='A wrapper around Cinch for the most ' 'common use case') # The inventory file that the user provides which will get passed along to # Ansible for its consumption parser.add_argument('inventory') # All remaining arguments are passed through, untouched, to Ansible parser.add_argument('args', nargs=REMAINDER) args = parser.parse_args() if len(args.inventory) > 0: if args.inventory[0] == '/': inventory = args.inventory else: inventory = path.join(getcwd(), args.inventory) else: raise Exception('Inventory path needs to be non-empty') exit_code = call_ansible(inventory, playbook, args.args) sys.exit(exit_code)
def init(self, path): self.script_path = path self.parser = self.get_subparsers().add_parser( self.get_command_name(), add_help=False, help=self.get_command_help() ) self.parser.add_argument( "-h", "--help", action="store_true" ) self.parser.add_argument( "args", help="Arguments", nargs=argparse.REMAINDER, action="store" )
def parseArguments(): argParser = argparse.ArgumentParser(description='PALADIN Pipeline Plugins') argParser.add_argument('-l', dest='list', action='store_true', help='List available plugins') argParser.add_argument('plugins', metavar='Plugins', type=str, nargs=argparse.REMAINDER, help='Plugin with arguments (@@plugin arguments)') retArguments = argParser.parse_args() # Check for no arguments, or bad syntax in plugins list invalidArgs = False if not retArguments.list and not retArguments.plugins: invalidArgs = True if retArguments.plugins and not retArguments.plugins[0].startswith('@@'): invalidArgs = True if invalidArgs: argParser.print_help() sys.exit(1) # Replace quotes for strings with spaces for plugIdx in range(len(retArguments.plugins)): plugArg = retArguments.plugins[plugIdx] if ' ' in plugArg: plugArg = "\"{0}\"".format(plugArg) retArguments.plugins[plugIdx] = plugArg return retArguments # Extract pipeline plugin/argument pairs from arguments
def automateMain(passArguments): # Parse arguments argParser = argparse.ArgumentParser(description='PALADIN Pipeline Plugins: Automate', prog='automate') argParser.add_argument('reference', metavar='REFERENCE', type=str, help='Reference database') argParser.add_argument('root', metavar='ROOT', type=str, help='Root path to search') argParser.add_argument('pattern', metavar='PATTERN', type=str, help='Input reads search pattern') argParser.add_argument('options', metavar='OPTIONS', type=str, nargs=argparse.REMAINDER, help='PALADIN options') arguments = argParser.parse_known_args(shlex.split(passArguments)) for root, dirs, files in os.walk(arguments[0].root): for fileName in files: if not re.search(arguments[0].pattern, fileName): continue # Matching input sequence, execute PALADIN baseName = fileName if '.' in baseName: baseName = baseName[:baseName.index('.')] baseName = os.path.join(root, baseName) fullFile = os.path.join(root, fileName) command = "paladin align {0} {1} -o {2} {3}".format(arguments[0].reference, fullFile, baseName, ' '.join(arguments[0].options)) output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True) with open("{0}.log".format(baseName), 'wb') as fileHandle: fileHandle.write(output)
def mainChar(argv): parser = argparse.ArgumentParser( description="Perform characterization for memory macros.", prog="char" ) parser.add_argument("num_addr", metavar="NADDR", type=int, help="number of address lines") parser.add_argument("num_bits", metavar="NBITS", type=int, help="number of bits") parser.add_argument("char", metavar="CHAR", type=str, help="characterization to perform") parser.add_argument("--vdd", metavar="VDD", type=float, default=1.2, help="supply voltage [V]") parser.add_argument("--temp", metavar="T", type=float, default=25, help="junction temperature [°C]") parser.add_argument("args", nargs=argparse.REMAINDER) args = parser.parse_args(argv) macro = potstill.macro.MacroConditions(args.num_addr, args.num_bits, vdd=args.vdd, temp=args.temp) if args.char == "all": mainCharMacroAll(macro, args.args) else: mainCharMacro(macro, args.char, args.args)
def parse_args(): bin_dir = os.environ.get('DEPOT_TOOLS_GSUTIL_BIN_DIR', DEFAULT_BIN_DIR) parser = argparse.ArgumentParser() parser.add_argument('--force-version', default='4.13') parser.add_argument('--clean', action='store_true', help='Clear any existing gsutil package, forcing a new download.') parser.add_argument('--fallback', default=DEFAULT_FALLBACK_GSUTIL) parser.add_argument('--target', default=bin_dir, help='The target directory to download/store a gsutil version in. ' '(default is %(default)s).') parser.add_argument('args', nargs=argparse.REMAINDER) args, extras = parser.parse_known_args() if args.args and args.args[0] == '--': args.args.pop(0) if extras: args.args = extras + args.args return args
def _create_command_line_parser(): """Returns an argparse.ArgumentParser to parse command line arguments.""" parser = argparse.ArgumentParser( usage='usage: %(prog)s [execution options] <script> [script_args]', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'script', help='the path to the PHP script that should be executed') parser.add_argument( 'script_args', help='the command arguments that will be passed to the script', nargs=argparse.REMAINDER) execution_group = parser.add_argument_group('Execution Options') php_cli_path = _get_default_php_cli_path() execution_group.add_argument('--php_executable_path', metavar='PATH', type=_parse_path, default=php_cli_path, required=php_cli_path is None, help='path to the PHP executable') return parser
def add_arguments(self, parser): parser.add_argument( 'files', nargs=argparse.REMAINDER, help='You may specify the test files/directories to be executed.' ) parser.add_argument( '--recreate', action='store_true', dest='recreate', default=False, help='Recreate test database (will slow down the test process), ' 'used when the database schema changed.' ) parser.add_argument( '--capture-stdout', '-cs', action='store_true', default=False, dest='capture_stdout', help='Tell pytest to capture stdout when certain tests fail.')
def parseArgs(): parser = argparse.ArgumentParser(prog="Honey.py", description=USAGE, \ formatter_class=argparse.RawDescriptionHelpFormatter) #parser.add_argument("-h", "--help", action="store_true") parser.add_argument("stage", metavar="STAGE", choices=STAGES.keys(), type=str, \ help="Stage to execute") parser.add_argument("options", metavar="OPTIONS", nargs=argparse.REMAINDER,\ help="Options to pass to the stage") args = parser.parse_args() sys.stderr.write(""" Please Cite: English, Adam C., William J. Salerno, Jeffery G. Reid. "PBHoney: identyfying genomic variants via long-read discordance and interrupted mapping." BMC Bioinformatics 2014, 15:180 (June 10, 2014). doi:10.1186/1471-2105-15-180\n\n""") STAGES[args.stage](args.options)
def parse_args(): """Parse input arguments.""" parser = argparse.ArgumentParser(description='Faster R-CNN demo') parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--def', dest='prototxt', help='prototxt file defining the network', default=None, type=str) parser.add_argument('--net', dest='caffemodel', help='model to test', default=None, type=str) parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use', default=0, type=int) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) args = parser.parse_args() return args
def _init_start(self): """ Inits the subparser that handles the start command. """ def start(core, args): task = ' '.join(args.task) if args.task else '' return core.start(task=task) usage = 'stl start [task]' desc = ( 'make a log that you are starting to work' ) subp = self.subparsers.add_parser('start', usage=usage, description=desc, help=desc) subp.add_argument('task', nargs=argparse.REMAINDER, help='the task that you are about to start working on') subp.set_defaults(func=start)
def _init_switch(self): """ Inits the subparser that handles the switch command. """ def switch(core, args): task = ' '.join(args.task) if args.task else '' return core.switch(task=task) usage = 'stl switch [task]' desc = ( 'shortcut for stl stop && stl start; ' 'stop the current task and immediately start another one' ) subp = self.subparsers.add_parser('switch', usage=usage, description=desc, help=desc[:desc.find(';')]) subp.add_argument('task', nargs=argparse.REMAINDER, help='the task that you are about to start working on') subp.set_defaults(func=switch)
def _init_edit(self): """ Inits the subparser that handles the edit command. """ def edit(core, args): month = ' '.join(getattr(args, 'month', [])) core.edit(month) usage = 'stl edit [month]' desc = ( 'lets you vim the right file' ) subp = self.subparsers.add_parser('edit', usage=usage, description=desc, help=desc) subp.add_argument('month', nargs=argparse.REMAINDER, help='the month you want to edit, e.g. oct 2016') subp.set_defaults(func=edit)
def main(): """ launch the screen """ cli = argparse.ArgumentParser() cli.add_argument("-p", "--port", default=60601, type=int, help="port to listen on") cli.add_argument("-l", "--listen", default="0.0.0.0", help="ip to listen on") cli.add_argument("-m", "--music", action="store_true", help="control mpd player by pausing and unpausing") cli.add_argument("--mpdhost", default=None, help="server where mpd is reached") cli.add_argument("--mpdport", default=None, help="port where mpd is reached") cli.add_argument("options", default="", nargs=argparse.REMAINDER, help="mpv options") args = cli.parse_args() screen = VideoScreen(args) screen.launch()
def main(): parser = argparse.ArgumentParser(description='Run commands to index and analyze FCC comments') parser.add_argument('command', choices=['index', 'analyze', 'create', 'tag_sigterms', 'breached']) parser.add_argument('args', nargs=argparse.REMAINDER) args = parser.parse_args() { 'create': create_command, 'index': index_command, 'analyze': analyze_command, 'tag_sigterms': positive_sig_terms_command, 'breached': breached_command }[args.command](args.args)
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Test a Fast R-CNN network') parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--model', dest='model', help='model to test', default=None, type=str) parser.add_argument('--imdb', dest='imdb_name', help='dataset to test', default='voc_2007_test', type=str) parser.add_argument('--comp', dest='comp_mode', help='competition mode', action='store_true') parser.add_argument('--num_dets', dest='max_per_image', help='max number of detections per image', default=100, type=int) parser.add_argument('--tag', dest='tag', help='tag of the model', default='', type=str) parser.add_argument('--net', dest='net', help='vgg16, res50, res101, res152, mobile', default='res50', type=str) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Convert an old VGG16 snapshot to new format') parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--snapshot', dest='snapshot', help='vgg snapshot prefix', type=str) parser.add_argument('--imdb', dest='imdb_name', help='dataset to train on', default='voc_2007_trainval', type=str) parser.add_argument('--iters', dest='max_iters', help='number of iterations to train', default=70000, type=int) parser.add_argument('--tag', dest='tag', help='tag of the model', default=None, type=str) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Train a Fast R-CNN network') parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--weight', dest='weight', help='initialize with pretrained model weights', type=str) parser.add_argument('--imdb', dest='imdb_name', help='dataset to train on', default='voc_2007_trainval', type=str) parser.add_argument('--imdbval', dest='imdbval_name', help='dataset to validate on', default='voc_2007_test', type=str) parser.add_argument('--iters', dest='max_iters', help='number of iterations to train', default=70000, type=int) parser.add_argument('--tag', dest='tag', help='tag of the model', default=None, type=str) parser.add_argument('--net', dest='net', help='vgg16, res50, res101, res152, mobile', default='res50', type=str) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def doJenkins(argv, bobRoot): subHelp = "\n ... ".join(sorted( [ "{} {}".format(c, d[1]) for (c, d) in availableJenkinsCmds.items() ])) parser = argparse.ArgumentParser(prog="bob jenkins", formatter_class=argparse.RawDescriptionHelpFormatter, description="""Configure jenkins. The following subcommands are available: bob jenkins {} """.format(subHelp)) parser.add_argument('subcommand', help="Subcommand") parser.add_argument('args', nargs=argparse.REMAINDER, help="Arguments for subcommand") parser.add_argument('-c', dest="configFile", default=[], action='append', metavar="NAME", help="Use additional config File.") args = parser.parse_args(argv) recipes = RecipeSet() recipes.defineHook('jenkinsNameFormatter', jenkinsNameFormatter) recipes.setConfigFiles(args.configFile) recipes.parse() if args.subcommand in availableJenkinsCmds: BobState().setAsynchronous() try: availableJenkinsCmds[args.subcommand][0](recipes, args.args) except http.client.HTTPException as e: raise BuildError("HTTP error: " + str(e)) except OSError as e: raise BuildError("OS error: " + str(e)) finally: BobState().setSynchronous() else: parser.error("Unknown subcommand '{}'".format(args.subcommand))
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Test a DPL network') parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use', default=0, type=int) parser.add_argument('--def', dest='prototxt', help='prototxt file defining the network', default=None, type=str) parser.add_argument('--net', dest='caffemodel', help='model to test', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--wait', dest='wait', help='wait until net file exists', default=True, type=bool) parser.add_argument('--imdb', dest='imdb_name', help='dataset to test', default='voc_2007_test', type=str) parser.add_argument('--comp', dest='comp_mode', help='competition mode', action='store_true') parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) parser.add_argument('--task', dest='task', default=None, type=str) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Train a DPL network') parser.add_argument('--gpu', dest='gpu_id', help='GPU device id to use [0]', default=0, type=int) parser.add_argument('--solver', dest='solver', help='solver prototxt', default=None, type=str) parser.add_argument('--iters', dest='max_iters', help='number of iterations to train', default=80000, type=int) parser.add_argument('--weights', dest='pretrained_model', help='initialize with pretrained model weights', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--imdb', dest='imdb_name', help='dataset to train on', default='voc_2007_trainval', type=str) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Test a Fast R-CNN network') parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use', default=0, type=int) parser.add_argument('--def', dest='prototxt', help='prototxt file defining the network', default=None, type=str) parser.add_argument('--net', dest='caffemodel', help='model to test', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--wait', dest='wait', help='wait until net file exists', default=True, type=bool) parser.add_argument('--imdb', dest='imdb_name', help='dataset to test', default='voc_2007_test', type=str) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Test a Fast R-CNN network') parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use', default=0, type=int) parser.add_argument('--def', dest='prototxt', help='prototxt file defining the network', default=None, type=str) parser.add_argument('--net', dest='caffemodel', help='model to test', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--wait', dest='wait', help='wait until net file exists', default=True, type=bool) parser.add_argument('--imdb', dest='imdb_name', help='dataset to test', default='voc_2007_test', type=str) parser.add_argument('--comp', dest='comp_mode', help='competition mode', action='store_true') parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) parser.add_argument('--vis', dest='vis', help='visualize detections', action='store_true') parser.add_argument('--num_dets', dest='max_per_image', help='max number of detections per image', default=100, type=int) parser.add_argument('--det_thresh', dest='det_thresh', help='detection score threshold', default=0.05, type=float) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Train a Faster R-CNN network') parser.add_argument('--gpu', dest='gpu_id', help='GPU device id to use [0]', default=0, type=int) parser.add_argument('--net_name', dest='net_name', help='network name (e.g., "ZF")', default=None, type=str) parser.add_argument('--weights', dest='pretrained_model', help='initialize with pretrained model weights', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--imdb', dest='imdb_name', help='dataset to train on', default='voc_2007_trainval', type=str) parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Train a Fast R-CNN network') parser.add_argument('--gpu', dest='gpu_id', help='GPU device id to use [0]', default=0, type=int) parser.add_argument('--solver', dest='solver', help='solver prototxt', default=None, type=str) parser.add_argument('--iters', dest='max_iters', help='number of iterations to train', default=40000, type=int) parser.add_argument('--weights', dest='pretrained_model', help='initialize with pretrained model weights', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--imdb', dest='imdb_name', help='dataset to train on', default='voc_2007_trainval', type=str) parser.add_argument('--rand', dest='randomize', help='randomize (do not use a fixed seed)', action='store_true') parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Test a Fast R-CNN network') parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use', default=0, type=int) parser.add_argument('--def', dest='prototxt', help='prototxt file defining the network', default=None, type=str) parser.add_argument('--net', dest='caffemodel', help='model to test', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--wait', dest='wait', help='wait until net file exists', default=True, type=bool) parser.add_argument('--imdb', dest='imdb_name', help='dataset to test', default='voc_2007_test', type=str) parser.add_argument('--comp', dest='comp_mode', help='competition mode', action='store_true') parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) parser.add_argument('--vis', dest='vis', help='visualize detections', action='store_true') parser.add_argument('--num_dets', dest='max_per_image', help='max number of detections per image', default=100, type=int) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def get_argparser(ArgumentParser=argparse.ArgumentParser): parser = ArgumentParser( description='Powerline BAR bindings.' ) parser.add_argument( '--i3', action='store_true', help='Subscribe for i3 events.' ) parser.add_argument( '--height', default='', metavar='PIXELS', help='Bar height.' ) parser.add_argument( '--interval', '-i', type=float, default=0.5, metavar='SECONDS', help='Refresh interval.' ) parser.add_argument( '--bar-command', '-C', default='lemonbar', metavar='CMD', help='Name of the lemonbar executable to use.' ) parser.add_argument( 'args', nargs=argparse.REMAINDER, help='Extra arguments for lemonbar. Should be preceded with ``--`` ' 'argument in order not to be confused with script own arguments.' ) return parser
def default(self, line): tab=line.split(" ",1) if tab[0] in self.aliases: arg_parser = PupyArgumentParser(prog=tab[0], add_help=False) arg_parser.add_argument('-f', '--filter', metavar='<client filter>', help="filter to a subset of all clients. All fields available in the \"info\" module can be used. example: run get_info -f 'platform:win release:7 os_arch:64'") arg_parser.add_argument('--bg', action='store_true', help="run in background") arg_parser.add_argument('arguments', nargs=argparse.REMAINDER, metavar='<arguments>', help="module arguments") if len(tab)==1: self.do_run(self.aliases[tab[0]]) else: left=[] try: modargs,left=arg_parser.parse_known_args(shlex.split(tab[1])) except PupyModuleExit: return #putting run arguments (-f and --bg) back at their place in case of aliases newargs_str="" if modargs.bg: newargs_str+=" --bg" if modargs.filter: newargs_str+=" -f '"+modargs.filter.replace("'","'\\''")+"'" newargs_str+=" "+self.aliases[tab[0]] if left: newargs_str+=" "+' '.join(left) if modargs.arguments: newargs_str+=" '"+(' '.join(modargs.arguments)).replace("'","'\\''")+"'" self.do_run(newargs_str.strip()) else: self.display_error("Unknown syntax: %s"%line)
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Test a Fast R-CNN network') parser.add_argument('--gpu', dest='gpu_id', help='GPU id to use', default=0, type=int) parser.add_argument('--def', dest='prototxt', help='prototxt file defining the network', default=None, type=str) parser.add_argument('--net', dest='caffemodel', help='model to test', default=None, type=str) parser.add_argument('--cfg', dest='cfg_file', help='optional config file', default=None, type=str) parser.add_argument('--wait', dest='wait', help='wait until net file exists', default=True, type=bool) parser.add_argument('--imdb', dest='imdb_name', help='dataset to test', default='voc_2007_test', type=str) parser.add_argument('--comp', dest='comp_mode', help='competition mode', action='store_true') parser.add_argument('--set', dest='set_cfgs', help='set config keys', default=None, nargs=argparse.REMAINDER) if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() return args
def main(): parser = argparse.ArgumentParser() parser.add_argument('--mode', choices=['clang', 'cl'], required=True, help='Specifies the compiler argument convention to use.') parser.add_argument('args', nargs=argparse.REMAINDER) parsed_args = parser.parse_args() prefix = '-Xclang' if parsed_args.mode == 'cl' else '-Xanalyzer' cmd = parsed_args.args + analyzer_enable_flags + \ interleave_args(analyzer_option_flags, prefix) returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(cmd)) sys.stderr.write(stderr) if returncode != 0: sys.stderr.write( """WARNING! The Clang static analyzer exited with error code %d. Please share the error details in crbug.com/695243 if this looks like a new regression.\n""" % (returncode)) returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(parsed_args.args)) sys.stderr.write(stderr) return returncode