def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) if self.template_file_root is None: self.template_file_root = path.join( path.dirname(path.realpath(__file__)), 'statemplates') # Template file, to be used as POST body with substituted values # TODO use Jinja2 formatting i.s.o. basic string formatting self.entities_list = [ 'thing', 'location', 'datastream', 'observation', 'observedproperty', 'sensor' ] self.entity_templates = {} self.sensors = {} self.things = {} self.locations = {} self.observedproperties = {} self.base_path = self.path self.base_url = 'http://%s:%d%s' % (self.host, self.port, self.path) self.http_session = requests.Session()
def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) # Construct write path self.path = '/write?db=%s' % self.database # Construct the template line to be used for each data frame # e.g. 'joseraw,station=%s,component=%s value=%s %s' self.tags_template = None if self.tags_map: self.tags = self.tags_map.keys() self.tags_template = '' for tag in self.tags: self.tags_template += ',' + tag + '=%s' self.geohash_template = None if self.geohash_map or self.geohash_wkt_attr: self.geohash_template = ',geohash="%s" ' self.fields = self.fields_map.keys() self.fields_template = ' ' for field in self.fields: self.fields_template += field + '=%s' # will expand to e.g. joseraw,station=19,component=no2raw value=12345 1434055562000000000 # tags, fields and timestamp will be filled when creating payload self.template_data_line = self.measurement + '%s%s%s\n'
def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) # Template file, to be used as POST body with substituted values self.insert_sensor_templ_path = '%s/insert-sensor.json' % self.template_file_root self.insert_obs_templ_path ='%s/insert-observation.json' % self.template_file_root self.proc_desc_templ_path = '%s/procedure-desc.xml' % self.template_file_root self.insert_sensor_templ_str = None self.insert_obs_templ_str = None
def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) self.content_type = self.cfg.get('content_type', 'application/json;charset=UTF-8') self.sos_request = self.cfg.get('sos_request', 'insert-observation') # Template file, to be used as POST body with substituted values self.template_file_ext = self.cfg.get('template_file_ext', 'json') self.template_file_root = self.cfg.get('template_file_root', 'sostemplates') self.template_file_path = '%s/%s.%s' % (self.template_file_root, self.sos_request, self.template_file_ext)
def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) # Template file, to be used as POST body with substituted values self.insert_sensor_templ_path = '%s/insert-sensor.json' % self.template_file_root self.insert_obs_templ_path = '%s/insert-observation.json' % self.template_file_root self.proc_desc_templ_path = '%s/procedure-desc.xml' % self.template_file_root self.insert_sensor_templ_str = None self.insert_obs_templ_str = None
def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) # Template file, to be used as POST body with substituted values # TODO use Jinja2 formatting i.s.o. basic string formatting self.entities_list = ['thing', 'datastream', 'observation', 'observedproperty', 'sensor'] self.entity_templates = {} self.sensors = {} self.things = {} self.observedproperties = {} self.base_path = self.path self.base_url = 'http://%s:%d%s' % (self.host, self.port, self.path)
def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) # Construct write path self.path = '/write?db=%s' % self.database # Construct the template line to be used for each data frame # We split into separate sub-templates for tags, fields, optional geohashes # Optional Tags template self.tags_template = None if self.tags_map: self.tags = self.tags_map.keys() self.tags_template = '' for tag in self.tags: if self.tags_template: # Additional tags self.tags_template += ',' + tag + '=%s' else: # First or one tag self.tags_template = tag + '=%s' # Required Fields template (need at least one field) self.fields_template = None self.fields = self.fields_map.keys() for field in self.fields: if self.fields_template: # Additional fields self.fields_template += ',' + field + '=%s' else: # First or one field self.fields_template = field + '=%s' # Optional extra geohash as tag template if self.geohash_tag: self.geohash_tag_template = ',' + self.geohash_tag_name + '=%s' # Optional extra geohash as field template if self.geohash_field: self.geohash_field_template = ',' + self.geohash_field_name + '="%s"' # will expand to <measurement>,<tags> <fields> # e.g. joseraw,station=19,component=no2raw value=12345,geohash_tag=uvx53kryp 1434055562000000000 # tags, fields and timestamp will be substituted when creating payload self.template_data_line = self.measurement + ',%s %s %d\n' self.base_path = self.path self.base_url = 'http://%s:%d%s' % (self.host, self.port, self.path) self.http_session = requests.Session()
def __init__(self, configdict, section): HttpOutput.__init__(self, configdict, section, consumes=FORMAT.record_array) if self.template_file_root is None: self.template_file_root = path.join( path.dirname(path.realpath(__file__)), 'sostemplates') # Template file, to be used as POST body with substituted values self.insert_sensor_templ_path = '%s/insert-sensor.json' % self.template_file_root self.update_sensor_desc_templ_path = '%s/update-sensor-desc.json' % self.template_file_root self.insert_obs_templ_path = '%s/insert-observation.json' % self.template_file_root self.proc_desc_templ_path = '%s/procedure-desc.xml' % self.template_file_root self.insert_sensor_templ_str = None self.update_sensor_desc_templ_str = None self.insert_obs_templ_str = None