Ejemplo n.º 1
0
def track_screen(screen_name):
    if app.argv.debug or app.argv.notrack:
        return
    args = dict(cd=screen_name, t="screenview")
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(_post_track(args), lambda _: None)
Ejemplo n.º 2
0
def track_event(category, action, label):
    ""
    if app.argv.debug or app.argv.notrack:
        return
    args = dict(ec=category, ea=action, el=label, t='event')
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(_post_track(args), lambda _: None)
Ejemplo n.º 3
0
def track_screen(screen_name):
    if app.argv.debug or app.argv.notrack:
        return
    args = dict(cd=screen_name,
                t="screenview")
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(_post_track(args), lambda _: None,
           queue_name=TELEMETRY_ASYNC_QUEUE)
Ejemplo n.º 4
0
def track_exception(description, is_fatal=True):
    ""
    if app.argv.debug or app.argv.notrack:
        return
    exf = 1 if is_fatal else 0
    args = dict(t='exception', exd=description, exf=exf)
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(_post_track(args), lambda _: None)
Ejemplo n.º 5
0
def track_event(category, action, label):
    ""
    if app.notrack:
        return
    args = dict(ec=category, ea=action, el=label, t='event')
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(partial(_post_track, args),
           lambda _: None,
           queue_name=TELEMETRY_ASYNC_QUEUE)
Ejemplo n.º 6
0
def track_screen(screen_name):
    if app.notrack:
        return
    args = dict(cd=screen_name, t="screenview")
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']

    submit(partial(_post_track, args),
           lambda _: None,
           queue_name=TELEMETRY_ASYNC_QUEUE)
Ejemplo n.º 7
0
def track_exception(description, is_fatal=True):
    ""
    if app.notrack:
        return
    exf = 1 if is_fatal else 0
    args = dict(t='exception', exd=description, exf=exf)
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(partial(_post_track, args),
           lambda _: None,
           queue_name=TELEMETRY_ASYNC_QUEUE)
Ejemplo n.º 8
0
def pollinate(session, tag):
    """ fetches random seed

    Tag definitions:
        W001 - welcome shown
        B001 - bundle selected
        CS - cloud selected
        CC - cloud creation started
        CA - cloud credentials added
        L001 - LXD Setup started
        L002 - LXD Setup completed
        J001 - juju post-bootstrap started
        J002 - juju post-bootstrap completed
        J003 - juju bootstrap started
        J004 - juju bootstrap completed
        CS - controller selected
        PM - placement/bundle editor shown (maas)
        PS - placement/bundle editor shown (other)
        PC - placements committed
        SS - deploy summary shown
        DS - deploy started
        DC - deploy complete
        XA - pre processing started
        XB - post processing started

        UC - user cancelled
        EC - error getting credentials
        EP - error in placement/bundle editor
        EB - error juju bootstrap
        ED - error deploying
        E001 - error in post bootstrap phase
        E002 - error in post processor
        E003 - error in pre processor
        E004 - error creating model in existing controller
        E005 - error in picking spells

    Arguments:
    session: randomly generated session id
    tag: custom tag
    """
    agent_str = 'conjure/{}/{}'.format(session, tag)

    def do_pollinate():
        try:
            cmd = ("curl -A {} --connect-timeout 3 --max-time 3 "
                   "--data /dev/null https://entropy.ubuntu.com "
                   "> /dev/null 2>&1".format(agent_str))
            app.log.debug("pollinate: {}".format(cmd))
            check_call(cmd, shell=True)
        except CalledProcessError as e:
            app.log.warning("Generating random seed failed: {}".format(e))

    if not app.argv.debug:
        submit(do_pollinate, lambda _: None)
Ejemplo n.º 9
0
def pollinate(session, tag):
    """ fetches random seed

    Tag definitions:
        W001 - welcome shown
        B001 - bundle selected
        CS - cloud selected
        CC - cloud creation started
        CA - cloud credentials added
        L001 - LXD Setup started
        L002 - LXD Setup completed
        J001 - juju post-bootstrap started
        J002 - juju post-bootstrap completed
        J003 - juju bootstrap started
        J004 - juju bootstrap completed
        CS - controller selected
        PM - placement/bundle editor shown (maas)
        PS - placement/bundle editor shown (other)
        PC - placements committed
        SS - deploy summary shown
        DS - deploy started
        DC - deploy complete
        XA - pre processing started
        XB - post processing started

        UC - user cancelled
        EC - error getting credentials
        EP - error in placement/bundle editor
        EB - error juju bootstrap
        ED - error deploying
        E001 - error in post bootstrap phase
        E002 - error in post processor
        E003 - error in pre processor
        E004 - error creating model in existing controller
        E005 - error in picking spells

    Arguments:
    session: randomly generated session id
    tag: custom tag
    """
    agent_str = 'conjure/{}/{}'.format(session, tag)

    def do_pollinate():
        try:
            cmd = ("curl -A {} --connect-timeout 3 --max-time 3 "
                   "--data /dev/null https://entropy.ubuntu.com "
                   "> /dev/null 2>&1".format(
                       agent_str))
            app.log.debug("pollinate: {}".format(cmd))
            check_call(cmd, shell=True)
        except CalledProcessError as e:
            app.log.warning("Generating random seed failed: {}".format(e))
    if not app.argv.debug:
        submit(do_pollinate, lambda _: None)
Ejemplo n.º 10
0
def track_screen(screen_name):
    app.log.debug('Showing screen: {}'.format(screen_name))
    if app.no_track:
        return
    args = dict(cd=screen_name,
                t="screenview")
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']

    submit(partial(_post_track, args), lambda _: None,
           queue_name=TELEMETRY_ASYNC_QUEUE)
Ejemplo n.º 11
0
def track_exception(description, is_fatal=True):
    ""
    if app.argv.debug or app.argv.notrack:
        return
    exf = 1 if is_fatal else 0
    args = dict(t='exception',
                exd=description,
                exf=exf)
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(_post_track(args), lambda _: None,
           queue_name=TELEMETRY_ASYNC_QUEUE)
Ejemplo n.º 12
0
def track_event(category, action, label):
    ""
    if app.argv.debug or app.argv.notrack:
        return
    args = dict(ec=category,
                ea=action,
                el=label,
                t='event')
    if 'spell' in app.config:
        args['cd1'] = app.config['spell']
    submit(_post_track(args), lambda _: None,
           queue_name=TELEMETRY_ASYNC_QUEUE)
Ejemplo n.º 13
0
    def get_cached(self, key):
        """cached API GET call, refreshes in background every 5 seconds

        returns None on the first call so you know it's just loading
        instead of an actual empty list
        """

        now = time.time()
        c_val, c_ts = self.CACHE.get(key, (None, now))
        if c_val is None or now - c_ts > 5:
            f = submit(partial(self._get_key_sync, key), lambda _: None)
            if f:
                f.add_done_callback(partial(self._update_cache, key))

        return c_val
Ejemplo n.º 14
0
    def get_cached(self, key):
        """cached API GET call, refreshes in background every 5 seconds

        returns None on the first call so you know it's just loading
        instead of an actual empty list
        """

        now = time.time()
        c_val, c_ts = self.CACHE.get(key, (None, now))
        if c_val is None or now - c_ts > 5:
            f = submit(partial(self._get_key_sync, key),
                       lambda _: None)
            f.add_done_callback(partial(self._update_cache, key))

        return c_val