Beispiel #1
0
 def __init__(self):
     ArgumentParser.__init__(
         self, prog="see", description="Mark episodes as SEEN", epilog="example: see lost.s01* lost.s02*"
     )
     self.add_argument(
         "filters", metavar="EPISODE", nargs="+", default=[""], help="episode name or filter, ex: lost.s01e0*"
     )
Beispiel #2
0
def rpt_compare(args):
    '''
    Analyze package test results by comparing test output with GnuR output.
    Uses either a specific directory, i.e. the 'test' subdirectory of the --testdir argument
    or (default) the latest downloaded results from the --logdir directory
    Return 0 if passed, non-zero if failed
    '''
    parser = ArgumentParser(prog='mx rpt-compare')
    _add_common_args(parser)
    parser.add_argument('--testdir', action='store', help='specific dir containing fastr results')
    parser.add_argument('--pkg', action='store', help='pkg to compare')
    parser.add_argument('--diff', action='store_true', help='execute given diff program on differing outputs')
    parser.add_argument('--difftool', action='store', help='diff tool', default='diff')
    _add_pattern_arg(parser)
    args = _check_verbose(parser.parse_args(args))

    if args.pkg:
        # backwards compatibility
        args.pattern = args.pkg

    gnur = _gather_test_outputs(join(os.getcwd(), "test_gnur"))

    if args.testdir:
        fastr = _gather_test_outputs(join(args.testdir, "test"))
    else:
        fastr = _get_test_outputs(_gather_all_test_outputs(args.logdir))

    rdict = _rpt_compare_pkgs(gnur, fastr, args.verbose, args.pattern, args.diff, args.difftool)
    for _, rc in rdict.iteritems():
        if rc == 1:
            return 1
    return 0
Beispiel #3
0
def rpt_install_status(args):
    parser = ArgumentParser(prog='mx rpt-install-status')
    parser.add_argument('--detail', action='store_true', help='display package status')
    parser.add_argument('--displaymode', action='store', default='latest', help='display mode: all | latest')
    parser.add_argument('--failed', action='store_true', help='list packages that failed to install')
    parser.add_argument('--ok-any', action='store_true', help='treat as OK if a package ever installed')
    _add_pattern_arg(parser)
    _add_common_args(parser)
    args = _check_verbose(parser.parse_args(args))

    pkgtable = _build_pkgtable(_get_results(args.logdir))

    pkgnames = []
    for pkgname, occurrences in pkgtable.iteritems():
        if re.search(args.pattern, pkgname) is None:
            continue
        status = _check_any_ok(occurrences, args.ok_any)
        if args.failed:
            if not status:
                pkgnames.append(pkgname)
        else:
            if status:
                pkgnames.append(pkgname)

    pkgnames.sort()
    for pkgname in pkgnames:
        print pkgname
        if args.detail:
            if args.displaymode == 'all':
                occurrences = pkgtable[pkgname]
                for occurrence in occurrences:
                    print "  ${0}".format(str(occurrence))
            else:
                print "  ${0}".format(str(occurrences[0]))
def main():
    opt_parser = ArgumentParser(
        description="Manage annotation databases of region_analysis.",
        prog="region_analysis_db.py")
    subparsers = opt_parser.add_subparsers(title="Subcommands",
                                           help="additional help")

    # list parser.
    parser_list = subparsers.add_parser("list", help="List genomes installed \
                                                      in database")
    parser_list.set_defaults(func=listgn)

    # install parser.
    parser_install = subparsers.add_parser("install",
                                           help="Install genome from tar.gz \
                                                  package file")
    parser_install.add_argument("pkg", help="Package file(.tar.gz) to install",
                                type=str)
    parser_install.set_defaults(func=install)
    parser_install.add_argument(
        "-y", "--yes", help="Say yes to all prompted questions",
        action="store_true")

    # remove parser.
    parser_remove = subparsers.add_parser("remove",
                                          help="Remove genome from database")
    parser_remove.add_argument("gn", help="Name of genome to be \
                                           removed(e.g. hg19)", type=str)
    parser_remove.set_defaults(func=remove)
    parser_remove.add_argument(
        "-y", "--yes", help="Say yes to all prompted questions",
        action="store_true")

    args = opt_parser.parse_args()
    args.func(args)
Beispiel #5
0
def parseargs():
    parser = ArgumentParser(description='Writes some data on mutliple autodetected USB devices. Be careful, they will be formatted!')
    parser.add_argument('data',help="The upper most folder which need to be transferred on all usb Sticks")
    parser.add_argument('-l','--loop',action='store_true',help='Activates the loop, which will then let the program wait for any new devices plugged in. Abort by CRTL+C')
    parser.add_argument('-f','--format',required=False,choices=["ntfs","fat32"],default=formats[0],help="Formats the sticks, default format %(default)s")
    parser.add_argument('-fl','--formatlabel',required=False,type=str,help="Formats the Devices with this Label")
    return parser.parse_args()
 def run(cls):
     parser = ArgumentParser(
         description=("The theme development utility. "
                      "Includes three modes: "
                      "one for serving a theme compiled on-the-fly, "
                      "the other for compiling statically a theme "
                      "and the latter to dump URLs to files")
     )
     subparsers = parser.add_subparsers(
         title="Commands",
         description="Available commands (modes of operation)"
     )
     for key, target in cls.commands.items():
         if target is None:
             target = cls
         else:
             target = getattr(cls, target)
         subparser = subparsers.add_parser(
             key,
             description=target.__doc__,
             help=target.__doc__.splitlines()[0]
         )
         target.setup_parser(subparser)
         subparser.set_defaults(target=target)
     args = parser.parse_args()
     if hasattr(args, 'target'):
         sys.exit(args.target.main(args))
     else:
         parser.print_usage()
         sys.exit(-1)
Beispiel #7
0
def parse_args():
    parser = ArgumentParser()
    parser.add_argument('-v', '--version', action='version', version='0.2')
    parser.add_argument('-c', '--configuration', default=expanduser("~") + '/.stools/configuration.cfg')
    parser.add_argument('-e', '--execute', nargs='*')
    parser.add_argument('-l', '--log', default='ERROR')
    return parser.parse_args()
Beispiel #8
0
def main():
    p = ArgumentParser(description='Plots spectral transmission data from filter datasheets')
    p.add_argument('--wlnm', help='START STOP STEP wavelength in nm', nargs=3, default=(200., 1200., 0.1), type=float)
    p.add_argument('--path', help='path to HDF5 data')
    p.add_argument('-a', '--altkm', help='observer altitude (km)', type=float, default=0.)
    p.add_argument('--zenang', help='zenith angle (deg)', type=float, default=0.)
    p = p.parse_args()

    inpath = Path(p.path).expanduser() if p.path else R / 'gridaurora/precompute'

    flist = ['BG3transmittance.h5', 'NE01transmittance.h5',
             'Wratten32transmittance.h5', 'Wratten21transmittance.h5',
             'HoyaV10transmittance.h5']
    flist = [inpath/f for f in flist]

    windFN = inpath/'ixonWindowT.h5'
    qeFN = inpath/'emccdQE.h5'
# %%
    Ts = []
    for f in flist:
        T = selftest(f, windFN, qeFN, p.wlnm, p.altkm, p.zenang)
        Ts.append(T)
        plotT(T, p.wlnm)
# %%
    comparefilters(Ts)

    show()
def parseArgs():
    parser = ArgumentParser(
        description = 'Convert Entrez Gene Homo_sapiens.xml to python dictionary representation')
    parser.add_argument(
        '--Hsxml', metavar = 'HSXML', type = file, required = True,
        help = 'Name of Homo_sapiens.xml file - include a date reference for download for example')
    return parser.parse_args()
Beispiel #10
0
    def __init__(self, context):
        super(ReconfClientPlugin, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('ReconfClientPlugin')

        # Process standalone plugin command-line arguments
        from argparse import ArgumentParser
        parser = ArgumentParser()
        # Add argument(s) to the parser.
        parser.add_argument("-q", "--quiet", action="store_true",
                      dest="quiet",
                      help="Put plugin in silent mode")
        args, unknowns = parser.parse_known_args(context.argv())
        if not args.quiet:
            print 'arguments: ', args
            print 'unknowns: ', unknowns

        # Create QWidget
        self._widget = tiny_ref_gui.ReconfigureWidget()
        # Show _widget.windowTitle on left-top of each plugin (when 
        # it's set in _widget). This is useful when you open multiple 
        # plugins at once. Also if you open multiple instances of your 
        # plugin at once, these lines add number to make it easy to 
        # tell from pane to pane.
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
        # Add widget to the user interface
        #parent = QTreeWidgetItem(self._widget.parameterTree)
        #parent.setText(0, "Name {}".format(2))
        #parent.setText(1, "Type")
        #parent.setText(2, "Value")
        #parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable | Qt.ItemIsEditable)
        context.add_widget(self._widget)
Beispiel #11
0
def parse_args():
    parser = ArgumentParser()

    parser.add_argument(
        '--force-update-mpt',
        action='store_true',
        help='Update MyPyTutor even if this would not normally be required',
    )
    parser.add_argument(
        '--force-update-tutorials',
        action='store_true',
        help='Update tutorials even if this would not normally be required',
    )
    parser.add_argument(
        '--no-gui',
        action='store_true',
        help='Run the installer without using a GUI',
    )
    parser.add_argument(
        '--version',
        '--version',
        action='store_true',
        help='Print the version and then terminate',
    )

    return parser.parse_args()
def query_main(graph, default_index):
    """
    Run a query.

    """
    parser = ArgumentParser()
    parser.add_argument("-i", "--index", default=default_index)
    parser.add_argument("-q", "--query", default='{"match_all": {}}')
    parser.add_argument("-f", "--flat", action="store_true")
    args = parser.parse_args()

    try:
        query = loads(args.query)
    except Exception:
        parser.error("query must be valid json")

    response = graph.elasticsearch_client.search(
        index=args.index,
        body=dict(query=query),
    )

    if args.flat:
        return response["hits"]["hits"]
    else:
        return response
Beispiel #13
0
def main():
    parser = ArgumentParser()
    parser.add_argument('file', action='store')

    args = parser.parse_args()

    print_left_right( "left.txt", "right.txt", open(args.file).readlines() )
Beispiel #14
0
 def __init__(self):
     ArgumentParser.__init__(
         self, prog="format", description="print episodes with given formats", epilog="example: format lost*"
     )
     self.add_argument(
         "filters", metavar="EPISODE", nargs="*", default=["*"], help="episode name or filter, ex: lost.s01e0*"
     )
Beispiel #15
0
def main():
    set_stdout_encoding()

    parser = ArgumentParser(
        formatter_class=ArgumentDefaultsHelpFormatter,
        description='Convert text file to communication',
    )
    parser.set_defaults(annotation_level=AL_NONE)
    parser.add_argument('text_path', type=str,
                        help='Input text file path (- for stdin)')
    parser.add_argument('concrete_path', type=str,
                        help='Output concrete file path (- for stdout)')
    add_annotation_level_argparse_argument(parser)
    parser.add_argument('-l', '--loglevel', '--log-level',
                        help='Logging verbosity level threshold (to stderr)',
                        default='info')
    concrete.version.add_argparse_argument(parser)
    args = parser.parse_args()

    logging.basicConfig(format='%(asctime)-15s %(levelname)s: %(message)s',
                        level=args.loglevel.upper())

    # Won't work on Windows
    text_path = '/dev/fd/0' if args.text_path == '-' else args.text_path
    concrete_path = (
        '/dev/fd/1' if args.concrete_path == '-' else args.concrete_path
    )
    annotation_level = args.annotation_level

    with codecs.open(text_path, encoding='utf-8') as f:
        comm = create_comm(text_path, f.read(),
                           annotation_level=annotation_level)
        write_communication_to_file(comm, concrete_path)
Beispiel #16
0
def make_parser(prog):
    parser = ArgumentParser(prog)
    parser.add_argument('--version', action='version', version='%(prog)s ' + VERSION)

    command_parsers = parser.add_subparsers(metavar='command', dest='command')
    command_parsers.required = True

    command_search_parser = command_parsers.add_parser('search', help='search for items')
    command_search_parser.add_argument('type', help='type of item to search for',
                                       choices=['movie', 'person', 'character', 'company', 'keyword'])
    command_search_parser.add_argument('key', help='title or name of item to search for')
    command_search_parser.add_argument('-n', type=int, help='number of items to list')
    command_search_parser.add_argument('--first', action='store_true', help='display only the first result')
    command_search_parser.set_defaults(func=search_item)

    command_get_parser = command_parsers.add_parser('get', help='retrieve information about an item')
    command_get_parser.add_argument('type', help='type of item to retrieve',
                                    choices=['movie', 'person', 'character', 'company', 'keyword'])
    command_get_parser.add_argument('key', help='IMDb id (or keyword name) of item to retrieve')
    command_get_parser.add_argument('-n', type=int, help='number of movies to list (only for keywords)')
    command_get_parser.set_defaults(func=get_item)

    command_top_parser = command_parsers.add_parser('top', help='get top ranked movies')
    command_top_parser.add_argument('-n', type=int, help='number of movies to list')
    command_top_parser.add_argument('--first', action='store_true', help='display only the first result')
    command_top_parser.set_defaults(func=get_top_movies)

    command_bottom_parser = command_parsers.add_parser('bottom', help='get bottom ranked movies')
    command_bottom_parser.add_argument('-n', type=int, help='number of movies to list')
    command_bottom_parser.add_argument('--first', action='store_true', help='display only the first result')
    command_bottom_parser.set_defaults(func=get_bottom_movies)

    return parser
Beispiel #17
0
def parse_args():
    """parse command-line arguments"""
    parser = ArgumentParser(
        description=__doc__, formatter_class=ArgumentDefaultsHelpFormatter
    )
    parser.add_argument(
        '--infile', required=True,
        help='Input I3 filename'
    )
    parser.add_argument(
        '--outdir', default=None,
        help='Output directory'
    )
    #parser.add_argument(
    #    '--n-per-file', type=int, required=True,
    #    help='Maximum number of events per output file'
    #)
    parser.add_argument(
        '--n-total', type=int, default=None,
        help='''Total events to split out into sub-files; if not specified,
        take all (that pass --keep-criteria)'''
    )
    parser.add_argument(
        '--keep-criteria', type=str, default=None,
        help='''Criteria for choosing the event for splitting out; events that
        fail to meet the criteria will not count towards n-total or n-per-file.
        This will be evaluated where the `frame` variable is available to
        retrieve info from.'''
    )
    return parser.parse_args()
Beispiel #18
0
def _make_arg_parser():
    # this parser is never used for help messages, but
    # will show usage on error
    parser = ArgumentParser(usage=_USAGE, add_help=False)

    # add positional arguments
    parser.add_argument(dest='script_or_jar', nargs='?')
    parser.add_argument(dest='args', nargs='*')

    _add_basic_args(parser)
    _add_runner_alias_arg(parser)
    _add_help_arg(parser)
    _add_deprecated_arg(parser)

    # add runner opts
    runner_opt_names = set(_RUNNER_OPTS) - set(_HARD_CODED_OPTS)
    _add_runner_args(parser, opt_names=runner_opt_names)

    # add spark-specific opts (without colliding with runner opts)
    for opt_name, switch in _SPARK_SUBMIT_SWITCHES.items():
        if opt_name in _RUNNER_OPTS and switch not in _SWITCH_ALIASES:
            continue
        _add_spark_submit_arg(parser, opt_name)

    return parser
Beispiel #19
0
def main():
    """
    Parse arguments, set configuration values, then start the broker
    """
    parser = ArgumentParser(description="Crawl frontier worker.")
    parser.add_argument(
        '--config', type=str,
        help='Settings module name, should be accessible by import.')
    parser.add_argument(
        '--address', type=str,
        help='Hostname, IP address or Wildcard * to bind. Default is 127.0.0.1'
        '. When binding to wildcard it defaults to IPv4.')
    parser.add_argument(
        '--log-level', '-L', type=str, default='INFO',
        help='Log level, for ex. DEBUG, INFO, WARN, ERROR, FATAL. Default is'
        ' INFO.')
    parser.add_argument(
        '--port', type=int,
        help='Base port number, server will bind to 6 ports starting from base'
        '. Default is 5550')
    args = parser.parse_args()

    settings = Settings(module=args.config)
    address = args.address if args.address else settings.get("ZMQ_ADDRESS")
    port = args.port if args.port else settings.get("ZMQ_BASE_PORT")
    server = Server(address, port)
    server.logger.setLevel(args.log_level)
    server.start()
Beispiel #20
0
def _make_basic_help_parser(include_deprecated=False):
    """Make an arg parser that's used only for printing basic help.

    This prints help very similar to spark-submit itself. Runner args
    are not included unless they are also spark-submit args (e.g. --py-files)
    """
    help_parser = ArgumentParser(usage=_USAGE, description=_DESCRIPTION,
                                 epilog=_BASIC_HELP_EPILOG, add_help=False)

    _add_runner_alias_arg(help_parser)

    for group_desc, opt_names in _SPARK_SUBMIT_ARG_GROUPS:
        if group_desc is None:
            parser_or_group = help_parser
        else:
            parser_or_group = help_parser.add_argument_group(group_desc)

        for opt_name in opt_names:
            _add_spark_submit_arg(parser_or_group, opt_name)

        if group_desc is None:
            _add_basic_args(help_parser)
            _add_help_arg(help_parser)
            if include_deprecated:
                _add_deprecated_arg(help_parser)

    return help_parser
def main(argv=None):
    if argv is None:
        argv = sys.argv
    else:
        sys.argv.extend(argv)

    parser = ArgumentParser(
        description="PCAWG Report Generator Gathering Counts", formatter_class=RawDescriptionHelpFormatter
    )
    parser.add_argument(
        "-m", "--metadata_dir", dest="metadata_dir", help="Directory containing metadata manifest files", required=True
    )

    args = parser.parse_args()
    metadata_dir = args.metadata_dir  # this dir contains gnos manifest files, will also host all reports

    if not os.path.isdir(metadata_dir):  # TODO: should add more directory name check to make sure it's right
        sys.exit("Error: specified metadata directory does not exist!")

    report_name = re.sub(r"^pc_report-", "", os.path.basename(__file__))
    report_name = re.sub(r"\.py$", "", report_name)

    generate_report(metadata_dir, report_name)

    return 0
Beispiel #22
0
def _get_args():
    parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
                            description="Node Agent")
    subparsers = parser.add_subparsers(dest="mode")

    parser_cleanup = subparsers.add_parser('cleanup')
    parser_cleanup.add_argument("session", help="Session Name")
    parser_cleanup.add_argument("volume", help="Volume Name")
    parser_cleanup.add_argument("tmpfilename", help="Temporary File Name")
    parser_cleanup.add_argument("--debug", help="Debug", action="store_true")

    parser_session_create = subparsers.add_parser('create')
    parser_session_create.add_argument("session", help="Session Name")
    parser_session_create.add_argument("volume", help="Volume Name")
    parser_session_create.add_argument("brick", help="Brick Path")
    parser_session_create.add_argument("time_to_update", help="Time to Update")
    parser_session_create.add_argument("--reset-session-time",
                                       help="Reset Session Time",
                                       action="store_true")
    parser_session_create.add_argument("--debug", help="Debug",
                                       action="store_true")

    parser_post = subparsers.add_parser('post')
    parser_post.add_argument("session", help="Session Name")
    parser_post.add_argument("volume", help="Volume Name")
    parser_post.add_argument("brick", help="Brick Path")
    parser_post.add_argument("--debug", help="Debug",
                             action="store_true")

    parser_delete = subparsers.add_parser('delete')
    parser_delete.add_argument("session", help="Session Name")
    parser_delete.add_argument("volume", help="Volume Name")
    parser_delete.add_argument("--debug", help="Debug",
                               action="store_true")
    return parser.parse_args()
def cli(args=sys.argv[1:]):
    parser = ArgumentParser()
    parser.add_argument('-o', '--output-directory', dest='outdir',
        default=here, help="Directory to save runtime data.")

    parser.add_argument('-i', '--input-directory', dest='indir',
        default=here, help="Directory from which to read current runtime data.")

    parser.add_argument('-p', '--platforms', default=None,
        help="Comma separated list of platforms from which to generate data.")

    parser.add_argument('-s', '--suite', dest='suite', default=None,
        help="Suite for which to generate data.")

    args = parser.parse_args(args)

    if not args.suite:
        raise ValueError("Must specify suite with the -u argument")
    if ',' in args.suite:
        raise ValueError("Passing multiple suites is not supported")

    if args.platforms:
        args.platforms = args.platforms.split(',')

    data = query_activedata(args.suite, args.platforms)
    write_runtimes(data, args.suite, indir=args.indir, outdir=args.outdir)
Beispiel #24
0
def parse_options(args=None):
    if args is None:  # pragma: no cover
        args = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        '-i', '--incremental',
        metavar='PATH',
        help='trigger incremental crawl'
    )
    parser.add_argument(
        '-o', '--output',
        metavar='PATH',
        default=DEFAULT_OUTPUT_PATH,
        help='Override persisted data, [default=%(default)s]'
    )
    parser.add_argument(
        '-v', '--verbose',
        action='count',
        dest='verbose',
        help='set verbosity level',
        default=0
    )
    parser.add_argument(
        'crawls',
        metavar='CRAWL',
        nargs='*',
        help='Sub-set of crawls to launch'
    )

    return parser.parse_args(args)
Beispiel #25
0
def rpt_list_testdates(args):
    parser = ArgumentParser(prog='mx rpt-list-testdates')
    _add_common_args(parser)
    parser.add_argument('--printdir', action='store_true', help='print directory containing tests')
    _add_pattern_arg(parser)
    args = _check_verbose(parser.parse_args(args))
    fastr = dict()
    local_dirs = get_local_dirs(args.logdir)
    for local_dir in local_dirs:
        resultInfo = ResultInfo(local_dir)
        result_outputs = _gather_test_outputs(join(args.logdir, local_dir, "test"))
        for pkg, _ in result_outputs.iteritems():
            if re.search(args.pattern, pkg) is None:
                continue
            if not fastr.has_key(pkg):
                testdates = []
                fastr[pkg] = testdates
            else:
                testdates = fastr[pkg]
            testdates.append(resultInfo)

    for pkg, testdates in fastr.iteritems():
        sortedList = sorted(testdates, reverse=True)
        print pkg
        for resultInfo in sortedList:
            if args.printdir:
                print '  ' + join(args.logdir, resultInfo.localdir)
            else:
                print '  ' + str(resultInfo.date)
Beispiel #26
0
def main():
    from argparse import ArgumentParser
    parser = ArgumentParser(usage=usage)
    parser.add_argument("-v", "--verbose", default=0, action="count", help="Increment test verbosity (can be used multiple times)")
    parser.add_argument("-d", "--debug", action="store_true", default=False, help="Print debugging items")
    parser.add_argument("-t", "--test", help="Run only the named test")
    parser.add_argument('type', choices=['accdb', 'mdb'], help='Which type of file to test')

    args = parser.parse_args()

    DRIVERS = {
        'accdb': 'Microsoft Access Driver (*.mdb, *.accdb)',
        'mdb': 'Microsoft Access Driver (*.mdb)'
    }

    here = dirname(abspath(__file__))
    src = join(here, 'empty.' + args.type)
    dest = join(here, 'test.' + args.type)
    shutil.copy(src, dest)

    global CNXNSTRING
    CNXNSTRING = 'DRIVER={%s};DBQ=%s;ExtendedAnsiSQL=1' % (DRIVERS[args.type], dest)
    print(CNXNSTRING)

    cnxn = pyodbc.connect(CNXNSTRING)
    print_library_info(cnxn)
    cnxn.close()

    suite = load_tests(AccessTestCase, args.test)

    testRunner = unittest.TextTestRunner(verbosity=args.verbose)
    result = testRunner.run(suite)
Beispiel #27
0
def rpt_getnew(args):
    parser = ArgumentParser(prog='mx rpt-getnew')
    _add_common_args(parser)
    args = _check_verbose(parser.parse_args(args))

    if not os.path.exists(args.logdir):
        _safe_mkdir(args.logdir)

    gatedirs = get_gate_dirs(gate_url, _is_result_dir, _strip_dotslash)
    localdirs = get_local_dirs(args.logdir)
    for gatedir in gatedirs:
        gate_url_dir = join(gate_url, gatedir)
        local_dir = join(args.logdir, gatedir)
        if not gatedir in localdirs:
            if args.verbose:
                print 'processing: ' + gatedir
            f = urllib.urlopen(join(gate_url_dir, 'testlog'))
            testlog = f.read()
            _safe_mkdir(local_dir)
            with open(join(local_dir, 'testlog'), 'w') as t:
                t.write(testlog)
#        if True:
            # get test results
            gate_url_test = join(gate_url_dir, 'test')
            local_dir_test = join(local_dir, 'test')
            _safe_mkdir(local_dir_test)
            pkgs = get_gate_dirs(gate_url_test, _is_package_dir, _strip_slash)
            for pkg in pkgs:
                if args.verbose:
                    print '  processing package: ' + pkg
                gate_url_test_pkg = join(gate_url_test, pkg)
                local_dir_test_pkg = join(local_dir_test, pkg)
                _copy_files(gate_url_test_pkg, local_dir_test_pkg, pkg)
def base_multinode_parser():
    """Creates a parser with arguments specific to sending HTTP requests
    to multiple REST APIs.

    Returns:
        {ArgumentParser}: Base parser with default HTTP args
    """
    base_parser = ArgumentParser(add_help=False)

    base_parser.add_argument(
        'urls',
        type=str,
        nargs='+',
        help="The URLs of the validator's REST APIs of interest, separated by"
        " commas or spaces. (no default)")
    base_parser.add_argument(
        '--users',
        type=str,
        action='append',
        metavar='USERNAME[:PASSWORD]',
        help='Specify the users to authorize requests, in the same order as '
        'the URLs, separate by commas. Passing empty strings between commas '
        'is supported.')

    return base_parser
Beispiel #29
0
def main():
    parser = ArgumentParser()
    parser_with_options = set_options(parser)
    args = parser_with_options.parse_args()
    arguments = vars(args)
    if 'help' in arguments:
        parser.print_help()
    else:
        config = Config()
        config.format = arguments['output']
        config.total_lists = arguments['lists']
        config.total_words = arguments['number']

        if arguments['file'] is None:
            current_path = os.path.abspath(
                inspect.getfile(inspect.currentframe())
                )
            dir = os.path.dirname(current_path)
            config.file_path = os.path.join(dir, config.internal_words_file)
        else:
            config.file_path = arguments['file']

    words = generate(config)

    if words:
        print(words)

    exit(0)
Beispiel #30
0
def read_params(args):
    parser = ArgumentParser(description= "GraPhlAn "+__version__+" ("+__date__+") "
                                         "AUTHORS: "+__author__)
    arg = parser.add_argument

    arg('intree', type=str, default = None, metavar='input_tree',
        help = "the input tree in PhyloXML format " )
    arg('outimg', type=str, default = None, metavar='output_image',
        help = "the output image, the format is guessed from the extension "
               "unless --format is given. Available file formats are: png, "
               "pdf, ps, eps, svg" )
    arg('--format', choices=['png','pdf','ps','eps','svg'], default=None, 
        type = str, metavar=['output_image_format'],
        help = "set the format of the output image (default none meaning that "
               "the format is guessed from the output file extension)")
    arg('--warnings', default=1, type=int,
        help = "set whether warning messages should be reported or not (default 1)")
    arg('--positions', default=0, type=int,
        help = "set whether the absolute position of the points should be reported on "
               "the standard output. The two cohordinates are r and theta")
    arg('--dpi', default=72, type=int, metavar='image_dpi',
        help = "the dpi of the output image for non vectorial formats")
    arg('--size', default=7.0, type=float, metavar='image_size',
        help = "the size of the output image (in inches, default 7.0)")
    arg('--pad', default=0.5, type=float, metavar='pad_in',
        help = "the distance between the most external graphical element and "
               "the border of the image")
    arg( '-v','--version', action='version', version="GraPhlAn version "+__version__+" ("+__date__+")", 
        help="Prints the current GraPhlAn version and exit" )
    return vars(parser.parse_args())