def _get_result(url): try: result = json.loads(util.decode_page(urlopen_with_retries(url))) return result except URLError, e: logger.error("GeoNames error, could not open URL: %s, error: %s" % (url, e)) return {}
def _fetch_results(self, q): params = {'q': q.encode("utf8"), 'key': self.api_key} # geopy changed the instance variables on the bing geocoder in # version 0.96 - this handles the differences if hasattr(self, 'url'): url = self.url % urlencode(params) else: url = "%s?%s" % (self.api, urlencode(params)) try: page = urlopen_with_retries(url) except Exception, e: logger.error("Geocode error, could not open URL: %s, error: %s" % (url, e)) return []
def _fetch_results(self, q): params = {'q': q.encode("utf8"), 'key': self.api_key } # geopy changed the instance variables on the bing geocoder in # version 0.96 - this handles the differences if hasattr(self, 'url'): url = self.url % urlencode(params) else: url = "%s?%s" % (self.api, urlencode(params)) try: page = urlopen_with_retries(url) except Exception, e: logger.error("Geocode error, could not open URL: %s, error: %s" % (url, e)) return []