发出'disqus_dumpdata'命令(link)时收到400错误。搜索过谷歌和github,但我似乎是唯一遇到这个问题的人。
以下是我的追溯。我以为它会是'disqus_dumpdata.py'的'第32行'和我的短名称或api键,但它不是:
(pinax073)[user@web142 mysite]$ python2.6 manage.py disqus_dumpdata --traceback
Traceback (most recent call last):
File "manage.py", line 28, in <module>
execute_from_command_line()
File "/home/user/webapps/whw/lib/python2.6/django/core/management/__init__.py", line 429, in execute_from_command_line
utility.execute()
File "/home/user/webapps/whw/lib/python2.6/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/webapps/whw/lib/python2.6/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/user/webapps/whw/lib/python2.6/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/user/envs/pinax073/lib/python2.6/site-packages/disqus/management/commands/disqus_dumpdata.py", line 32, in handle
forum_list = client.get_forum_list(user_api_key=settings.DISQUS_API_KEY)
File "/home/user/envs/pinax073/lib/python2.6/site-packages/disqus/api.py", line 53, in call_method
return self.call(attr, **kwargs)
File "/home/user/envs/pinax073/lib/python2.6/site-packages/disqus/api.py", line 79, in call
response = urllib2.urlopen(request)
File "/usr/local/lib/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/local/lib/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/local/lib/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python2.6/urllib2.py", line 435, in error
return self._call_chain(*args)
File "/usr/local/lib/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: BAD REQUEST
400 :('错误请求','错误请求语法或不支持的方法')
查看我的api.py文件的第77,78,79行,一切看起来都不错。什么可能导致这种情况?
request = self._get_request(url, self.METHODS[method], **params)
try:
response = urllib2.urlopen(request)
答案 0 :(得分:0)
我建议你实际上阅读了你得到的错误。在该行周围添加try / except:
try:
response = urllib2.urlopen(url)
except urllib2.HTTPError, error:
contents = error.read()
logging.debug(contents)
raise