コード例 #1
0
 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.")
コード例 #2
0
 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.")
コード例 #3
0
ファイル: ifmon.py プロジェクト: marchon/ifmon
def save_data():
    _, received, transmitted = get_bytes()
    uptime, _ = get_uptime()
    now = DateTimeCol.now()
    boot_time = now - timedelta(seconds=uptime)
    boot_time = boot_time - timedelta(seconds=boot_time.second,
                                      microseconds=boot_time.microsecond)
    bws = Bandwidth.select(Bandwidth.q.booted_at==boot_time)
    for bw in bws:
        dr = received - bw.received
        dt = transmitted - bw.transmitted
        bw.received = received
        bw.transmitted = transmitted
        bw.retrieved_at = now
        break
    else:
        dr, dt = received, transmitted
        Bandwidth(booted_at=boot_time, retrieved_at=now, received=received,
                  transmitted=transmitted)

    return dr, dt
コード例 #4
0
ファイル: ifmon.py プロジェクト: marchon/ifmon
def save_data():
    _, received, transmitted = get_bytes()
    uptime, _ = get_uptime()
    now = DateTimeCol.now()
    boot_time = now - timedelta(seconds=uptime)
    boot_time = boot_time - timedelta(seconds=boot_time.second,
                                      microseconds=boot_time.microsecond)
    bws = Bandwidth.select(Bandwidth.q.booted_at == boot_time)
    for bw in bws:
        dr = received - bw.received
        dt = transmitted - bw.transmitted
        bw.received = received
        bw.transmitted = transmitted
        bw.retrieved_at = now
        break
    else:
        dr, dt = received, transmitted
        Bandwidth(booted_at=boot_time,
                  retrieved_at=now,
                  received=received,
                  transmitted=transmitted)

    return dr, dt