askcompu

Untitled

Jul 29th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1.     query = query.replace('!', '')
  2.     query = web.quote(query)
  3.     uri = 'http://api.wunderground.com/api/' + phenny.config.wunderground_api_key + '/conditions/q/' + query + '.json'
  4.     rec_bytes = web.get(uri)
  5.     jsonstring = json.loads(rec_bytes)
  6.     werror = 0
  7.     try
  8.         werrorexist = jsonstring['response']['error']['type']
  9.         werror = 1
  10.     except
  11.         werror = 0
  12.        
  13.     if werror is 1:
  14.         werrortype = jsonstring['response']['error']['type']
  15.         werrordesc = jsonstring['response']['error']['description']
  16.         werrorfull = werrortype + ' - ' + werrordesc
  17.         return werrorfull
Advertisement
Add Comment
Please, Sign In to add comment