Closed GoogleCodeExporter closed 9 years ago
Seems the problem is on line 49. The correct line should be something like:
reason = data['error']['errors'][0]['reason']
The problem is that, I really don't know if the 'path' to 'reason' on the data
dict will be always the same.
Original comment by felippe....@gmail.com
on 10 Sep 2012 at 10:11
You need to upgrade to httplib2 0.7.5, as this change addresses that issue:
http://code.google.com/p/httplib2/source/detail?format=side&path=/python2/httplib2/__init__.py&r=fa8982bd19a2570da5e93dc424dbe49b037962d3&spec=svnfa8982bd19a2570da5e93dc424dbe49b037962d3
The dependencies for google-api-python-client should be updated to 0.7.5 to
make sure everyone gets that fix. I will file a bug to that effect. Thanks!
Original comment by jcgregorio@google.com
on 11 Sep 2012 at 1:49
Hi Gregorio,
Thanks for your answer.
I tried upgrading to new httplib2 and still not working.
I'm trying to do something like
https://developers.google.com/analytics/devguides/reporting/core/v3/coreErrors#b
ackoff
(take a look on the code for makeRequest()).
And as I said, it is not working.
My solution for now was to implement something like:
except HttpError, error:
content = json.loads(error.content)
reason = content.get('error').get('errors')[0].get('reason')
reason in ['userRateLimitExceeded', 'quotaExceeded']:
time.sleep((2 ** n) + (random.randint(0, 1000) / 1000))
Thank you.
Original comment by felippe....@gmail.com
on 11 Sep 2012 at 6:09
Please check the version of httplib2 you are running:
$ python
>>> import httplib2
>>> httplib2.__version__
should return 0.7.5 or later.
The code you pointed to in
http://code.google.com/p/google-api-python-client/source/browse/apiclient/errors.py#46
is just part of the definition of _get_reason() and is only called
from __repr__(), it has no effect on what error.resp.reason returns.
The value in error.resp.reason is the string part of the HTTP status
code, i.e. it's the 'Forbidden' part of '401 Forbidden'.
Your code looks good, but there could be more than one error so you
should loop over all the 'errors' and check the 'reason' in each one.
Original comment by jcgregorio@google.com
on 11 Sep 2012 at 8:51
Original issue reported on code.google.com by
felippe....@gmail.com
on 10 Sep 2012 at 9:56