def get(self): self.response.headers['Content-Type'] = 'text/plain' kind = self.request.GET['kind'].strip() bssid = self.request.GET['bssid'].strip() probe = self.request.get_all('probed') power = self.request.GET['power'].strip() essid = self.request.GET['essid'].strip() timeRanges = self.request.get_all('times') curTimes = [] probedEssid = [] for probed in probe: probed.encode('ascii','ignore') probed = probed.strip() probedEssid.append(probed) for time in timeRanges: time.encode('ascii','ignore') time = time.strip() curTimes.append(datetime.strptime(time, "%Y-%m-%d %H:%M:%S") ) power = int(power) if kind == "Router": r = NodeRecord(parent = device_key(bssid), kind = kind, BSSID = bssid, timeRanges = curTimes , lastSeen = curTimes[-1], power = power, ESSID = essid, probedESSID =probedEssid) else: r = NodeRecord(parent = device_key(bssid), kind = kind, BSSID = bssid, timeRanges = curTimes , lastSeen = curTimes[-1], power = power, AP = essid, probedESSID =probedEssid) r_key = r.put()
def get(self): self.response.headers['Content-Type'] = 'text/plain' update = dict() curTimes = [] probedEssid = [] try: self.response.headers['Content-Type'] = 'text/plain' update['kind'] = self.request.GET['kind'].strip() update['bssid'] = self.request.GET['bssid'].strip() update['power'] = self.request.GET['power'].strip() update['essid'] = self.request.GET['essid'].strip() probe = self.request.get_all('probed') timeRanges = self.request.get_all('times') for probed in probe: probed.encode('ascii','ignore') probed = probed.strip() probedEssid.append(probed) update['probed'] = probedEssid for time in timeRanges: time.encode('ascii','ignore') time = time.strip() curTimes.append(datetime.strptime(time, "%Y-%m-%d %H:%M:%S") ) except KeyError: #bail if there is no argument for 'devicename' submitted self.response.write ('Error with update parameters') else: nodeToUpdate = NodeRecord.updateNode(update) nodeToUpdate.power = int(update['power']) nodeToUpdate.lastSeen = curTimes[-1] # NOTE: Commenting out this because it seems redundant to strore ranges for the real time app. # Can always put it back for data analyis # nodeToUpdate.timeRanges = [] # for t in update['time']: # nodeToUpdate.timeRanges.append(t) if nodeToUpdate.kind == "Client": nodeToUpdate.AP = update['essid'] r_key = nodeToUpdate.put() self.response.write("Updated")
def get(self): self.response.headers['Content-Type'] = 'text/plain' update = dict() curTimes = [] probedEssid = [] try: self.response.headers['Content-Type'] = 'text/plain' update['kind'] = self.request.GET['kind'].strip() update['bssid'] = self.request.GET['bssid'].strip() update['power'] = self.request.GET['power'].strip() update['essid'] = self.request.GET['essid'].strip() probe = self.request.get_all('probed') timeRanges = self.request.get_all('times') for probed in probe: probed.encode('ascii', 'ignore') probed = probed.strip() probedEssid.append(probed) update['probed'] = probedEssid for time in timeRanges: time.encode('ascii', 'ignore') time = time.strip() curTimes.append(datetime.strptime(time, "%Y-%m-%d %H:%M:%S")) except KeyError: #bail if there is no argument for 'devicename' submitted self.response.write('Error with update parameters') else: nodeToUpdate = NodeRecord.updateNode(update) nodeToUpdate.power = int(update['power']) nodeToUpdate.lastSeen = curTimes[-1] # NOTE: Commenting out this because it seems redundant to strore ranges for the real time app. # Can always put it back for data analyis # nodeToUpdate.timeRanges = [] # for t in update['time']: # nodeToUpdate.timeRanges.append(t) if nodeToUpdate.kind == "Client": nodeToUpdate.AP = update['essid'] r_key = nodeToUpdate.put() self.response.write("Updated")
def get(self): self.response.headers['Content-Type'] = 'text/plain' kind = self.request.GET['kind'].strip() bssid = self.request.GET['bssid'].strip() probe = self.request.get_all('probed') power = self.request.GET['power'].strip() essid = self.request.GET['essid'].strip() timeRanges = self.request.get_all('times') curTimes = [] probedEssid = [] for probed in probe: probed.encode('ascii', 'ignore') probed = probed.strip() probedEssid.append(probed) for time in timeRanges: time.encode('ascii', 'ignore') time = time.strip() curTimes.append(datetime.strptime(time, "%Y-%m-%d %H:%M:%S")) power = int(power) if kind == "Router": r = NodeRecord(parent=device_key(bssid), kind=kind, BSSID=bssid, timeRanges=curTimes, lastSeen=curTimes[-1], power=power, ESSID=essid, probedESSID=probedEssid) else: r = NodeRecord(parent=device_key(bssid), kind=kind, BSSID=bssid, timeRanges=curTimes, lastSeen=curTimes[-1], power=power, AP=essid, probedESSID=probedEssid) r_key = r.put()