2013-06-21 44 views
9

如何从boto中获得有用的诊断信息?我所看到的只是无用的“400坏请求”。我认识到boto只是传递了底层API可用的东西,但肯定有某种方式可以获得比“错误请求”更有用的东西。如何从boto获得有用的诊断信息?

Traceback (most recent call last): 
    File "./mongo_pulldown.py", line 153, in <module> 
    main() 
    File "./mongo_pulldown.py", line 24, in main 
    print "snap = %r" % snap 
    File "./mongo_pulldown.py", line 149, in __exit__ 
    self.connection.delete_volume(self.volume.id) 
    File "/home/roy/deploy/current/python/local/lib/python2.7/site-packages/boto/ec2/connection.py", line 1507, in delete_volume 
    return self.get_status('DeleteVolume', params, verb='POST') 
    File "/home/roy/deploy/current/python/local/lib/python2.7/site-packages/boto/connection.py", line 985, in get_status 
    raise self.ResponseError(response.status, response.reason, body) 
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request 
+0

'import boto; boto.set_stream_logger('boto')'会打印json结果,包括控制台遇到的任何错误。 – ecoe

回答

6

可以configure the boto.cfg文件得更加详细:

[Boto] 
debug = 2 

调试:控制将由 的博托库中打印调试消息的级别。下面的值定义为:

0 - no debug messages are printed 
1 - basic debug messages from boto are printed 
2 - all boto debugging messages plus request/response messages from httplib 
+1

这并没有提供任何更多的信息。问题是,返回的HTTP响应在正文中只有“400错误请求”。我真正需要的是通过某种方式让服务器提供有关出错的更多信息。 –

+0

从代码,它看起来像一个可以在每个连接的基础上打开此信息。例? – dfrankow

5

我没有多少运气把调试设置的配置文件,但调用ec2.connect_to_region()需要一个调试参数,使用相同的值如在jnes的答案中。

ec2 = boto.ec2.connect_to_region("eu-west-1", debug=2) 

连接对象发送/接收的所有内容都将被转储到标准输出。

相关问题