def addRecording(person, file_id): #approxLocs = getApproxLocations(person.location.lat,person.location.lon) r = Recording() r.populate(chat_id=person.chat_id, location = person.location, date_time=time_util.now(), file_id=file_id, random_id = random.random()) r.put() return r
def importVivaldi(): vivaldiBaseUrl = "https://dl.dropboxusercontent.com/u/12016006/Vivaldi/ogg/" cityFile = open("vivaldi/citiesGPS.tsv") #recFile = open("vivaldi/recStructure_3_4.tsv") recFile = open("vivaldi/sample_10_feb_16.tsv") cityDictionary = {} count = 0 for line in cityFile: city_gps = line.split("\t") city = city_gps[0] #logging.debug("'" + city_gps[1] + "'") loc_string = city_gps[1] #(45.6051865, 10.6900516) loctext_split = loc_string[1:-2].split(", ") #trim the \n loc = {'latitude': float(loctext_split[0]), 'longitude': float(loctext_split[1])} cityDictionary[city] = loc listOfRecEntities = [] for line in recFile: # region|translation|city|file rtcf = line.split("\t") translation = rtcf[1] + " (credits to Vivaldi project, see https://www2.hu-berlin.de/vivaldi)" city = rtcf[2] locGps = cityDictionary[city] locGeoPt = ndb.GeoPt(locGps['latitude'], locGps['longitude']) fileName = rtcf[3][:-1] #trim the \n url = vivaldiBaseUrl + fileName r = Recording() r.populate(chat_id=0, location = locGeoPt, date_time=time_util.now(), url=url, random_id = random.random(), translation = translation) listOfRecEntities.append(r) count += 1 if (count==50): ndb.put_multi(listOfRecEntities) listOfRecEntities = [] count = 0 ndb.put_multi(listOfRecEntities)
def updateLastSeen(p): p.last_seen = time_util.now() p.put()
def addPeopleCount(): p = DateCounter.get_or_insert(str(time_util.now())) p.people_counter = person.Person.query().count() p.put() return p