Skip to content

Instantly share code, notes, and snippets.



Created Mar 1, 2011
What would you like to do?
play a sound when there's a tornado warning near me
# WARNING: If you want to use it, don't rely on it, and you'd have to edit it to get to work for you, wherever you are, if you're in the US.
from lxml import etree
from urllib2 import urlopen
from subprocess import Popen, PIPE
entries = w.findall('{}entry')
for x in entries:
thisentry = {}
thisentry.update({'msgType': list(x.findall('{urn:oasis:names:tc:emergency:cap:1.1}msgType')[0].itertext())[0]})
thisentry.update({'urgency': list(x.findall('{urn:oasis:names:tc:emergency:cap:1.1}urgency')[0].itertext())[0]})
thisentry.update({'severity': list(x.findall('{urn:oasis:names:tc:emergency:cap:1.1}severity')[0].itertext())[0]})
thisentry.update({'areaDesc': list(x.findall('{urn:oasis:names:tc:emergency:cap:1.1}areaDesc')[0].itertext())[0]})
thisentry.update({'title': list(x.findall('{}title')[0].itertext())[0]})
county = [x for x in values if x['areaDesc'].lower().__contains__(COUNTY)]
immediate_extreme = [x for x in county if x['urgency'].lower()=='immediate' and x['severity'].lower()=='extreme']
if len(immediate_extreme) > 0:
output = output = Popen(["/home/thomas/", "/home/thomas/emergency.wav"], stdout=PIPE).communicate()[0]

This comment has been minimized.

Copy link
Owner Author

@th0ma5w th0ma5w commented Mar 1, 2011

heh, some voodoo and redundant code, i was tired! :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment