Example #1
0
def main():
    parser = ArgumentParser(description="Extract a list of symbols from a shared library.")
    parser.add_argument("library", metavar="shared-lib", type=str, help="The library to extract symbols from")
    parser.add_argument(
        "-o",
        "--output",
        dest="output",
        help="The output file. stdout is used if not given",
        type=str,
        action="store",
        default=None,
    )
    parser.add_argument(
        "--names-only", dest="names_only", help="Output only the name of the symbol", action="store_true", default=False
    )
    parser.add_argument(
        "--only-stdlib-symbols",
        dest="only_stdlib",
        help="Filter all symbols not related to the stdlib",
        action="store_true",
        default=False,
    )
    args = parser.parse_args()
    if args.output is not None:
        print("Extracting symbols from %s to %s." % (args.library, args.output))
    syms = extract.extract_symbols(args.library)
    if args.only_stdlib:
        syms, other_syms = util.filter_stdlib_symbols(syms)
    util.write_syms(syms, out=args.output, names_only=args.names_only)
Example #2
0
def main():
    parser = ArgumentParser()
    parser.add_argument("-n", "--host", default="127.0.0.1", help="network hostname")
    args = parser.parse_args()

    params = dict(hostname=args.host)

    try:
        open("users.pickle")
    except IOError:
        common.make_users("users.pickle", 100)

    with open("webui/barker_host.js", "wb") as jsfile:
        jsfile.write("""barker_host = "%(hostname)s";\n""" % params)

    pids = []
    try:
        for command in (commands % params).split("\n"):
            if command and not command.strip().startswith("#"):
                pids.append(launch(command.strip()))
        while True:
            sleep(100000)
    finally:
        for pid in pids:
            os.kill(pid, signal.SIGTERM)
Example #3
0
def main():
    """Delete feature local, remote-tracking, and remote branch in git repository."""
    parser = ArgumentParser(description=main.__doc__)
    parser.add_argument("-d", "--delete", action="store_true", default=True, help=SUPPRESS)
    parser.add_argument("-n", "--name", help="Feature branch name without user prefix.")
    parser.add_argument("-o", "--origin", default="origin", help="Git repository alias. Default: 'origin'")
    parser.add_argument("-u", "--user_prefix", help="Prefix feature branch name with current user. Default: True")

    feature_branch = FeatureBranch(**vars(parser.parse_args()))
    feature_branch.validate_input()
    if feature_branch.outputs["exit_code"] != 0:
        print("Aborted.")
        sys.exit(feature_branch.outputs["exit_code"])

    feature_branch.get_repo()
    feature_branch.validate_repo()
    if feature_branch.outputs["exit_code"] != 0:
        print("Aborted.")
        sys.exit(feature_branch.outputs["exit_code"])

    if feature_branch.get_current_branch() == feature_branch.target:
        if not feature_branch.user_want_to_discard_changes():
            print("User cancelled out of discard changes in working directory.")
            sys.exit(0)
        feature_branch.checkout("master")

    feature_branch.fetch()
    feature_branch.delete()
    feature_branch.notify_delete()
    feature_branch.notify_current_branch()
Example #4
0
def parse_cl(argv):
    parser = ArgumentParser()
    parser.add_argument("dir", metavar="DIR", help="dir")
    parser.add_argument("-o", "--output", metavar="FILE", help="output file")
    parser.add_argument("-p", "--plate", metavar="PLATE", help="plate name")
    parser.add_argument("-s", "--screen", metavar="SCREEN", help="screen name")
    return parser.parse_args(argv[1:])
Example #5
0
def admin_users():
    from argparse import ArgumentParser

    a = ArgumentParser()
    for op in ("add", "remove", "reset"):
        a.add_argument("--" + op, nargs="+", type=str, default=())
    args = a.parse_args()

    def _add_user(username):
        cursor.execute("INSERT INTO users VALUES (?, ?)", (username, hash_pw(username)))
        user_db.commit()

    def _remove_user(username):
        cursor.execute("DELETE FROM users WHERE id=?", (username,))
        user_db.commit()

    for u in args.add:
        _add_user(u)
        print("Added user " + u)

    for u in args.remove:
        _remove_user(u)
        print("Removed user " + u)

    for u in args.reset:
        _remove_user(u)
        _add_user(u)
        print("Reset user " + u)
Example #6
0
    def __init__(self, context):
        name = "SimMan"
        resource = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource/" + name + ".ui")
        GuiT = SimManGui
        RosT = SimManROS

        super(SimManRqt, self).__init__(context)
        self.setObjectName(name)

        from argparse import ArgumentParser

        parser = ArgumentParser()
        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._gui = GuiT()
        self._ros = RosT()

        loadUi(resource, self._gui)
        self._ros.setup(self._gui)
        self._gui.setup(name + "Rqt", self._ros)

        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() + (" (%d)" % context.serial_number()))
        context.add_widget(self._gui)
Example #7
0
def cmd_args():
    from argparse import ArgumentParser

    parser = ArgumentParser()
    parser.add_argument("-l", dest="locale", choices=app.LOCALES + ["auto"], default="auto")
    args = parser.parse_args()
    return args
Example #8
0
def isoenv_main(args=sys.argv[1:]):
    parser = ArgumentParser(
        description="Compile a set of source directories containing environment specific "
        "files into a single output repository with only the files for "
        "the specified environment"
    )
    parser.add_argument("--sources", nargs="+", metavar="source", required="true")
    parser.add_argument("--environment", required="true")
    parser.add_argument("dest")
    parser.add_argument(
        "-d",
        "--dryrun",
        dest="dryrun",
        action="store_true",
        default=False,
        help="Don't modify the destination directory",
    )
    add_logging_args(parser)

    args = parser.parse_args(args)

    run_mode = "live run" if not args.dryrun else "dry run"
    fmt = " - ".join(["%(asctime)s", "%(levelname)s", run_mode, "%(message)s"])
    setup_logging(args, fmt)

    compile(args.sources, args.dest, args.environment, args.dryrun)
    def __init__(self, context):
        super(NodeManager, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName("NodeManagerFKIE")

        # 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
        node_manager_fkie.init_settings()
        masteruri = node_manager_fkie.settings().masteruri()
        node_manager_fkie.init_globals(masteruri)
        # Create QWidget
        try:
            self._widget = MainWindow()
        #          self._widget.read_view_history()
        except Exception, e:
            msgBox = QMessageBox()
            msgBox.setText(str(e))
            msgBox.exec_()
            raise
Example #10
0
def main():
    usage = "Setup the database and populate with data"
    description = "Accepts a series of files to load to the database and match"
    parser = ArgumentParser(usage=usage, description=description)
    parser.add_argument("--all", action="store_true")
    parser.add_argument("--db", action="store_true")
    parser.add_argument("--ocdid", action="store_true")
    parser.add_argument("--office", action="store_true")

    args = parser.parse_args()
    if not (args.all or args.db or args.ocdid or args.office):
        args.all = True

    if args.all or args.db:
        create_db()
    if args.all or args.ocdid:
        clear_dir()
        ocdid_data = {"ocdid": get_ocdids()}
        load_data(Ocdid.OCDID_FILES, ocdid_data)
    if args.all or args.office:
        clear_dir()
        export_data(Ocdid.EXPORT_QUERY)
        global ocdid
        import ocdid

        oh_data = assign_ocdids()
        office_holder_data = split_data(oh_data)
        load_data(OfficeHolder.OFFICE_HOLDER_FILES, office_holder_data)
Example #11
0
def main():
    global options
    parser = ArgumentParser()
    parser.add_argument("-v", dest="verbose", action="store_true", default=False, help="print more information.")
    parser.add_argument(
        "-d", "--debug", dest="debug", action="store_true", default=False, help="print debug information"
    )

    parser.add_argument("-n", type=int, dest="numCores", nargs="?", help="Number of customers in queueing network.")
    parser.add_argument(
        "datafile",
        help='Prefix of files containing thread IDs, lock IDs and acquire timestamps, sorted by time. Name should be "prefix__{try,acq,rel}.dat"',
    )

    options = parser.parse_args()

    if options.debug:
        print >> sys.stderr, "options:", options

    lt = ParsedLockTrace(options.datafile)
    lt.analyze()
    lt.mva()

    print lt.serv_times()
    print lt.est_wait
    print lt.meas_wait

    return 0
    def __new__(mcs, name, bases, attrs):
        instance = super(Commando, mcs).__new__(mcs, name, bases, attrs)
        subcommands = []
        main_command = None
        for name, member in attrs.iteritems():
            if hasattr(member, "command"):
                main_command = member
            elif hasattr(member, "subcommand"):
                subcommands.append(member)
        main_parser = None

        def add_arguments(parser, params):
            """
            Adds parameters to the parser
            """
            for parameter in params:
                parser.add_argument(*parameter.args, **parameter.kwargs)

        if main_command:
            main_parser = ArgumentParser(*main_command.command.args, **main_command.command.kwargs)
            add_arguments(main_parser, main_command.params)
            subparsers = None
            if len(subcommands):
                subparsers = main_parser.add_subparsers()
                for sub in subcommands:
                    parser = subparsers.add_parser(*sub.subcommand.args, **sub.subcommand.kwargs)
                    parser.set_defaults(run=sub)
                    add_arguments(parser, sub.params)

        instance.__parser__ = main_parser
        instance.__main__ = main_command
        return instance
Example #13
0
def command_line():
    """
    Parses command line arguments.

    Returns
    =======
    :returns: Namespace containing parsed arguments
    :rtype  : argparse.ArgumentParser
    """
    description = "A Text Summarizer for Humans"
    version = " ".join([__version__, __build__])

    parser = ArgumentParser(prog="ExplainToMe", description=description)

    parser.add_argument(
        "-v", "--version", action="version", version="{name} v{version}".format(name="ExplainToMe", version=version)
    )

    parser.add_argument(
        "url", type=str, default="http://wikipedia.org/wiki/Automatic_summarization", help="Summarize website contents."
    )

    parser.add_argument("limit", type=int, default=10, help="Give a sentence limit")

    parser.add_argument("--language", type=str, default="english", help="This feature is still in testing")

    return parser.parse_args()
Example #14
0
def main():
    arg_parser = ArgumentParser("creates XML encoded block data")
    arg_parser.add_argument("--tags", type=int, action="store", dest="nr_tags", help="number of tags to use")
    arg_parser.add_argument(
        "--elements", type=int, action="store", dest="nr_elements", help="number of elements in document"
    )
    arg_parser.add_argument(
        "--text-prob",
        action="store",
        type=float,
        dest="text_prob",
        default=0.0,
        help="probability to generate text in elements",
    )
    arg_parser.add_argument(
        "--text-length",
        type=int,
        action="store",
        dest="max_text_length",
        default=5,
        help="number of elements in document",
    )
    options = arg_parser.parse_args()
    if not options.nr_tags:
        options.nr_tags = random.randint(1, 10)
    if not options.nr_elements:
        options.nr_elements = random.randint(1, 10)
    tags = Tags(options.nr_tags)
    texts = Texts(options.max_text_length)
    docs = Docs(options.nr_elements, tags, options.text_prob, texts)
    doc = docs.random()
    print(doc.toprettyxml(indent="  "))
    return 0
Example #15
0
File: sjmpc.py Project: sabl0r/wall
    def run(self):
        parser = ArgumentParser()
        parser.add_argument("url")
        parser.add_argument("type")
        parser.add_argument("arg", type=namedarg, nargs="*")
        args = parser.parse_args()

        try:
            connection = websocket.create_connection(args.url)
        except ValueError as e:
            parser.error("argument url: invalid url value: '{}'".format(args.url))
        except (IOError, WebSocketException) as e:
            print("error: failed to connect (details: {})".format(e), file=sys.stderr)
            sys.exit(1)

        try:
            call_msg = Message(args.type, dict(args.arg))
            connection.send(str(call_msg))
            while True:
                result_msg = Message.parse(connection.recv())
                if result_msg.type == call_msg.type:
                    break
            connection.close()
        except WebSocketException as e:
            print("error: disconnected (details: {})".format(e), file=sys.stderr)
            sys.exit(1)

        print(json.dumps(result_msg.data, indent=4))
def parse_command_line(args):
    """Return a namespace built after parsing the command line.

    PARAMETERS
        args: A sequence of arguments to be used as the command-line.
    """
    # The command-line interface is very simple, so we could possibly
    # handle it by hand.  But it's nice to have features such as
    # -h/--help switches which come for free if we use argparse.
    #
    # We use ArgumentParser, which means that we are requiring
    # Python version 2.7 or later, because it handles mandatory
    # command-line arguments for us as well.
    ap = ArgumentParser(description='Git "update" hook.')
    ap.add_argument(
        "--submitter-email",
        help=(
            "Use this email address instead as the sender"
            " of email notifications instead of using the"
            " email address of the user calling this"
            " script"
        ),
    )
    ap.add_argument("old_rev", help="the SHA1 before update")
    ap.add_argument("new_rev", help="the new SHA1, if the update is accepted")
    ap.add_argument("ref_name", help="the name of the reference being updated")

    return ap.parse_args(args)
Example #17
0
def parse_args():
    parser = ArgumentParser(description="Crawl the web. Hack the planet.")
    parser.add_argument(
        "-s",
        "--source",
        default="http://ciir.cs.umass.edu",
        dest="source",
        help="The URL to crawl from",
        metavar="source",
    )
    parser.add_argument(
        "-l", "--limit", default=100, type=int, dest="limit", help="Limit the number of URL's to crawl", metavar="limit"
    )
    parser.add_argument(
        "-w", "--wait", default=5, type=int, dest="wait", help="Time to wait between requests", metavar="wait"
    )
    parser.add_argument(
        "-d",
        "--domain",
        default="cs.umass.edu",
        dest="domain",
        help="Limit the crawler to a specific domain",
        metavar="domain",
    )
    return parser.parse_args()
Example #18
0
def parse_options():
    """Parse command line options"""

    opt = ArgumentParser(description=__doc__)

    opt.add_argument(
        "config_file",
        metavar="CONFIG_FILE",
        type=str,
        nargs="?",
        help="Packular configuration file (default %s)" % (DEFAULT_CONF_FILE,),
        default=DEFAULT_CONF_FILE,
    )

    opt.add_argument(
        "-S", metavar="KEY=VALUE", type=str, nargs="*", help="Overwrite config file variables, e.g. version=2.0"
    )

    opt.add_argument(
        "--ignore_colon",
        action="store_true",
        default=False,
        help="Don't consider colon character (':') as key/value separator",
    )

    opt.add_argument("-T", metavar="TARGET_NAME", type=str, help="Build only specified target, e.g. sandbox")

    return opt.parse_args()
Example #19
0
def main():
    parser = ArgumentParser(
        prog=sys.argv[0],
        add_help=True,
        description="Tool used to migrate your old layers from the old structure to the new one.",
    )

    parser.add_argument(
        "-i",
        "--app-config",
        default="production.ini",
        dest="app_config",
        help="the application .ini config file (optional, default is 'production.ini')",
    )
    parser.add_argument(
        "-n", "--app-name", default="app", dest="app_name", help="the application name (optional, default is 'app')"
    )
    parser.add_argument("--no-layers", dest="layers", action="store_false", help="do not import the layers")
    parser.add_argument("--no-groups", dest="groups", action="store_false", help="do not import the groups")
    parser.add_argument("--no-themes", dest="themes", action="store_false", help="do not import the themes")
    options = parser.parse_args()

    app_config = options.app_config
    app_name = options.app_name
    if app_name is None and "#" in app_config:
        app_config, app_name = app_config.split("#", 1)
    get_app(app_config, name=app_name)

    # must be done only once we have loaded the project config
    from c2cgeoportal.models import DBSession, OGCServer, Theme, LayerWMS, LayerWMTS, LayerV1, LayerGroup

    session = DBSession()

    if options.layers:
        table_list = [LayerWMTS, LayerWMS, OGCServer]
        for table in table_list:
            print("Emptying table {0!s}.".format(str(table.__table__)))
            # must be done exactly this way othewise the cascade config in the
            # models are not used
            for t in session.query(table).all():
                session.delete(t)

        # list and create all distinct ogc_server
        ogc_server(session)

        print("Converting layerv1.")
        for layer in session.query(LayerV1).all():
            layer_v1tov2(session, layer)

    if options.groups:
        print("Converting layer groups.")
        for group in session.query(LayerGroup).all():
            layergroup_v1tov2(session, group)

    if options.themes:
        print("Converting themes.")
        for theme in session.query(Theme).all():
            theme_v1tov2(session, theme)

    transaction.commit()
def get_opts():
    ap = ArgumentParser(description="Generate OAuth keys for interacting with remote services")
    ap.add_argument("-c", "--config", type=str, help="Path to the configuration file", required=True)
    ap.add_argument("ACTION", type=str, choices=["init-trello", "init-drive"], help="Select the action to execute")
    ap.add_argument("KEY", type=str, help="The API Key for the service")
    ap.add_argument("SECRET", type=str, help="The API Secret for the service")
    return ap.parse_args(argv[1:])
Example #21
0
def execute_from_command_line():
    arg_parser = ArgumentParser(description=development_deploy.__doc__)
    arg_parser.add_argument("--deps", action="store_true", help="install dependencies")
    arg_parser.add_argument("--scripts", action="store_true", help="install scripts")
    arg_parser.add_argument(
        "--inject", action="store_true", help="inject setuptools call (for modules without setuptools)"
    )
    arg_parser.add_argument("paths", metavar="path", nargs="+", help="packages search path")

    # Processing
    arguments = arg_parser.parse_args()
    for path in [os.path.abspath(x) for x in arguments.paths]:
        print 'Finding packages at "{0}"...'.format(path)
        for root, dirs, files in os.walk(path):
            dirs[:] = [x for x in dirs if not x.startswith(".")]
            for file_name in files:
                file_name_lower = file_name.lower()
                if file_name_lower == "setup.py":
                    dirs[:] = []
                    print 'Processing "{0}"'.format(root)
                    development_deploy(
                        os.path.join(root, file_name),
                        dependencies=arguments.deps,
                        scripts=arguments.scripts,
                        inject_setuptools=arguments.inject,
                    )
Example #22
0
    def __init__(self, context):
        super(utilityPlugin, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName("utilityPlugin")

        # 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 = QWidget()
        # Get path to UI file which is a sibling of this file
        # in this example the .ui and .py file are in the same folder
        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "utility.ui")
        # Extend the widget with all attributes and children from UI file
        loadUi(ui_file, self._widget)
        # Give QObjects reasonable names
        self._widget.setObjectName("utilityUi")
        # 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
        context.add_widget(self._widget)

        self.ID = 0

        self.State = QuadPositionDerived()
        self.Target = QuadPositionDerived()
        self.sub = ""
        self.name = ""
        self.pwd = os.environ["PWD"]

        self._widget.IrisInputBox.insertItems(0, ["iris1", "iris2", "iris3", "iris4", "iris5"])
        self._widget.bStart.clicked.connect(self.Start)
        self._widget.GravityCancelButton.clicked.connect(self.adjust_gravity_cancel)

        self._widget.XBox.setMinimum(-10.0)
        self._widget.XBox.setMaximum(10.0)
        self._widget.XBox.setSingleStep(0.1)
        self._widget.YBox.setMinimum(-10.0)
        self._widget.YBox.setMaximum(10.0)
        self._widget.YBox.setSingleStep(0.1)
        self._widget.ZBox.setMinimum(-10.0)
        self._widget.ZBox.setMaximum(10.0)
        self._widget.ZBox.setSingleStep(0.1)
        self._widget.GravitySpinBox.setMaximum(1800)
        self._widget.GravitySpinBox.setMinimum(1200)
        self._widget.GravitySpinBox.setSingleStep(10)
        self._widget.GravitySpinBox.setValue(1500)
Example #23
0
def main():
    # Initialize parser
    parser = ArgumentParser(
        prog="PokemonGoInCanada",
        description="Checks if Pokemon Go is available in Canada.",
        formatter_class=RawTextHelpFormatter,
    )
    # Initialize sub-parsers
    subparsers = parser.add_subparsers(dest="subCommand", help="PokemonGoInCanada commands")
    # Initialize region sub-parser
    regionParser = subparsers.add_parser("region", help="Check a region. (besides just Canada)")
    regionParser.add_argument("region_id", help="iTunes region ID. Should usually be a two letter abbreviation.")
    # Parse arguments
    args = parser.parse_args()
    # Handle args
    if args.subCommand == "region":
        try:
            if checkForPokemonGo(args.region_id):
                print("Pokemon Go is available in this region.")
            else:
                print("Pokemon Go is not available in this region yet.")
        except PokemonGoError as e:
            print(e)
    else:
        isPokemonGoInCanada()
Example #24
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*"
     )
Example #25
0
    def parseOptions(self, opts, nameSpace=None):
        self.logger.info("options : >%s<\n" % opts)
        parser = ArgumentParser()
        parser.add_argument(
            "--delay-metric-weight", dest="delayMetricWeight", type=float, default=self.D_DELAY_METRIC_WEIGHT
        )

        args, rest = parser.parse_known_args(
            opts,
            Namespace(
                nPings=self.D_NPINGS,
                packetSize=self.D_PING_PACKET_SIZE,
                rttdevThreshold=10,  # threshold above which to throw results (rttdev in ms)
            ),
        )
        self.D_DELAY_METRIC_WEIGHT = args.delayMetricWeight
        if args.delayMetricWeight > 0:
            self.metrics.append((args.delayMetricWeight, self.metricDelay))
        super().parseOptions(rest, args)
        self.options.pingOptions = [
            "--parallel",
            "-c %s" % self.options.nPings,
            "-s %s" % self.options.packetSize,
            "-i 0.5",
        ]
        Probe.packetSize = self.options.packetSize
Example #26
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*"
     )
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
Example #28
0
def main():
    # Parse the args
    parser = ArgumentParser(description="Symbolicate OS X crash logs.")
    parser.add_argument("logfile", help="The crash log file to symbolicate.")
    parser.add_argument("-d", "--dwarfdump", action="store_true", help="Use dwarfdump instead of atos.")
    parser.add_argument("-f", "--force", action="store_true", help="Re-symbolicate already resolved symbols.")
    parser.add_argument("-s", "--logdsyms", action="store_true", help="Log list of detected dSym files to stderr.")
    args = parser.parse_args()

    # Locate dSyms
    dsym_map = gen_dsym_map()
    if len(dsym_map) == 0:
        print "No dSYM files detected."
        sys.exit(1)

    # Symbolicate
    resolver = resolve_dwarfdump if args.dwarfdump else resolve_atos
    out_lines = symbolicate(
        lines=open(args.logfile).readlines(),
        dsym_map=gen_dsym_map(),
        resolver=resolver,
        dump_crash_dsyms=args.logdsyms,
        force=args.force,
    )
    sys.stdout.writelines(out_lines)
Example #29
0
def init_parsers():
    """
    This function is responsible to initialize the argument parser.
    :return:
    """
    parser_main = ArgumentParser(prog=path.basename(__file__), version=__version__)
    subparsers = parser_main.add_subparsers()

    # Report Parser
    parser_report = subparsers.add_parser("analyze", help="Analyze and browse")
    parser_report.add_argument(
        "nmap_report", help='nmap report(xml file) to analyze (full path example: "your path\report.xml"', default=None
    )

    # Scan Parser
    parser_scan = subparsers.add_parser("scan", help="Scan and browse")
    parser_scan.add_argument(
        "target",
        help="hosts for scan (example: 127.0.0.1, 127.0.0.1/24) or file (ip/hosts file.txt) seperated with new lines.",
        default=None,
    )
    parser_scan.add_argument("-a", "--nmap-args", help="nmap args for scan", default="-sS -sV")

    # Add Global Arguments to parsers
    add_global_arguments(parser_scan, parser_report)
    return parser_main
Example #30
0
def main():
    parser = ArgumentParser()
    parser.add_argument("ply_filename")

    args = parser.parse_args()

    plot(PlyData.read(args.ply_filename))