Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
"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