How to use the watchtower.db.dispatch function in watchtower

To help you get started, we’ve selected a few watchtower examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github synw / django-watchtower / watchtower / management / commands / collect.py View on Github external
def handle(self, *args, **options):
        verbosity = options["verbosity"]
        if verbosity is None:
            verbosity = VERBOSITY
        if verbosity > 0:
            print("Collecting data ...")
        r = redis.Redis(host='localhost', port=6379, db=0)
        while True:
            hits = getHits(r)
            events = getEvents(r)
            dispatch(hits, events, verbosity)
            time.sleep(FREQUENCY)
github synw / django-watchtower / watchtower / middleware.py View on Github external
"is_bot": request.user_agent.is_bot,
            "is_touch": request.user_agent.is_touch_capable,
            "browser": request.user_agent.browser.family,
            "browser_version": request.user_agent.browser.version_string,
            "os": request.user_agent.os.family,
            "os_version": request.user_agent.os.version_string,
            "device": request.user_agent.device.family,
        }
        data["ua"] = ua
        name = CONF.SITE_SLUG + "_hit" + str(HITNUM)
        data["geo"] = serializer.getGeoData(data['ip'])
        if CONF.COLLECTOR is True:
            hit = serializer.pack(data)
            R.set(name, hit)
        else:
            thread = Thread(target=dispatch, args=([data],))
            thread.start()
        HITNUM += 1
        return response