Example #1
0
def find_location(location):
	if location is None:
		return None

	response = get_station_and_gmt(location)
	if response is None:
		return None

	station = response['station']
	timezone = response['gmt']
	name = response['name']
	location_entity = Location.all().filter('station =', station).get()

	if location_entity is None:
		location_entity = Location(name=name, station=station, timezone=timezone)
		location_entity.put()

	return location_entity
Example #2
0
	def get(self):
		all_places = list(Location.all())
		rainy_places = self._get_locations(all_places)
		twitter = login_twitter_bot()

		logging.debug("The rainy places are: "+str([location.name for location in rainy_places]))
		for place in all_places:
			if place in rainy_places:
				users = list(User.all(keys_only=True).filter('location =', place).filter('active =', True))
				message = self._format_message(place)

				user_len = len(users)
				for i in range(0, user_len / RainNotification.DM_PER_REQUEST + 1):
					slice = users[i*RainNotification.DM_PER_REQUEST:(i + 1)*RainNotification.DM_PER_REQUEST]

					if len(slice) > 0:
						QueueHandler.queue_notify(message, slice, i*10)
			else:
				place.last_broadcast_rain = False

		db.put(all_places)
Example #3
0
	def get(self):
		places = list(Location.all(keys_only=True))
		for i in xrange(len(places)):
			QueueHandler.queue_fetch(places[i], 5*i)