Esempio n. 1
0
    def on_get(self, req, resp):
        mymetrics.incr('version.count')
        version_info = json.dumps(get_version_info(self.basedir))

        resp.content_type = 'application/json; charset=utf-8'
        resp.status = falcon.HTTP_200
        resp.body = version_info
Esempio n. 2
0
    def on_get(self, req, resp):
        """Implement GET HTTP request."""
        mymetrics.incr('version.count')
        version_info = json.dumps(get_version_info(self.basedir))

        resp.content_type = 'application/json; charset=utf-8'
        resp.status = falcon.HTTP_200
        resp.body = version_info
Esempio n. 3
0
def test_get_version_info(tmpdir):
    fn = tmpdir.join('/version.json')
    fn.write_text('{"commit": "d6ac5a5d2acf99751b91b2a3ca651d99af6b9db3"}',
                  encoding='utf-8')

    assert (get_version_info(str(tmpdir)) == {
        'commit': 'd6ac5a5d2acf99751b91b2a3ca651d99af6b9db3'
    })
Esempio n. 4
0
    def on_get(self, req, resp):
        """Implement GET HTTP request."""
        mymetrics.incr("version.count")
        version_info = json.dumps(get_version_info(self.basedir))

        resp.content_type = "application/json; charset=utf-8"
        resp.status = falcon.HTTP_200
        resp.body = version_info
Esempio n. 5
0
def test_get_version_info(tmpdir):
    fn = tmpdir.join('/version.json')
    fn.write_text('{"commit": "d6ac5a5d2acf99751b91b2a3ca651d99af6b9db3"}', encoding='utf-8')

    assert (
        get_version_info(str(tmpdir)) ==
        {'commit': 'd6ac5a5d2acf99751b91b2a3ca651d99af6b9db3'}
    )
Esempio n. 6
0
def test_get_version_info(tmpdir):
    fn = tmpdir.join("/version.json")
    fn.write_text(
        '{"commit": "d6ac5a5d2acf99751b91b2a3ca651d99af6b9db3"}', encoding="utf-8"
    )

    assert get_version_info(str(tmpdir)) == {
        "commit": "d6ac5a5d2acf99751b91b2a3ca651d99af6b9db3"
    }
def set_sentry_client(sentry_dsn, basedir):
    """Set a Sentry client using a given sentry_dsn.

    To clear the client, pass in something falsey like ``''`` or ``None``.

    """
    global _sentry_client
    if sentry_dsn:
        version_info = get_version_info(basedir)
        commit = version_info.get('commit')[:8]

        _sentry_client = Client(dsn=sentry_dsn,
                                include_paths=['antenna'],
                                tags={'commit': commit})
        logger.info('Set up sentry client')
    else:
        _sentry_client = None
        logger.info('Removed sentry client')
Esempio n. 8
0
def set_sentry_client(sentry_dsn, basedir):
    """Sets a Sentry client using a given sentry_dsn

    To clear the client, pass in something falsey like ``''`` or ``None``.

    """
    global _sentry_client
    if sentry_dsn:
        version_info = get_version_info(basedir)
        commit = version_info.get('commit')[:8]

        _sentry_client = Client(
            dsn=sentry_dsn,
            include_paths=['antenna'],
            tags={'commit': commit}
        )
        logger.info('Set up sentry client')
    else:
        _sentry_client = None
        logger.info('Removed sentry client')
Esempio n. 9
0
    def on_get(self, req, resp):
        version_info = json.dumps(get_version_info(self.basedir))

        resp.content_type = 'application/json; charset=utf-8'
        resp.status = falcon.HTTP_200
        resp.body = version_info