Esempio n. 1
0
 def get_current_load(self):
     db = Database(self.filePath)
     APs = db.get_data_raw("SELECT * FROM wlc_aps")
     data = []
     for ap in APs:
         node = {}
         node['key'] = ap[0]
         node['name'] = ap[1]
         node['location'] = ap[2]
         node['cnt'] = int(db.get_data_single("SELECT clients from wlc_ap_clients WHERE ap_key=? ORDER BY timestamp DESC",(str(ap[0]),)))
         data.append(node)
     data = sorted(data, key=lambda k: k['cnt'], reverse = True)
     return data
Esempio n. 2
0
 def get_groups(self):
     db = Database(self.filePath)
     data = []
     groups = db.get_data_raw("SELECT * FROM wlc_ap_groups")
     for group in groups:
         node = {}
         node['id'] = group[0]
         node['name'] = group[1]
         node['lat'] = group[2]
         node['lng'] = group[3]
         node['aps'] = []
         node['cnt'] = 0
         bindings = db.get_data("SELECT * FROM wlc_ap_group_binding WHERE group_id=?",(node['id'],))
         for binding in bindings:
             apNode = {}
             apNode['key'] = binding[2]
             adDetails = db.get_data("SELECT * FROM wlc_aps WHERE ap_key=?",(apNode['key'],))
             apNode["name"] = adDetails[0][1]
             node['aps'].append(apNode)
             node['cnt'] += int(db.get_data_single("SELECT clients from wlc_ap_clients WHERE ap_key=? ORDER BY timestamp DESC",(str(apNode['key']),)))
         data.append(node)
     data = sorted(data, key=lambda k: k['cnt'], reverse = True)
     return data