Exemple #1
0
def main(argv=None, namespace=None, check_new_version=True):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == 'nt':
        colorama.init()

    if sys.version_info <= (2, 7, 9):
        # requests uses urllib3, and on python <= 2.7.9 there will be a lot
        # of warnings that we do not want. See
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1199020
        import logging
        logging.captureWarnings(True)

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version(config.logger)
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})
        app = Application(config.fetch_config, config.options)

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except UnavailableRelease, exc:
        config.logger.error(str(exc)) if config else sys.exit(str(exc))
        print formatted_valid_release_dates()
        sys.exit(1)
Exemple #2
0
def main(
    argv=None,
    namespace=None,
    check_new_version=True,
    mozregression_variant="console",
):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == "nt":
        colorama.init()

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version()
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})

        app = Application(config.fetch_config, config.options)
        send_telemetry_ping_oop(
            UsageMetrics(
                variant=mozregression_variant,
                appname=config.fetch_config.app_name,
                build_type=config.fetch_config.build_type,
                good=config.options.good,
                bad=config.options.bad,
                launch=config.options.launch,
            ),
            config.enable_telemetry,
        )

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except (MozRegressionError, RequestException) as exc:
        if isinstance(exc, HTTPError) and exc.response.status_code == 401:
            # remove the taskcluster credential file - looks like it's wrong
            # anyway. This will force mozregression to ask again next time.
            mozfile.remove(TC_CREDENTIALS_FNAME)
        LOG.error(str(exc)) if config else sys.exit(str(exc))
        sys.exit(1)
    finally:
        if app:
            app.clear()
Exemple #3
0
def test_set_http_session():
    try:
        with patch('requests.Session') as Session:
            session = Session.return_value = Mock()
            session_get = session.get

            network.set_http_session(get_defaults={'timeout': 5})

        assert session == network.get_http_session()
        # timeout = 5 will be passed to the original get method as a default
        session.get('http://my-ul')
        session_get.assert_called_with('http://my-ul', timeout=5)
        # if timeout is defined, it will override the default
        session.get('http://my-ul', timeout=10)
        session_get.assert_called_with('http://my-ul', timeout=10)

    finally:
        # remove the global session to not impact other tests
        network.SESSION = None
def test_set_http_session():
    try:
        with patch('requests.Session') as Session:
            session = Session.return_value = Mock()
            session_get = session.get

            network.set_http_session(get_defaults={'timeout': 5})

        assert session == network.get_http_session()
        # timeout = 5 will be passed to the original get method as a default
        session.get('http://my-ul')
        session_get.assert_called_with('http://my-ul', timeout=5)
        # if timeout is defined, it will override the default
        session.get('http://my-ul', timeout=10)
        session_get.assert_called_with('http://my-ul', timeout=10)

    finally:
        # remove the global session to not impact other tests
        network.SESSION = None
Exemple #5
0
def main(argv=None, namespace=None, check_new_version=True):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == 'nt':
        colorama.init()

    if sys.version_info <= (2, 7, 9):
        # requests uses urllib3, and on python <= 2.7.9 there will be a lot
        # of warnings that we do not want. See
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1199020
        import logging
        logging.captureWarnings(True)

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version()
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})
        app = Application(config.fetch_config, config.options)

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except (MozRegressionError, RequestException) as exc:
        if isinstance(exc, HTTPError) and exc.response.status_code == 401:
            # remove the taskcluster credential file - looks like it's wrong
            # anyway. This will force mozregression to ask again next time.
            mozfile.remove(TC_CREDENTIALS_FNAME)
        LOG.error(str(exc)) if config else sys.exit(str(exc))
        sys.exit(1)
    finally:
        if app:
            app.clear()
Exemple #6
0
def main(argv=None, namespace=None, check_new_version=True):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == 'nt':
        colorama.init()

    if sys.version_info <= (2, 7, 9):
        # requests uses urllib3, and on python <= 2.7.9 there will be a lot
        # of warnings that we do not want. See
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1199020
        import logging
        logging.captureWarnings(True)

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version()
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})
        app = Application(config.fetch_config, config.options)

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except (MozRegressionError, RequestException) as exc:
        if isinstance(exc, HTTPError) and exc.response.status_code == 401:
            # remove the taskcluster credential file - looks like it's wrong
            # anyway. This will force mozregression to ask again next time.
            mozfile.remove(TC_CREDENTIALS_FNAME)
        LOG.error(str(exc)) if config else sys.exit(str(exc))
        sys.exit(1)
    finally:
        if app:
            app.clear()
def apply_prefs(options):
    set_http_session(get_defaults={
        "timeout": options['http_timeout'],
        "verify": patch_requests.cacert_path()
    })
Exemple #8
0
def apply_prefs(options):
    set_http_session(get_defaults={
        "timeout": options['http_timeout'],
        "verify": patch_requests.cacert_path()
    })
def apply_prefs(options):
    set_http_session(get_defaults={"timeout": options["http_timeout"]})