예제 #1
0
 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 {}
예제 #2
0
 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 {}
예제 #3
0
    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 []
예제 #4
0
    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 []