Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def retrieve(endpoint, api_key):
gmaps = GoogleMaps(api_key)
url = endpoint + '?' + urllib.urlencode([("query",query)]) + '&format=text%2Fcsv'
header = None
print >> sys.stderr, url
for line in csv.reader(urllib.urlopen(url),delimiter=","):
if header == None:
header = line
continue
addressURI = line[0]
address = ", ".join([x for x in line[1:] if x != ""])
try:
lat, lng = gmaps.address_to_latlng(address)
except GoogleMapsError:
print >> sys.stderr, 'GoogleMapsError'
print '{},{},{}'.format(addressURI,lat,lng)
def getGmapsInstance(self):
"""get a google maps wrapper instance"""
key = self.get('googleAPIKey', None)
if key == None:
print "onlineServices: a google API key is needed for using the google maps services"
return None
# only import when actually needed
import googlemaps
gmap = googlemaps.GoogleMaps(key)
return gmap
def _getGmapsInstance():
"""get a google maps wrapper instance"""
key = constants.GOOGLE_PLACES_API_KEY
if key is None:
log.error("a google API key is needed for using the Google maps services")
return None
# only import when actually needed
import googlemaps
gMap = googlemaps.GoogleMaps(key)
return gMap
def _getGmapsInstance():
"""get a google maps wrapper instance"""
key = constants.GOOGLE_API_KEY
if key is None:
log.error("onlineServices: online providers:"
" a google API key is needed for using the google maps services")
return None
# only import when actually needed
import googlemaps
gMap = googlemaps.GoogleMaps(key)
return gMap
def getGmapsInstance(self):
"""get a google maps wrapper instance"""
key = constants.GOOGLE_API_KEY
if not key:
print("onlineServices: a google API key is needed for using the google maps services")
return None
# only import when actually needed
import googlemaps
gMap = googlemaps.GoogleMaps(key)
return gMap
#!/bin/bash
import ConfigParser
import pg8000
from pg8000 import DBAPI
import re
from googlemaps import GoogleMaps
addressRegex = r"(\b(at|on)\s((\d+|\w{2,})\s){1,2}(st(reet)?|r[(oa)]d)(\sstation|\smarket)?[,.\s])"
#addressRegex =r"(\b(at|on)\s((\d+|\w{2,})\s){1,2}(st(reet)?|r[(oa)]d)(\sstation|\smarket)?)"
currRegex = addressRegex
gmaps = GoogleMaps("ABQIAAAAUGnYtZ9Py2CWqhKA2j8WNhSV67USoQ6pUbqiV9eqnAi_hHG1PhShAENkss9dydHdndy0C9ko99g-Pg")
#gmaps = GoogleMaps("AIzaSyCw6F9tfQG6R56y9tUUm4WaI7o-D3cn7HI")
conn = DBAPI.connect(host=cfg_server, database=cfg_database,user=cfg_username, password=cfg_password)
cursor = conn.cursor()
query = "select text from tweets where geolocation is null"
cursor.execute(query)
counter = 0
for row in cursor:
text = str(row[0])
regexMatch = re.search(currRegex, text, re.IGNORECASE)
if not regexMatch == None:
#print text[:140]
addr = regexMatch.group(0)[3:] #, text[:80]
lraddr = addr.lower()