Created
January 27, 2016 16:36
-
-
Save gomezgoiri/fba21334c8f74db4c154 to your computer and use it in GitHub Desktop.
Creation of instances for pt-instances-management
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import time | |
import requests | |
from humanfriendly import Spinner, Timer | |
instances_to_create = 50 | |
url = 'http://anon.kmi.open.ac.uk/instances' | |
response_count = {} | |
with Spinner(label="Creating instances", total=instances_to_create) as spinner: | |
progress = 0 | |
for progress in range(instances_to_create): | |
r = requests.post(url) | |
if r.status_code not in response_count: | |
response_count[r.status_code] = 1 | |
else: | |
response_count[r.status_code] += 1 | |
if r.status_code!=200: | |
time.sleep(2.0) # Let's give a break to the server. | |
spinner.step(progress+1) | |
print response_count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment