def get(self): import re rp = RoomsParser() rp.feed(urllib2.urlopen(ROOMS_URL).read()) rooms = rp.getRooms() #self.response.out.write(len(rooms)) for room_key in rooms: room = rooms[room_key] debug("room %s" % room[1]) dbRoom = Room.get_or_insert(room[1]) dbRoom.link = room[-1] (dbRoom.occupied, dbRoom.total) = parseOccupancy(room[-2]) dbRoom.free = dbRoom.total - dbRoom.occupied long_name_nums = re.findall("\d+", room[1]) dbRoom.longName = unicode(room[1]) #if dbRoom.name == "" or dbRoom.name is None: # dbRoom.name = long_name_nums[-1] #if (dbRoom.building == "" or dbRoom.building is None) and len(long_name_nums) == 2: # dbRoom.building = long_name_nums[0] dbRoom.put()
def getRoomsFromGezer(self): rp = RoomsParser() rp.feed(urllib2.urlopen(ROOMS_URL).read()) rooms = rp.getRooms() return rooms