Skip to content

Instantly share code, notes, and snippets.

@skyl
Created December 29, 2011 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyl/1531186 to your computer and use it in GitHub Desktop.
Save skyl/1531186 to your computer and use it in GitHub Desktop.
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