def add_phone_numbers(self): # add phone nos items = Item.query() for it in items: try: if it.telephone: self.response.out.write("%s has phone<br>" % it.title) continue detail = geo.getPlaceDetailFromGoogle(it) if 'telephone' in detail: it.telephone = geo.getPlaceDetailFromGoogle(it)['telephone'] else: self.response.out.write("%s no phone<br>" % it.title) it.save() self.response.out.write("%s is %s<br>" % (it.title, it.telephone)) except Exception, e: self.response.out.write("FAIL %s<br>" % it.title) self.response.out.write("FAIL %s-%s<br>" % (it.title, str(e))) pass
def add_addresses(self): #add address to any that don't have one try: items = Item.query() count = 0 for it in items: if not it.address: google_data = geo.getPlaceDetailFromGoogle(it) if 'address' in google_data: it.address = google_data['address'] if not it.address: it.address = geo.geoCodeLatLng(it.lat, it.lng) if it.address: it.save() count += 1 else: self.response.out.write('No address for \s'%it.place_name) self.response.out.write('Added %d addresses \n'%count) except Exception, e: self.response.out.write("FAIL ") logging.error("Migration add-addresses FAIL", exc_info=True)
def add_google_img_if_missing(self): # add google img where missing items = Item.query() for it in items: try: if it.photo and it.photo.thumb: self.response.out.write("photo %s<br>" % it.title) continue if it.photo.remoteURL and len(it.photo.remoteURL) > 0: self.response.out.write("googled %s<br>" % it.title) continue img = DBImage() img.remoteURL = geo.getPlaceDetailFromGoogle(it)['photo'] img.put() it.photo = img self.response.out.write("Added <a href='%s'>%s</a><br>" % (img.remoteURL, it.title)) it.save() except Exception, e: self.response.out.write("FAIL %s<br>" % it.title) self.response.out.write("FAIL %s-%s<br>" % (it.title, str(e))) pass