Skip to content

Instantly share code, notes, and snippets.

@skyl skyl/gist:1531186
Created Dec 29, 2011

Embed
What would you like to do?
Fill varnish with requests
import urllib
import requests
exposure_liability_map = {
"people": [
#("RESDQ", "All residents Day"),
("RESNQ", "Night Residents"),
("RESFDQ", "Female residents Day"),
("RESN4Q", "Night residents < 4yo"),
],
"buildings": [
("RINF_BAQ", "Building Area (m2)"),
],
"infrastructure": [
("PPQ", "MW capacity"),
],
"esa": [
("Something", "IDK"),
],
}
ROOT_URL = "http://173.203.127.51/cityrisk/"
cities = [u'Manila', u'Ningbo']
ets = [u'earthquake', u'landslide', u'typhoon', u'monsoon', u'drought']
LIABILITIES = ("people", "buildings", "infrastructure", "esa")
def main():
for city in cities:
for et in ets:
for l in LIABILITIES:
for exp in exposure_liability_map[l]:
url = "{url}?city={city}&exposure_type={exposure_type}&liability={liability}&exposure={exposure}".format(**{
"url": ROOT_URL,
"city": city,
"exposure_type": et,
"liability": l,
"exposure": exp[0],
})
print url
res = requests.get(url)
print res.headers
raw_input("ok? ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.