Example #1
0
 def stream_events(self, inputs, ew):
     for input_name, input_item in inputs.inputs.iteritems():
         plat = input_item["latitude"]
         plon = input_item["longitude"]
         pradius = input_item["radius"]
         url = ENDPOINT.format(lat=plat, lon=plon, radius=pradius)
         xmlstring = requests.get(url).content
         root = ET.fromstring(xmlstring)
         items = root.find('channel').findall('item')
         for item in items:
             data = get_dict(item)
             event = Event()
             event.stanza = input_name
             event.sourceType = "ndbc:observations"
             event.data = json.dumps(data)
             ew.write_event(event)
Example #2
0
 def stream_events(self, inputs, ew):
     for input_name, input_item in inputs.inputs.iteritems():
         plat = input_item["latitude"]
         plon = input_item["longitude"]
         pradius = input_item["radius"]
         url = ENDPOINT.format(lat=plat, lon=plon, radius=pradius)
         xmlstring = requests.get(url).content
         root = ET.fromstring(xmlstring)
         items = root.find('channel').findall('item')
         for item in items:
             data = get_dict(item)
             event = Event()
             event.stanza = input_name
             event.sourceType = "ndbc:observations"
             event.data = json.dumps(data)
             ew.write_event(event)
Example #3
0
 def stream_events(self, inputs, ew):
     for input_name, input_item in inputs.inputs.iteritems():
         stations = input_item["stations"].split(" ")
         for station in stations:
             url = ENDPOINT.format(id=station)
             xmlstring = requests.get(url).content
             root = ET.fromstring(xmlstring)
             items = root.find('channel').findall('item')
             for item in items:
                 data = get_dict(item)
                 data['id'] = station
                 event = Event()
                 event.stanza = input_name
                 event.sourceType = "ndbc:observations"
                 event.data = json.dumps(data)
                 ew.write_event(event)
Example #4
0
 def stream_events(self, inputs, ew):
     for input_name, input_item in inputs.inputs.iteritems():
         xmlstring = requests.get(ENDPOINT).content
         root = ET.fromstring(xmlstring)
         time = root.get('created')
         stations = root.findall('station')
         for station in stations:
             data = dict()
             data['time'] = time
             for name in station.attrib:
                 value = station.get(name)
                 if name == 'elev' or name == 'lat' or name == 'lon':
                     value = float(value)
                 data[name] = value
             event = Event()
             event.stanza = input_name
             event.data = json.dumps(data)
             ew.write_event(event)
Example #5
0
 def stream_events(self, inputs, ew):
     for input_name, input_item in inputs.inputs.iteritems():
         xmlstring = requests.get(ENDPOINT).content
         root = ET.fromstring(xmlstring)
         time = root.get('created')
         stations = root.findall('station')
         for station in stations:
             data = dict()
             data['time'] = time
             for name in station.attrib:
                 value = station.get(name)
                 if name == 'elev' or name == 'lat' or name == 'lon':
                     value = float(value)
                 data[name] = value
             event = Event()
             event.stanza = input_name
             event.sourceType = "ndbc:activestations"
             event.data = json.dumps(data)
             ew.write_event(event)
Example #6
0
 def create_event(self, input_name, sourcetype, obj):
     event = Event()
     event.stanza = input_name
     event.sourceType = sourcetype
     event.data = self.to_json(obj)
     return event
Example #7
0
 def create_event(self, input_name, sourcetype, obj):
     event = Event()
     event.stanza = input_name
     event.sourceType = sourcetype
     event.data = self.to_json(obj)
     return event