Entry point for application
180937
public function run($options = [])
    {
        $method = @$options['method'] ?: $_SERVER['REQUEST_METHOD'];

        $uri = @$options['uri'] ?: rawurldecode($_SERVER['REQUEST_URI']);
        if (false !== $pos = strpos($uri, '?')) {
            $uri = substr($uri, 0, $pos);
        }

        $routeInfo = $this->route($method, $uri);
        if (!$routeInfo) {
            $routeInfo = ['default', []];
        }

        list($routeName, $params) = $routeInfo;

        try {
            return $this->runAs($routeName, $params);
        } catch (\Exception $e) {
            $params[] = $e;
            return $this->runAs('defaultError', $params);
        }
    }
1102679
def main():
    '''
    
    '''
    args = CLI.parse_args(__doc__)

    if args['--verbose']:
        requests_log = logging.getLogger("requests.packages.urllib3")
        requests_log.setLevel(logging.DEBUG)
        logging.basicConfig(level=logging.DEBUG)

    if not args['-k']:
        print("No API key given. Please create an API key on <https://octopart.com/api/dashboard>")
        return ReturnValues.NO_APIKEY

    if args['-t'] == 'octopart':
        engine = PyPartsOctopart(args['-k'], verbose=args['--verbose'])
    elif args['-t'] == 'parts.io':
        engine = PyPartsPartsIO(args['-k'], verbose=args['--verbose'])
    else:
        engine = PyPartsBase(args['-k'], verbose=args['--verbose'])

    try:
        if 'lookup' in args or 'search' in args:
            return engine.part_search(args['<part>'])
        elif 'specs' in args:
            return engine.part_specs(args['<part>'])
        elif 'datasheet' in args:
            if args['<action>'] == 'open':
                if args['--output']:
                    return engine.part_datasheet(args['<part>'], command=args['--command'], path=args['--output'])
                else:
                    return engine.part_datasheet(args['<part>'], command=args['--command'])
            elif args['<action>'] == 'save':
                return engine.part_datasheet(args['<part>'], path=args['--output'])
        elif 'show' in args:
            return engine.part_show(args['<part>'], printout=args['--print'])
    except OctopartException as err:
        print(err)
        return ReturnValues.RUNTIME_ERROR
201609
function main() {
    const options = queryOptions();
    switch (options.porting) {
        case 'build':
            runBuild(options)
            .catch((reason) => {
                console.error(reason);
                process.exit(1);
            });
            break;
        case 'arrange':
            runArrange(options);
            break;
        case 'rebase':
            runRebase(options);
            break;
        case 'clean':
            runClean(options);
            break;
    }
}
1039542
def main():
    

    #: If we set the TMP env variable the dev reloader will save file
    #: and load changes in this directory instead of overwriting the
    #: ones installed with the app.
    os.environ['TMP'] = os.path.join(sys.path[0], '../tmp')

    from enamlnative.android.app import AndroidApplication

    app = AndroidApplication(
        debug=True,  #: Makes a lot of lag!
        dev='server',
        load_view=load_view,
    )
    app.start()
776797
def main():
    """"""

    # Hack to make user code available for import
    sys.path.append(".")

    # Run the specified action
    oz.initialize()
    retr = optfn.run(list(oz._actions.values()))

    if retr == optfn.ERROR_RETURN_CODE:
        sys.exit(-1)
    elif retr == None:
        sys.exit(0)
    elif isinstance(retr, int):
        sys.exit(retr)
    else:
        raise Exception("Unexpected return value from action: %s" % retr)
1082074
def main():
    """"""
    util.create_dir(os.path.join(CONF_DIR, "templates"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))

    util.setup_logging()
    parser = get_args()

    parse_args_exit(parser)
    parse_args(parser)
1287588
def main():
    """"""
    import colorama
    import argparse
    import logging
    import sys
    import os

    parser = argparse.ArgumentParser(prog="gulpless",
                                     description="Simple build system.")
    parser.add_argument("-v", "--version",
                        action="version",
                        version="%(prog)s 0.7.6")
    parser.add_argument("-d", "--directory",
                        action="store",
                        default=os.getcwd(),
                        help="Look for `build.py` in this folder (defaults to "
                             "the current directory)")
    parser.add_argument("mode",
                        action="store",
                        choices=["build", "interactive"],
                        default="interactive",
                        metavar="mode",
                        nargs="?",
                        help="If `interactive` (the default), will wait for "
                             "filesystem events and attempt to keep the input "
                             "and output folders in sync. If `build`, it will "
                             "attempt to build all updated files, then exit.")

    args = parser.parse_args()
    os.chdir(args.directory)
    sys.path.append(os.getcwd())

    if os.environ.get("TERM") == "cygwin":
        # colorama doesn't play well with git bash
        del os.environ["TERM"]
        colorama.init()
        os.environ["TERM"] = "cygwin"
    else:
        colorama.init()

    try:
        old, sys.dont_write_bytecode = sys.dont_write_bytecode, True
        import build
    except ImportError:
        sys.exit("No `build.py` found in current folder.")
    finally:
        sys.dont_write_bytecode = old

    try:
        logging.basicConfig(level=build.LOGGING,
                            format="%(message)s")
    except AttributeError:
        logging.basicConfig(level=logging.INFO,
                            format="%(message)s")

    reactor = Reactor(build.SRC, build.DEST)
    for handler in build.HANDLERS:
        reactor.add_handler(handler)
    reactor.run(args.mode == "build")
995485
def main():
    """"""
    # check logging
    log_level = os.environ.get('LOG_LEVEL', 'INFO')
    logging.basicConfig(level=getattr(logging, log_level),
                        format='%(asctime)s %(name)s[%(levelname)s] %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S')

    current_path = os.path.abspath('.')
    if current_path not in sys.path:
        sys.path.insert(0, current_path)
    argcomplete.autocomplete(ARG_PARSER)
    args = ARG_PARSER.parse_args()
    args.func(args)
422747
def main(argv=None):
    # type: (Union[NoneType, List[str]]) -> NoneType
    
    app = application.Application()
    app.run(argv)
    app.exit()
572960
def main():
    """"""
    # Helper method so that the coroutine exits cleanly if an exception
    # happens (which would leave resources dangling)
    async def _run_application(loop):
        try:
            return await cli_handler(loop)

        except KeyboardInterrupt:
            pass  # User pressed Ctrl+C, just ignore it

        except SystemExit:
            pass  # sys.exit() was used - do nothing

        except:  # pylint: disable=bare-except  # noqa
            import traceback

            traceback.print_exc(file=sys.stderr)
            sys.stderr.writelines(
                '\n>>> An error occurred, full stack trace above\n')

        return 1

    try:
        loop = asyncio.get_event_loop()
        return loop.run_until_complete(_run_application(loop))
    except KeyboardInterrupt:
        pass

    return 1
303256
def main():
    """"""
    # Initialize logging to the terminal.
    coloredlogs.install()
    # Prepare for command line argument parsing.
    action = show_matching_entry
    program_opts = dict(exclude_list=[])
    show_opts = dict(filters=[], use_clipboard=is_clipboard_supported())
    verbosity = 0
    # Parse the command line arguments.
    try:
        options, arguments = getopt.gnu_getopt(
            sys.argv[1:],
            "elnp:f:x:vqh",
            ["edit", "list", "no-clipboard", "password-store=", "filter=", "exclude=", "verbose", "quiet", "help"],
        )
        for option, value in options:
            if option in ("-e", "--edit"):
                action = edit_matching_entry
            elif option in ("-l", "--list"):
                action = list_matching_entries
            elif option in ("-n", "--no-clipboard"):
                show_opts["use_clipboard"] = False
            elif option in ("-p", "--password-store"):
                stores = program_opts.setdefault("stores", [])
                stores.append(PasswordStore(directory=value))
            elif option in ("-f", "--filter"):
                show_opts["filters"].append(value)
            elif option in ("-x", "--exclude"):
                program_opts["exclude_list"].append(value)
            elif option in ("-v", "--verbose"):
                coloredlogs.increase_verbosity()
                verbosity += 1
            elif option in ("-q", "--quiet"):
                coloredlogs.decrease_verbosity()
                verbosity -= 1
            elif option in ("-h", "--help"):
                usage(__doc__)
                return
            else:
                raise Exception("Unhandled option! (programming error)")
        if not (arguments or action == list_matching_entries):
            usage(__doc__)
            return
    except Exception as e:
        warning("Error: %s", e)
        sys.exit(1)
    # Execute the requested action.
    try:
        show_opts["quiet"] = verbosity < 0
        kw = show_opts if action == show_matching_entry else {}
        action(QuickPass(**program_opts), arguments, **kw)
    except PasswordStoreError as e:
        # Known issues don't get a traceback.
        logger.error("%s", e)
        sys.exit(1)
    except KeyboardInterrupt:
        # If the user interrupted an interactive prompt they most likely did so
        # intentionally, so there's no point in generating more output here.
        sys.exit(1)
549531
def main():
    """"""
    from spyder.utils.qthelpers import qapplication
    app = qapplication()
    if os.name == 'nt':
        dialog = WinUserEnvDialog()
    else:
        dialog = EnvDialog()
    dialog.show()
    app.exec_()
1024133
def main(argv=None):
    """"""

    parser = argparse.ArgumentParser(
        description='Commands as arguments'
    )
    command_help = 'optional command to run, if no command given, enter an interactive shell'
    parser.add_argument('command', nargs='?',
                        help=command_help)
    arg_help = 'optional arguments for command'
    parser.add_argument('command_args', nargs=argparse.REMAINDER,
                        help=arg_help)

    args = parser.parse_args(argv)

    c = CmdLineApp()

    if args.command:
        # we have a command, run it and then exit
        c.onecmd_plus_hooks('{} {}'.format(args.command, ' '.join(args.command_args)))
    else:
        # we have no command, drop into interactive mode
        c.cmdloop()
1228992
def main(args=sys.argv[1:]):
    
    args = parse_args(args)
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    elif args.quiet:
        logging.basicConfig(level=logging.ERROR)
    else:
        logging.basicConfig(level=logging.INFO)
    app = Grole()
    serve_static(app, '', args.directory, not args.noindex)
    app.run(args.address, args.port)
573289
def main():
    """"""
    args = parser.parse_args()
    args_dict = vars(args)
    root_dir = args_dict['root'] if 'root' in args else None

    # If a root directory is specified, get the absolute path and
    # check if it exists. Abort if it doesn't exist!
    if root_dir:
        root_dir = os.path.abspath(root_dir)
        if not os.path.exists(root_dir):
            print("The specified directory doesn't exist!")
            sys.exit(1)
    # Default to home directory if no root is specified
    else:
        root_dir = os.path.expanduser('~')

    if args.stopdaemon:
        print_command_factory('STOPDAEMON')(vars(args), root_dir)
    elif args.nodaemon:
        daemon_factory(root_dir)()
    elif args.daemon:
        config_dir = os.path.join(root_dir, '.config/pueue')
        os.makedirs(config_dir, exist_ok=True)
        daemon = Daemonize(app='pueue', pid=os.path.join(config_dir, 'pueue.pid'),
                           action=daemon_factory(root_dir), chdir=root_dir)
        daemon.start()
    elif hasattr(args, 'func'):
        try:
            args.func(args_dict, root_dir)
        except EOFError:
            print('Apparently the daemon just died. Sorry for that :/')
    else:
        print('Invalid Command. Please check -h')
1252858
def main():
    """"""
    # Create command line parser.
    parser = argparse.ArgumentParser()
    # Adding command line arguments.
    parser.add_argument("-o", "--out", help="Output file", default=None)
    parser.add_argument(
        "pyfile", help="Python file to be profiled", default=None
    )
    # Parse command line arguments.
    arguments = parser.parse_args()
    if arguments.pyfile is not None:
        # Core functionality.
        pyheat = PyHeat(arguments.pyfile)
        pyheat.create_heatmap()
        pyheat.show_heatmap(output_file=arguments.out, enable_scroll=True)
        pyheat.close_heatmap()
    else:
        # Print command help
        parser.print_help()
877759
def entry_point() -> None:
    """"""

    # make sure the path contains the current working directory
    sys.path.insert(0, os.getcwd())

    parser = get_cxflow_arg_parser(True)

    # parse CLI arguments
    known_args, unknown_args = parser.parse_known_args()

    # show help if no subcommand was specified.
    if not hasattr(known_args, 'subcommand'):
        parser.print_help()
        quit(1)

    # set up global logger
    logger = logging.getLogger('')
    logger.setLevel(logging.DEBUG if known_args.verbose else logging.INFO)
    logger.handlers = []  # remove default handlers

    # set up STDERR handler
    stderr_handler = logging.StreamHandler(sys.stderr)
    stderr_handler.setFormatter(logging.Formatter(CXF_LOG_FORMAT, datefmt=CXF_LOG_DATE_FORMAT))
    logger.addHandler(stderr_handler)

    if known_args.subcommand == 'train':
        train(config_path=known_args.config_file, cl_arguments=unknown_args, output_root=known_args.output_root)

    elif known_args.subcommand == 'resume':
        resume(config_path=known_args.config_path, restore_from=known_args.restore_from, cl_arguments=unknown_args,
               output_root=known_args.output_root)

    elif known_args.subcommand == 'predict':
        logging.warning('Predict command is deprecated and will be removed, use ``cxflow eval predict ...`` instead')
        predict(config_path=known_args.config_path, restore_from=known_args.restore_from, cl_arguments=unknown_args,
                output_root=known_args.output_root)

    elif known_args.subcommand == 'eval':
        evaluate(model_path=known_args.model_path, stream_name=known_args.stream_name,
                 config_path=known_args.config, cl_arguments=unknown_args, output_root=known_args.output_root)

    elif known_args.subcommand == 'dataset':
        invoke_dataset_method(config_path=known_args.config_file, method_name=known_args.method,
                              cl_arguments=unknown_args, output_root=known_args.output_root)

    elif known_args.subcommand == 'gridsearch':
        grid_search(script=known_args.script, params=known_args.params, dry_run=known_args.dry_run)

    elif known_args.subcommand == 'ls':
        list_train_dirs(known_args.dir, known_args.recursive, known_args.all, known_args.long, known_args.verbose)

    elif known_args.subcommand == 'prune':
        prune_train_dirs(known_args.dir, known_args.epochs, known_args.subdirs)