2017-02-01 4 views
0

は、次のPythonスクリプトは、先月の魅力のように働いた:Softlayer getAllBillingItemsの動作が停止しましたか?

スクリプト:

import SoftLayer 
client = SoftLayer.Client(username='someUser', api_key='someKey') 
LastInvoice = client['Account'].getAllBillingItems() 
print LastInvoice 

今日の結果:

C:\Python27\python.exe C:/Users/username/Documents/Python/Softlayer/Softlayer5.py 
Traceback (most recent call last): 
    File "C:/Users/username/Documents/Python/Softlayer/Softlayer5.py", line 8, in <module> 
    LastInvoice = client['Account'].getAllBillingItems() 
    File "C:\Python27\lib\site-packages\SoftLayer\API.py", line 392, in call_handler 
    return self(name, *args, **kwargs) 
    File "C:\Python27\lib\site-packages\SoftLayer\API.py", line 360, in call 
    return self.client.call(self.name, name, *args, **kwargs) 
    File "C:\Python27\lib\site-packages\SoftLayer\API.py", line 263, in call 
    return self.transport(request) 
    File "C:\Python27\lib\site-packages\SoftLayer\transports.py", line 197, in __call__ 
    raise exceptions.TransportError(ex.response.status_code, str(ex)) 
SoftLayer.exceptions.TransportError: TransportError(500): 500 Server Error: Internal Server Error for url: https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Account 

他のAPIアクションが正常に動作...任意の考え?

答えて

0

よくチャームに欠陥があります。レスポンスに大量のデータが含まれているとレスポンスにタイムアウトが発生し、接続が閉じられます。

しかし、この問題は簡単に結果の制限を使用することによって解決することができるが、この例に見てみましょう:

import SoftLayer 

# Your SoftLayer API username and key. 
USERNAME = 'set me' 
API_KEY = 'set me' 

client = SoftLayer.Client(username=USERNAME, api_key=API_KEY) 

offset = 0 
limit = 50 

accountService = client['SoftLayer_Account'] 

while True: 
    try: 
     result = accountService.getAllBillingItems(limit=limit, offset=offset) 
     offset = offset + limit 
     limit = limit + limit 
     print(result) 
     if not result: 
      break 
    except SoftLayer.SoftLayerAPIError as e: 
     print("Unable to retrieve the servers . " % (e.faultCode, e.faultString)) 
     exit(1) 

よろしく

+0

あなたの答えをいただき、ありがとうございます。私はそれを行こう。 – yuval

+0

素晴らしいこのエラーの詳細については、http://sldn.softlayer.com/blog/phil/how-solve-error-fetching-http-headersを参照してください。すべての場合の修正では、 asnwer.Ifこれはあなたが正しいように答えをマークして忘れないようにしてください:) –

関連する問題