Python argparse.RawTextHelpFormatter() Examples

The following are 30 code examples of argparse.RawTextHelpFormatter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module argparse , or try the search function .
Example #1
Source File: xnat_tools_utils.py    From dax with MIT License 6 votes vote down vote up
def parse_args(name, description, add_tools_arguments, purpose,
               extra_display=''):
    """
    Method to parse arguments base on argparse

    :param name: name of the script
    :param description: description of the script for help display
    :param add_tools_arguments: fct to add arguments to parser
    :param purpose: purpose of the script
    :param extra_display: extra display
    :return: parser object
    """
    from argparse import ArgumentParser, RawTextHelpFormatter
    parser = ArgumentParser(prog=name, description=description,
                            formatter_class=RawTextHelpFormatter)
    parser.add_argument('--host', dest='host', default=None,
                        help='Host for XNAT. Default: env XNAT_HOST.')
    parser.add_argument('-u', '--username', dest='username', default=None,
                        help='Username for XNAT.')
    parser = add_tools_arguments(parser)
    main_display(name, purpose, extra_display)
    args = parser.parse_args()
    args_display(args)
    return args 
Example #2
Source File: main.py    From raspiblitz with MIT License 6 votes vote down vote up
def main():
    # make sure CTRL+C works
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    description = """BlitzTUI - the Touch-User-Interface for the RaspiBlitz project

Keep on stacking SATs..! :-D"""

    parser = argparse.ArgumentParser(description=description, formatter_class=RawTextHelpFormatter)
    parser.add_argument("-V", "--version",
                        help="print version", action="version",
                        version=__version__)

    parser.add_argument('-d', '--debug', help="enable debug logging", action="store_true")

    # parse args
    args = parser.parse_args()

    if args.debug:
        setup_logging(log_level="DEBUG")
    else:
        setup_logging()

    log.info("Starting BlitzTUI v{}".format(__version__))

    # initialize app
    app = QApplication(sys.argv)

    w = AppWindow()
    w.show()

    # run app
    sys.exit(app.exec_()) 
Example #3
Source File: train.py    From DNA-GAN with MIT License 6 votes vote down vote up
def main():
    parser = argparse.ArgumentParser(description='test', formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument(
        '-a', '--attributes',
        nargs='+',
        type=str,
        help='Specify attribute name for training. \nAll attributes can be found in list_attr_celeba.txt'
    )
    parser.add_argument(
        '-g', '--gpu',
        default='0',
        type=str,
        help='Specify GPU id. \ndefault: %(default)s. \nUse comma to seperate several ids, for example: 0,1'
    )
    args = parser.parse_args()

    celebA = Dataset(args.attributes)
    DNA_GAN = Model(args.attributes, is_train=True)
    run(config, celebA, DNA_GAN, gpu=args.gpu) 
Example #4
Source File: transfer_gtex_to_s3.py    From toil-scripts with Apache License 2.0 6 votes vote down vote up
def build_parser():
    parser = argparse.ArgumentParser(description=main.__doc__, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument('-s', '--sra', default=None, required=True,
                        help='Path to a file with one analysis ID per line for data hosted on CGHub.')
    parser.add_argument('-k', '--dbgap_key', default=None, required=True,
                        help='Path to a CGHub key that has access to the TCGA data being requested. An exception will'
                             'be thrown if "-g" is set but not this argument.')
    parser.add_argument('--s3_dir', default=None, required=True, help='S3 Bucket. e.g. tcga-data')
    parser.add_argument('--ssec', default=None, required=True, help='Path to Key File for SSE-C Encryption')
    parser.add_argument('--single_end', default=None, action='store_true', help='Set this flag if data is single-end')
    parser.add_argument('--sudo', dest='sudo', default=None, action='store_true',
                        help='Docker usually needs sudo to execute locally, but not when running Mesos or when '
                             'the user is a member of a Docker group.')
    return parser


# Convenience Functions 
Example #5
Source File: PredictCommand.py    From aetros-cli with MIT License 6 votes vote down vote up
def main(self, args):

        from aetros.predict import predict
        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, prog=aetros.const.__prog__ + ' predict')
        parser.add_argument('id', nargs='?', help='the job id, e.g. peter/mnist/5d0f81d3ea73e8b2da3236c93f502339190c7037')
        parser.add_argument('--weights', help="Weights path. Per default we try to find it in the ./weights/ folder.")
        parser.add_argument('-i', nargs='+', help="Input (path or url). Multiple allowed")

        parsed_args = parser.parse_args(args)

        if not parsed_args.id:
            parser.print_help()
            sys.exit()

        if not parsed_args.i:
            parser.print_help()
            sys.exit()

        os.environ['KERAS_BACKEND'] = 'tensorflow'
        predict(self.logger, parsed_args.id, parsed_args.i, parsed_args.weights) 
Example #6
Source File: IdCommand.py    From aetros-cli with MIT License 6 votes vote down vote up
def main(self, args):
        import aetros.const

        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                         prog=aetros.const.__prog__ + ' id')

        parsed_args = parser.parse_args(args)
        config = read_home_config()


        try:
            user = api.user()
        except KeyNotConfiguredException as e:
            self.logger.error(str(e))
            sys.exit(1)

        print("Logged in as %s (%s) on %s" % (user['username'], user['name'], config['host']))

        if len(user['accounts']) > 0:
            for orga in six.itervalues(user['accounts']):
                print("  %s of organisation %s (%s)." % ("Owner" if orga['memberType'] == 1 else "Member", orga['username'], orga['name']))
        else:
            print("  Without membership to an organisation.") 
Example #7
Source File: GPUCommand.py    From aetros-cli with MIT License 6 votes vote down vote up
def main(self, args):
        import aetros.cuda_gpu

        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                         prog=aetros.const.__prog__ + ' gpu')

        try:
            print("CUDA version: " +str(aetros.cuda_gpu.get_version()))
        except aetros.cuda_gpu.CudaNotImplementedException:
            sys.stderr.write('It seems you dont have NVIDIA CUDA not installed properly.')
            sys.exit(2)

        for gpu in aetros.cuda_gpu.get_ordered_devices():
            properties = aetros.cuda_gpu.get_device_properties(gpu['device'], all=True)
            free, total = aetros.cuda_gpu.get_memory(gpu['device'])
            print("%s GPU id=%s %s (memory %.2fGB, free %.2fGB)" %(gpu['fullId'], str(gpu['id']), properties['name'], total/1024/1024/1024, free/1024/1024/1024)) 
Example #8
Source File: save_list_2_excel.py    From BerePi with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def parse_args():
    story = u"파일명, 데이터 시작셀과 마지막셀 입력"
    usg = u'\n python save_list.py -fname "sample" -s T4 -e T38'
    parser = argparse.ArgumentParser(description=story, usage=usg, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("-f", default="sample", help=u"파일명, e.g.) sample")
    parser.add_argument("-s", default='T4', help=u"데이터 시작 셀, e.g.) T4")
    parser.add_argument("-e", default='T38', help=u"데이터 마지막 셀, e.g.) T38")
    parser.add_argument("-n", default='test.py', help=u"생성할 파일명, e.g) test.py")
    args = parser.parse_args()

    # check
    f = args.f
    s = args.s
    e = args.e
    n = args.n
    return f, s, e, n 
Example #9
Source File: assistant.py    From MMM-GoogleAssistant with MIT License 6 votes vote down vote up
def init_googleAssistant():
    parser = argparse.ArgumentParser(
        formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument('--credentials', type=existing_file,
                        metavar='OAUTH2_CREDENTIALS_FILE',
                        default=os.path.join(
                            os.path.expanduser('/home/pi/.config'),
                            'google-oauthlib-tool',
                            'credentials.json'
                        ),
                        help='Path to store and read OAuth2 credentials')
    args = parser.parse_args()
    with open(args.credentials, 'r') as f:
        credentials = google.oauth2.credentials.Credentials(token=None,
                                                            **json.load(f))

    with Assistant(credentials,"magic-mirror-device-id") as assistant:
        for event in assistant.start():
            process_event(event) 
Example #10
Source File: standardcitations.py    From 3gpp-citations with MIT License 6 votes vote down vote up
def parse_args(args):
    """
    Parse arguments
    """

    parser = argparse.ArgumentParser(
        description=DESCRIPTION,
        epilog=EPILOG,
        formatter_class=RawTextHelpFormatter)

    parser.add_argument('--input', '-i', metavar='INPUT',
                        required=True,
                        help=('The Excel file generated by and '
                              'exported from the 3GPP Portal '
                              '(https://portal.3gpp.org)'))
    parser.add_argument('--output', '-o', metavar='OUTPUT',
                        help=('The bib file to write to. '
                              'STDOUT is used if omitted.'))
    parser.add_argument('--xelatex',
                        action='store_true',
                        help='Use line breaks')

    args = parser.parse_args(args)

    return args 
Example #11
Source File: config.py    From grimoire with GNU Affero General Public License v3.0 6 votes vote down vote up
def __load_arguments(self):
        modes = ["m32", "m64"]
        modes_help = 'm32\tpack and compile as an i386   executable.\n' \
                     'm64\tpack and compile as an x86-64 executable.\n'

        parser = ArgsParser(formatter_class=argparse.RawTextHelpFormatter)

        parser.add_argument('binary_file', metavar='<Executable>', action=FullPath, type=parse_is_file,
                            help='path to the user space executable file.')
        parser.add_argument('output_dir', metavar='<Output Directory>', action=FullPath, type=parse_is_dir,
                            help='path to the output directory.')
        parser.add_argument('mode', metavar='<Mode>', choices=modes, help=modes_help)
        parser.add_argument('-args', metavar='<args>', help='define target arguments.', default="", type=str)
        parser.add_argument('-file', metavar='<file>', help='write payload to file instead of stdin.', default="",
                            type=str)
        parser.add_argument('--recompile', help='recompile all agents.', action='store_true', default=False)
        parser.add_argument('-m', metavar='<memlimit>', help='set memory limit [MB] (default 50 MB).', default=50,
                            type=int)
        parser.add_argument('--asan', help='disables memlimit (required for ASAN binaries)', action='store_true', default=False)

        self.argument_values = vars(parser.parse_args()) 
Example #12
Source File: osc_tools.py    From upload-scripts with MIT License 6 votes vote down vote up
def add_upload_parser(subparsers: ArgumentParser):
    """Adds upload parser"""
    upload_parser = subparsers.add_parser('upload', formatter_class=RawTextHelpFormatter)
    upload_parser.set_defaults(func=upload_command)
    upload_parser.add_argument('-p',
                               '--path',
                               required=True,
                               help='Full path directory that contains sequence(s) '
                                    'folder(s) to upload')
    upload_parser.add_argument('-w',
                               '--workers',
                               required=False,
                               type=int,
                               default=10,
                               choices=range(1, 21),
                               metavar="[1-20]",
                               help='Number of parallel workers used to upload files. '
                                    'Default number is 10.')
    _add_environment_argument(upload_parser)
    _add_logging_argument(upload_parser) 
Example #13
Source File: daemon.py    From UnifiedMessageRelay with MIT License 6 votes vote down vote up
def main():
    # ARGS
    argP = argparse.ArgumentParser(
        description="QQ <-> Telegram Bot Framework & Forwarder", formatter_class=argparse.RawTextHelpFormatter)
    cmdHelpStr = """
start   - start bot as a daemon
stop    - stop bot
restart - restart bot
run     - run as foreground Debug mode. every log will print to screen and log to file.
"""
    argP.add_argument("command", type=str, action="store",
                      choices=['start', 'stop', 'restart', 'run'], help=cmdHelpStr)
    daemon = MainProcess('/tmp/coolq-telegram-bot.pid')
    args = argP.parse_args()
    if args.command == 'start':
        daemon.start(debug_mode=True)
    elif args.command == 'stop':
        daemon.stop()
    elif args.command == 'restart':
        daemon.restart(debug_mode=True)
    elif args.command == 'run':
        # Run as foreground mode
        daemon.run(debug_mode=True) 
Example #14
Source File: save_excel_2_list.py    From BerePi with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def parse_args():
    story = u"파일명, 데이터 시작셀과 마지막셀 입력"
    usg = u'\n python save_list.py -f "sample" -t 0 -s T4 -e T38'
    parser = argparse.ArgumentParser(description=story, usage=usg, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("-f", default="2017-07-24 17.12.00_new_ee_with_DB", help=u"파일명")
    parser.add_argument("-t", default="0", help=u"Sheet Tab: 0, 1, 2 ...")
    parser.add_argument("-s", default='G2', help=u"데이터 시작 셀")
    parser.add_argument("-e", default='G746', help=u"데이터 마지막 셀")
    args = parser.parse_args()

    # check
    f = args.f
    t = args.t
    s = args.s
    e = args.e
    return f, t, s, e 
Example #15
Source File: ModelCommand.py    From aetros-cli with MIT License 6 votes vote down vote up
def main(self, args):
        import aetros.const

        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                         prog=aetros.const.__prog__ + ' model')

        parsed_args = parser.parse_args(args)

        home_config = read_home_config()
        config_path = find_config_path()

        if not config_path:
            print("No model configuration file (aetros.yml). Switch to a directory first..")
            sys.exit(1)

        config = find_config(error_on_missing=True)
        print("Model %s in %s used in all aetros commands." % (config['model'], os.path.dirname(config_path)))

        git_remote_url = 'git@%s:%s.git' % (home_config['host'], config['model'])
        print("Git url: %s" % (git_remote_url,)) 
Example #16
Source File: manly.py    From manly with MIT License 5 votes vote down vote up
def main():
    parser = argparse.ArgumentParser(
        prog="manly",
        description="Explain how FLAGS modify a COMMAND's behaviour.",
        epilog=USAGE_EXAMPLE,
        formatter_class=argparse.RawTextHelpFormatter,
    )
    parser.add_argument("command", nargs=argparse.REMAINDER, help="")
    parser.add_argument(
        "-v",
        "--version",
        action="version",
        version=VERSION,
        help="display version information and exit.",
    )
    args = parser.parse_args()

    if not len(args.command):
        print_err(
            "manly: missing COMMAND\nTry 'manly --help' for more information.",
        )
        sys.exit(1)

    title, output = manly(args.command)
    if output:
        print("\n%s" % title)
        print("=" * (len(title) - 8), end="\n\n")
        for flag in output:
            print(flag, end="\n\n")
    else:
        print_err("manly: No matching flags found.") 
Example #17
Source File: build_midas_db.py    From MIDAS with GNU General Public License v3.0 5 votes vote down vote up
def fetch_arguments():
	parser = argparse.ArgumentParser(
		formatter_class=argparse.RawTextHelpFormatter,
		usage=argparse.SUPPRESS,
		description="""
Description:
This script will allow you to build your own custom MIDAS database
Usage: build_midas_db.py indir mapfile outdir [options]
""")
	parser.add_argument('indir', type=str,
		help="""Path to directory of input genomes
Each subdirectory should be named according to a genome_id
Each subdirectory should contain (replace genome_id):
  genome_id.fna: Genomic DNA sequence in FASTA format
  genome_id.ffn: Gene DNA sequences in FASTA format
  genome_id.faa: Translated genes in FASTA format
""")
	parser.add_argument('mapfile', type=str,
		help="""Path to mapping file that specifies which genomes belonging to the same species.
The file should be tab-delimited file with a header and 3 fields:
  genome_id (CHAR): corresponds to subdirectory within INDIR
  species_id (CHAR): species identifier for genome_id
  rep_genome (0 or 1): indicator if genome_id should be used for SNP calling
""")
	parser.add_argument('outdir', type=str,
		help="Directory to store MIDAS database")
	parser.add_argument('--threads', type=str, metavar='INT', default=1,
		help="Number of threads to use (1)")
	parser.add_argument('--compress', action='store_true', default=False,
		help="Compress output files with gzip (False)")
	parser.add_argument('--max_species', type=int, default=float('inf'), metavar='INT',
		help="Maximum number of species to process from input (use all).\nUseful for quick tests")
	parser.add_argument('--max_genomes', type=int, default=float('inf'), metavar='INT',
		help="Maximum number of genomes to process per species (use all).\nUseful for quick tests")
	parser.add_argument('--max_length', type=int, default=20000, metavar='INT',
		help="Maximum gene length to use (20000). \nVery long genes can be problemmatic for VSEARCH")
	parser.add_argument('--resume', action='store_true', default=False,
		help="Resume database building without starting over from scratch (False)")

	args = vars(parser.parse_args())
	return args 
Example #18
Source File: passmaker.py    From passmaker with GNU General Public License v3.0 5 votes vote down vote up
def parse_args():
    parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter, description= \
        "Usage: python passmaker.py <OPTIONS> \n")

    menu_group = parser.add_argument_group('Menu Options')

    menu_group.add_argument('-o', '--output', help="password dict file", default=None)
    menu_group.add_argument('-i', '--interactive', help="interactive mode",action='store_true',default=False)
    menu_group.add_argument('-g', '--gui', help="GUI mode", action='store_true', default=False)

    argcomplete.autocomplete(parser)
    args = parser.parse_args()

    return args 
Example #19
Source File: test_components_bump.py    From skelebot with MIT License 5 votes vote down vote up
def test_addParsers(self):
        bump = sb.components.bump.Bump()

        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
        subparsers = parser.add_subparsers(dest="job")
        subparsers = bump.addParsers(subparsers)

        self.assertNotEqual(subparsers.choices["bump"], None) 
Example #20
Source File: erase_annoying_sequences.py    From YAMDA with MIT License 5 votes vote down vote up
def get_args():
    parser = argparse.ArgumentParser(description="Train model.",
                                     epilog='\n'.join(__doc__.strip().split('\n')[1:]).strip(),
                                     formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument('-i', '--input', required=True,
                        help='Input FASTA file', type=str)
    parser.add_argument('-o', '--output', default=None,
                        help='Output FASTA file of negative sequences', type=str)
    args = parser.parse_args()
    return args 
Example #21
Source File: tsdb_read.py    From BerePi with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def parse_args():
    story = 'OpenTSDB needs many arguments URL, start time, end time, port '
    usg = '\n python tsdb_read.py  -url x.x.x.x -port 4242 -start 2016110100 -end 2016110222, --help for more info'
    parser=argparse.ArgumentParser(description=story, usage=usg, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("-url",    default='localhost', help="URL input, or run fails")
    parser.add_argument("-start",  default=None, help="start time input, like 2016110100")
    parser.add_argument("-end",    default=None, help="end time input, like 2016110223")
    parser.add_argument("-port",   default='4242', help="port input, like 4242")
    parser.add_argument("-recent", default=None, help="Time input for recent value")
    parser.add_argument("-m", default=None, help="metric ")
    args = parser.parse_args()
    #check args if valid
    url = args.url
    port = args.port
    if port != None : port = ':' + args.port
    else : port = ''
    if url != None : url = 'http://' + url + port + '/api/query?'
    else : exit("... please input URL and other arguments")

    start = args.start
    if start != None : start = args.start
    end = args.end
    if end != None : end = args.end
    recent = args.port
    if recent != None : recent = args.recent
    m = args.m
    #print args
    return url, port, start, end, recent, m 
Example #22
Source File: put_test.py    From BerePi with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def parse_args():

    story = 'OpenTSDB needs many arguments URL, start time, end time, port '
    usg = '\n python tsdb_read.py  -url x.x.x.x \
        -port 4242 -start 2016110100 -end 2016110222 \
        -rdm metric_name, -wm write_metric_name -tags="{id:911}" --help for more info'

    parser=argparse.ArgumentParser(description=story,
        usage=usg,
        formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument("-url",    default="127.0.0.1",
        help="URL input, or run fails")
    parser.add_argument("-start",  default='2016070100',
        help="start time input, like 2016110100")
    parser.add_argument("-port",   default=4242,
        help="port input, like 4242")
    parser.add_argument("-val", default=802,
        help="value which will be inserted to OpenTSDB")
    parser.add_argument("-wtm", default='__keti_test__',
        help="write-metric ")
    parser.add_argument("-tags", default="{'sensor':'_test_sensor_', 'desc':'_test_'}",
        help="tags ")
    args = parser.parse_args()

    #check args if valid
    url = args.url
    _ht = 'http://'
    if ( url[:7] != _ht ) : url = _ht + url
    port = args.port
    if  port == 80 : port = ''
    else : port = ":"+ str(port)
    url = url + port +'/api/put'


    wm = args.wtm
    if wm == None :
        print usg
        exit("... I can not do anything without metric")

    return url, wm, args.start, args.val, args.tags 
Example #23
Source File: useTSDB.py    From BerePi with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def parse_args():
    story = 'OpenTSDB needs many arguments URL, start time, end time, port '
    usg = '\n python tsdb_read.py  -url x.x.x.x -port 4242 -start 2016110100 -end 2016110222, --help for more info'
    parser=argparse.ArgumentParser(description=story, usage=usg, formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("-url",    default="localhost", help="URL input, or run fails")
    parser.add_argument("-start",  default=None, help="start time input, like 2016110100")
    parser.add_argument("-end",    default=None, help="end time input, like 2016110223")
    parser.add_argument("-port",   default=4242, help="port input, like 4242")
    parser.add_argument("-recent", default=None, help="Time input for recent value")
    parser.add_argument("-m", default=None, help="metric ")
    args = parser.parse_args()
    
    #check args if valid
    url = args.url
    _ht = 'http://'
    if ( url[:7] != _ht ) : url = _ht + url
    port = args.port
    if  port == 80 : port = ''
    else : port = ":"+ str(port)
    url = url + port +'/api/query?'

    start = args.start
    if start != None : start = args.start
    end = args.end
    if end != None : end = args.end

    recent = args.port
    if recent != None : recent = args.recent

    m = args.m
    if m == None : exit("... please input metric name")
    
    return url, port, start, end, recent, m 
Example #24
Source File: watch.py    From BerePi with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def parse_args():
    parser=argparse.ArgumentParser(description="how to run, watch.py", usage='use "%(prog)s --help" for more information', formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("-ip", "--ipaddress", default="0.0.0.0:0000", help="input ip address of iot db")
    parser.add_argument("-id", "--nodeid", default="-1", help="input id of iot device")
    args = parser.parse_args()
    return args 
Example #25
Source File: test_components_dexec.py    From skelebot with MIT License 5 votes vote down vote up
def test_addParsers(self):
        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
        subparsers = parser.add_subparsers(dest="job")
        dexec = sb.components.dexec.Dexec()
        subparsers = dexec.addParsers(subparsers)

        self.assertNotEqual(subparsers.choices["exec"], None) 
Example #26
Source File: test_components_registry.py    From skelebot with MIT License 5 votes vote down vote up
def test_addParsers(self):
        registry = sb.components.registry.Registry(host="docker.io", port=88, user="skelebot")

        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
        subparsers = parser.add_subparsers(dest="job")
        subparsers = registry.addParsers(subparsers)

        self.assertNotEqual(subparsers.choices["publish"], None) 
Example #27
Source File: tsdb_temperature.py    From BerePi with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def parse_args():
    parser=argparse.ArgumentParser(description="how to run, watch.py", usage='use "%(prog)s --help" for more information', formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("-ip", "--ipaddress", default="0.0.0.0:0000", help="input ip address of iot db")
    parser.add_argument("-id", "--nodeid", default="-1", help="input id of iot device")
    args = parser.parse_args()
    return args 
Example #28
Source File: test_components_prime.py    From skelebot with MIT License 5 votes vote down vote up
def test_addParsers(self):
        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
        subparsers = parser.add_subparsers(dest="prime")
        prime = sb.components.prime.Prime()
        subparsers = prime.addParsers(subparsers)

        self.assertNotEqual(subparsers.choices["prime"], None) 
Example #29
Source File: hist_importer.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def parse():
    """Parse command line arguments."""
    description = ("This program is meant to extract browser history from your"
                   " previous browser and import them into qutebrowser.")
    epilog = ("Databases:\n\n\tqutebrowser: Is named 'history.sqlite' and can "
              "be found at your --basedir. In order to find where your "
              "basedir is you can run ':open qute:version' inside qutebrowser."
              "\n\n\tFirefox: Is named 'places.sqlite', and can be found at "
              "your system's profile folder. Check this link for where it is "
              "located: http://kb.mozillazine.org/Profile_folder"
              "\n\n\tChrome: Is named 'History', and can be found at the "
              "respective User Data Directory. Check this link for where it is"
              "located: https://chromium.googlesource.com/chromium/src/+/"
              "master/docs/user_data_dir.md\n\n"
              "Example: hist_importer.py -b firefox -s /Firefox/Profile/"
              "places.sqlite -d /qutebrowser/data/history.sqlite")
    parser = argparse.ArgumentParser(
        description=description, epilog=epilog,
        formatter_class=argparse.RawTextHelpFormatter
    )
    parser.add_argument('-b', '--browser', dest='browser', required=True,
                        type=str, help='Browsers: {firefox, chrome}')
    parser.add_argument('-s', '--source', dest='source', required=True,
                        type=str, help='Source: Full path to the sqlite data'
                        'base file from the source browser.')
    parser.add_argument('-d', '--dest', dest='dest', required=True, type=str,
                        help='\nDestination: Full path to the qutebrowser '
                        'sqlite database')
    return parser.parse_args() 
Example #30
Source File: ApiCommand.py    From aetros-cli with MIT License 5 votes vote down vote up
def main(self, args):
        import aetros.const

        parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                description="You can provide json in stdin to issue a POST call", prog=aetros.const.__prog__ + ' api')
        parser.add_argument('path', nargs='?', help="Request path + query, e.g. model/settings?name=owner/name")
        parser.add_argument('--method', nargs='?', help="Per default GET, if stdin data is given a POST. Alternatively provide a HTTP verb.")

        parsed_args = parser.parse_args(args)

        if not parsed_args.path:
            parser.print_help()
            sys.exit(1)

        sys.stdout.write(api.request(parsed_args.path))