예제 #1
0
def run_main():
    """Some initial logging, then run main()."""
    # Ensure any errors occurring in the setup are sent to stderr, while the
    # code below directs them to stderr once rather than twice.
    try:
        with p4gf_log.ExceptionLogger(squelch=False, write_to_stderr_=True):
            p4gf_version_3.log_version_extended()
            log_l10n()
            p4gf_version_3.version_check()
    except:  # pylint: disable=bare-except
        # Cannot continue if above code failed.
        sys.exit(1)
    # main() already writes errors to stderr, so don't let logger do it again
    p4gf_log.run_with_exception_logger(main_ignores, write_to_stderr=False)
user name. To stop the server, send a terminating signal to the process.
""")
    log_l10n()
    parser = p4gf_util.create_arg_parser(desc, epilog=epilog)
    parser.add_argument('-p',
                        '--port',
                        type=int,
                        help=_('port on which to listen for LFS reqeuests'))
    args = parser.parse_args()
    if args.port:
        LOG.info("Listening for LFS-HTTP requests on port %s, pid=%s",
                 args.port, os.getpid())
        httpd = wsgiref.simple_server.make_server('', args.port, app_wrapper)
        print(_('Serving on port {port}...').format(port=args.port))
        p4gf_http_common.wsgi_install_signal_handler(httpd)
        p4gf_proc.install_stack_dumper()
        httpd.serve_forever()
    else:
        # Assume we are running inside a web server...
        p4gf_proc.install_stack_dumper()
        _handle_cgi()


if __name__ == "__main__":
    # Get the logging configured properly...
    with p4gf_log.ExceptionLogger(squelch=False, write_to_stderr_=True):
        try:
            main()
        except Exception:  # pylint:disable=broad-except
            LOG.exception('HTTP main failed')
예제 #3
0
    Dump test exec args.
    '''
    usage = _(  'Usage: p4gf_branch_id.py <repo-config-file> <git-dir> [ref ...]'
              '\n'
              '\nRuns branch-id calculation on the branches defined in'
              '\nrepo-config-file within the given git directory.'
              '\nSee debug log for results.')
    print(usage)
    exit(1)


if __name__ == '__main__':
    if len(sys.argv) < 3:
        _test_usage()

    with p4gf_log.ExceptionLogger():
        p4gf_proc.init()
        _refs = sys.argv[3:]
        if not _refs:
            _refs = ['master']
        LOG.debug('config={} dir={}\nrefs={}'
                  .format(sys.argv[1], sys.argv[2], _refs))
        _anon_branch_func = _counter
        _config = configparser.ConfigParser()
        _config.read(sys.argv[1])
        _branch_dict = p4gf_branch.dict_from_config(_config)
        _branch_to_old_head_sha1 = _test_return_none
        _git_dir = sys.argv[2]
        _remote_refs = ['refs/heads/' + ref for ref in _refs]
        _test_dump_all_commits(_branch_dict, _git_dir, _remote_refs)