hitrust / namebench

Automatically exported from code.google.com/p/namebench
Apache License 2.0
0 stars 0 forks source link

* Failed to use GoogleLocAPI: simplejson.decoder.JSONDecodeError #256

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start the program from the command line in linux
2. Google 404 error for the geodata appears before the gui loads
3.

What is the expected output? What do you see instead?
No errors

What version of the product are you using? On what operating system?
Namebench 1.3.1. Ubuntu Linux 14.04

Please provide any additional information below.

$ ./namebench.py 
Starting Tk interface for namebench...
* Failed to use GoogleLocAPI: simplejson.decoder.JSONDecodeError No JSON object 
could be decoded: line 1 column 0 (char 0) (content: <!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/errors/logo_sm_2.png) no-repeat}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/errors/logo_sm_2_hr.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/errors/logo_sm_2_hr.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/errors/logo_sm_2_hr.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:55px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/loc/json</code> was not found on this server.  <ins>That’s all we know.</ins>
)
Failed to get Geodata: socket.timeout timed out

Original issue reported on code.google.com by george.p...@gmail.com on 22 Apr 2014 at 11:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Seems likes the url which provides the GeoLocationAPI was shutdown by Google, 
[https://code.google.com/p/gears/wiki/GeolocationAPI]

If you look in the file, libnamebench/geoip.py line +37 
you can see the old url.

 33   NOTE: This is in violation of the Gears Terms of Service. See:
     34   http://code.google.com/p/gears/wiki/GeolocationAPI
     35   """
     36   h = httplib2.Http(tempfile.gettempdir(), timeout=10)
     37   url = 'http://www.google.com/loc/json'
     38   post_data = {'request_address': 'true', 'version': '1.1.0', 'source': 'namebench'}
     39   unused_resp, content = h.request(url, 'POST', simplejson.dumps(post_data))
     40   try:
     41     data = simplejson.loads(content)['location']
     42     return {
     43         'region_name': data['address'].get('region'),
     44         'country_name': data['address'].get('country'),
     45         'country_code': data['address'].get('country_code'),
     46         'city': data['address'].get('city'),
     47         'latitude': data['latitude'],
     48         'longitude': data['longitude'],
     49         'source': 'gloc'
     50     }
     51   except:
     52     print '* Failed to use GoogleLocAPI: %s (content: %s)' % (util.GetLastExceptionString(), content)
     53     return {}

Original comment by ra...@rabin.io on 31 Jul 2014 at 11:11