2013-06-21 81 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) 

連接對象發送/接收的所有內容都將被轉儲到標準輸出。

相關問題