def run(self): """Thread main loop""" while (app.running): time.sleep(self.poll_interval) if not hasattr(settings, 'server_url'): continue try: log.debug("Calling home...") data = { 'playlist': settings.content.playlist_name, 'mac_address': self.mac_address, 'ip_address': utils.get_ip_address(), 'cpu_freq': utils.get_cpu_freq(), 'cpu_temp': utils.get_cpu_temp(), 'cpu_usage': utils.get_cpu_usage(), 'browser_ram': utils.get_pid_rss(self.browser.uzbl.pid), 'uptime': utils.get_uptime() } if self.send_logs: data['logs'] = '\n'.join(utils.get_log_entries()) self.send_logs = False reply = self.call_home(data) log.debug("Got reply %s" % reply) self.do_clock(reply) try: method = getattr(self, 'do_' + reply['action']) except AttributeError: log.debug("Cannot handle reply %s", reply) if app.running: # state may have changed in the meantime method(reply['data']) except Exception as e: log.debug("Got %s while calling home" % e) pass log.info("Exiting beacon thread.")
def dump_logs(): """Dump log entries from in-memory logger""" if not app.settings.debug: abort(400, "Access Denied") response.content_type = 'text/plain' return '\n'.join(utils.get_log_entries())
def run(self): """Thread main loop""" while(app.running): time.sleep(self.poll_interval) if not hasattr(self.config,'server_url'): continue try: log.debug("Calling home...") data = { 'playlist' : self.playlist, 'mac_address' : self.mac_address, 'ip_address' : self.ip_address, 'cpu_freq' : utils.get_cpu_freq(), 'cpu_temp' : utils.get_cpu_temp(), 'cpu_usage' : utils.get_cpu_usage(), 'browser_ram' : utils.get_pid_rss(self.browser.uzbl.pid), 'uptime' : utils.get_uptime() } if self.send_logs: data['logs'] = '\n'.join(utils.get_log_entries()) self.send_logs = False reply = self.call_home(data) log.debug("Got reply %s" % reply) self.do_clock(reply) try: method = getattr(self, 'do_' + reply['action']) except AttributeError: log.debug("Cannot handle reply %s", reply) if app.running: # state may have changed in the meantime method(reply['data']) except Exception as e: log.debug("Got %s while calling home" % e) pass log.info("Exiting beacon thread.")
def _filter_log_duplicates(accepted, needs_approval, rejected, options): """ Filter users for account names already present in accounts.log. Return new accepted, needs_approval, and rejected lists. """ accepted_new = [] needs_approval_new = list(needs_approval) rejected_new = list(rejected) with open(options.log_file) as f: log_users = get_log_entries(f) log_user_names = dict() for user in log_users: name = user["account_name"] if name in log_user_names: log_user_names[name] += 1 else: log_user_names[name] = 1 for user in accepted: if log_user_names.get(user["account_name"], 0) > 1: _staff_approval(user, "Duplicate account name found in log file", accepted_new, needs_approval_new, rejected_new, options) else: accepted_new += user, return accepted_new, needs_approval_new, rejected_new
def dump_logs(): """Dump log entries from in-memory logger""" if not app.config.debug: abort(400, "Access Denied") response.content_type = "text/plain" return "\n".join(utils.get_log_entries())