leerssej / freebase-python

Automatically exported from code.google.com/p/freebase-python
Other
0 stars 0 forks source link

Httplib2Client does not have a logger #24

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Request this query 
[{'c:key': [{'namespace': '/wikipedia/en_id', 'value': None}], 'a:key': 
[{'namespace': '/wikipedia/en_id', 'value': None}], 'b:key': [{'namespace': 
'/wikipedia/en', 'value': None}], 'name': {'lang': '/lang/en', 'value': None}, 
'type|=': ['/people/person']}]

What is the expected output? What do you see instead?
Results returned. It seems freebase require special Httplib2Client

What version of the product are you using? On what operating system?
trunk, Ubuntu 12.04

Please provide any additional information below.

[{'c:key': [{'namespace': '/wikipedia/en_id', 'value': None}], 'a:key': 
[{'namespace': '/wikipedia/en_id', 'value': None}], 'b:key': [{'namespace': 
'/wikipedia/en', 'value': None}], 'name': {'lang': '/lang/en', 'value': None}, 
'type|=': ['/people/person']}]
2013-05-14 11:38:20 INFO session.py: 397 POST 
http://api.freebase.com/api/service/mqlread
FORM:
  query={"cursor":true,"query":[{"c:key":[{"namespace":"/wikipedia/en_id","value":null}],"a:key":[{"namespace":"/wikipedia/en_id","value":null}],"b:key":[{"namespace":"/wikipedia/en","value":null}],"name":{"lang":"/lang/en","value":null},"type|=":["/people/person"]}],"escape":false}
HEADERS:
  content-type: application/x-www-form-urlencoded; charset=utf-8
  x-metaweb-request: Python
  user-agent: python freebase.api-1.0.4
Traceback (most recent call last):
  File "freebase_entities.py", line 105, in <module>
    main(args)
  File "freebase_entities.py", line 75, in main
    dump_results(q)
  File "freebase_entities.py", line 57, in dump_results
    for row in r:
  File "/usr/local/lib/python2.7/dist-packages/freebase/api/session.py", line 569, in mqlreaditer
    r = self._httpreq_json(service, 'POST', form=dict(query=qstr))
  File "/usr/local/lib/python2.7/dist-packages/freebase/api/session.py", line 420, in _httpreq_json
    resp, body = self._httpreq(*args, **kws)
  File "/usr/local/lib/python2.7/dist-packages/freebase/api/session.py", line 406, in _httpreq
    return self._http_request(url, method, body, headers)
  File "/usr/local/lib/python2.7/dist-packages/freebase/api/httpclients.py", line 65, in __call__
    self.log.error('SOCKET FAILURE: %s', e.fp.read())
AttributeError: 'Httplib2Client' object has no attribute 'log'

> 
/usr/local/lib/python2.7/dist-packages/freebase/api/httpclients.py(65)__call__()
-> self.log.error('SOCKET FAILURE: %s', e.fp.read())

You need to add 
self.log = logging.getLogger("freebase")

to the __init__ of Httplib2Client

Original issue reported on code.google.com by rmyeid on 14 May 2013 at 3:52

GoogleCodeExporter commented 9 years ago
The API supported by this library has been retired and then endpoint now 
returns HTML instead of the JSON that all the client libraries expect, so you 
won't get any reasonable error message.

If you're writing a new app, you should switch to the Google's standard Python 
client library.  If you've got an existing app that using this library, I've 
started a (minimal) update to the new APIs in my fork on Github.  
github.com/tfmorris/freebase-python

Original comment by tfmorris on 2 Jul 2013 at 12:46