Skip to content

Instantly share code, notes, and snippets.

@jackyyf
Created April 13, 2015 18:03
Show Gist options
  • Save jackyyf/3bd6a15f8e13ee8cfb5e to your computer and use it in GitHub Desktop.
Save jackyyf/3bd6a15f8e13ee8cfb5e to your computer and use it in GitHub Desktop.
Gist by paste.py @ 2015-04-14 02:03:01.503046
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