def signup(self, emailid, ipaddress): query = SignUp.all() query.filter("emailid = ", emailid) p = None for p in query.run(limit=1): break try: if not p: p = SignUp() p.counter = 0 p.emailid = emailid p.counter += 1 p.ipaddress = ipaddress p.ipupdated = False p.put() filename = constants.GOOGLE_DRIVE_EMAIL_ATTACHMENT_KEY attachment = mail.Attachment(filename, None) emailservice = EmailService() emailservice.register( constants.EMAIL_TYPE_SIGNUP, constants.EMAIL_ID_SIGNUP, emailid, constants.EMAIL_SIGNUP_SUBJECT, readtextfilecontents(constants.EMAIL_SIGNUP_BODY_FILENAME), attachment) return 1 except Exception as e: logging.error("error signing up " + str(emailid)) sys_err = sys.exc_info() logging.error(sys_err[1]) return 0
def updategeoip(self, ipaddress): geoservice = GeoService() countryname = geoservice.getcountryname(ipaddress) cityname, latitude, longitude = geoservice.getcitydetails(ipaddress) logging.info('databaseupdate requested from ipaddress=' + str(ipaddress) \ + ', countryname=' + str(countryname) \ + ', cityname=' + str(cityname) \ + ', latitude=' + str(latitude) \ + ', longitude=' + str(longitude)) query = SignUp.all() query.filter("ipupdated = ", False) p = None for p in query.run(limit=100): ipaddress = str(p.ipaddress) countryname = geoservice.getcountryname(ipaddress) cityname, latitude, longitude = geoservice.getcitydetails( ipaddress) othercities = OtherCities() othercities.countryname = countryname othercities.cityname = cityname othercities.latitude = latitude othercities.longitude = longitude try: othercities.put() except: logging.error('error putting OtherCities ipaddress=' + str(ipaddress) \ + ', countryname=' + str(countryname) \ + ', cityname=' + str(cityname) \ + ', latitude=' + str(latitude) \ + ', longitude=' + str(longitude)) sys_err = sys.exc_info() logging.error(sys_err[1]) try: p.ipupdated = True p.put() except: logging.error('error updating SignUp ipaddress=' + str(ipaddress)) sys_err = sys.exc_info() logging.error(sys_err[1])