2017-02-01 1 views
0

은 다음 파이썬 스크립트는 지난 달 마법처럼 일했다 :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 도움이 당신을 잊지 마세요 올바른 답변을 표시하고 같은 :) –

관련 문제