Created
April 13, 2015 18:03
-
-
Save jackyyf/3bd6a15f8e13ee8cfb5e to your computer and use it in GitHub Desktop.
Gist by paste.py @ 2015-04-14 02:03:01.503046
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
import datetime | |
api_key = 'YOUR_APIKEY_HERE' | |
url = 'https://api.linode.com/?api_key=%s&api_action=linode.create&PlanID=1&DatacenterID=8&PaymentTerm=1' % api_key | |
sess = requests.Session() | |
while True: | |
resp = sess.get(url).json() | |
if resp['ERRORARRAY'] and not resp['DATA']: | |
print '[%s] Failed.' % datetime.datetime.now() | |
print '[Code %d] %s' % (resp['ERRORARRAY'][0]['ERRORCODE'], resp['ERRORARRAY'][0]['ERRORMESSAGE']) | |
time.sleep(0.7) | |
continue | |
print 'Seems done?' | |
print resp | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment