def create_get_site_info_response(self, siteArg, varArg=None): siteCode = self.get_site_code(siteArg) siteResult = self.dao.get_site_by_code(siteCode) if (varArg is None or varArg == ''): seriesResultArr = self.dao.get_series_by_sitecode(siteCode) else: varCode = self.get_variable_code(varArg) seriesResultArr = self.dao.get_series_by_sitecode_and_varcode( siteCode, varCode) # if len(seriesResultArr) == 0: # return None siteInfoResponse = WaterML.SiteInfoResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetSiteInfo') pType_site = WaterML.parameterType(name='site', value=siteArg) criteria.add_parameter(pType_site) if varArg is not None: pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) s = self.create_site_element(siteResult, seriesResultArr) siteInfoResponse.add_site(s) return siteInfoResponse
def create_get_site_info_response(self, siteArg, varArg=None): siteCode = self.get_site_code(siteArg) siteResult = self.dao.get_site_by_code(siteCode) if (varArg is None or varArg == ''): seriesResultArr = self.dao.get_series_by_sitecode(siteCode) else: varCode = self.get_variable_code(varArg) seriesResultArr = self.dao.get_series_by_sitecode_and_varcode( siteCode, varCode) # if len(seriesResultArr) == 0: # return None siteInfoResponse = WaterML.SiteInfoResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetSiteInfo') pType_site = WaterML.parameterType(name='site', value=siteArg) criteria.add_parameter(pType_site) if varArg is not None: pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) s = self.create_site_element(siteResult, seriesResultArr) siteInfoResponse.add_site(s) return siteInfoResponse
def create_get_values_site_response(self, site, startDateTime, endDateTime): timeSeriesResponse = WaterML.TimeSeriesResponseType() logging.debug( 'create_get_values_site_response: timeSeriesResponse created') queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetValuesForASite') pType_site = WaterML.parameterType(name='site', value=site) criteria.add_parameter(pType_site) if startDateTime is not None: pType_sdate = WaterML.parameterType(name='startDate', value=startDateTime) criteria.add_parameter(pType_sdate) if endDateTime is not None: pType_edate = WaterML.parameterType(name='endDate', value=endDateTime) criteria.add_parameter(pType_edate) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') timeSeriesResponse.set_queryInfo(queryInfo) logging.debug( 'create_get_values_site_response: queryInfo set to timeSeriesResponse' ) siteCode = self.get_site_code(site) seriesResultArr = self.dao.get_series_by_sitecode(siteCode) logging.debug( 'create_get_values_site_response: seriesResultArr: {} series'. format(len(seriesResultArr))) if seriesResultArr: for seriesResult in seriesResultArr: valueResultArr = self.dao.get_datavalues_series( seriesResult, startDateTime, endDateTime) logging.debug( 'create_get_values_site_response: valueResultArr determined' ) # if not valueResultArr: # raise Exception( # ('ERROR: No data found for {} for dates ' # '{} - {}').format(site, startDateTime, endDateTime)) if not valueResultArr or len(valueResultArr) == 0: continue timeSeries = self.create_timeseries( siteCode, seriesResult.Variable.VariableCode, valueResultArr) timeSeriesResponse.add_timeSeries(timeSeries) return timeSeriesResponse
def create_get_values_site_response(self, site, startDateTime, endDateTime): timeSeriesResponse = WaterML.TimeSeriesResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetValuesForASite') pType_site = WaterML.parameterType(name='site', value=site) criteria.add_parameter(pType_site) if startDateTime is not None: pType_sdate = WaterML.parameterType( name='startDate', value=startDateTime ) criteria.add_parameter(pType_sdate) if endDateTime is not None: pType_edate = WaterML.parameterType( name='endDate', value=endDateTime ) criteria.add_parameter(pType_edate) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') timeSeriesResponse.set_queryInfo(queryInfo) siteCode = self.get_site_code(site) seriesResultArr = self.dao.get_series_by_sitecode(siteCode) if seriesResultArr: for seriesResult in seriesResultArr: valueResultArr = self.dao.get_datavalues( siteCode, seriesResult.Variable.VariableCode, startDateTime, endDateTime ) # if not valueResultArr: # raise Exception( # ('ERROR: No data found for {} for dates ' # '{} - {}').format(site, startDateTime, endDateTime)) if not valueResultArr: continue timeSeries = self.create_timeseries( siteCode, seriesResult.Variable.VariableCode, valueResultArr ) timeSeriesResponse.add_timeSeries(timeSeries) return timeSeriesResponse
def create_get_site_info_multiple_response(self, siteArg): siteCodesArr = siteArg.split(',') siteCodesArr = [self.get_site_code(s) for s in siteCodesArr] siteInfoResponse = WaterML.SiteInfoResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetSiteInfo') pType_site = WaterML.parameterType(name='site', value=siteArg) criteria.add_parameter(pType_site) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) for siteArg in siteCodesArr: siteCode = self.get_site_code(siteArg) siteResult = self.dao.get_site_by_code(siteCode) seriesResultArr = self.dao.get_series_by_sitecode(siteCode) # if len(seriesResultArr) == 0: # return None s = self.create_site_element(siteResult, seriesResultArr) siteInfoResponse.add_site(s) return siteInfoResponse
def create_get_site_response(self, siteArg=None): if siteArg is None or siteArg == '': siteResultArr = self.dao.get_all_sites() else: siteCodesArr = siteArg.split(',') siteCodesArr = [self.get_site_code(s) for s in siteCodesArr] siteResultArr = self.dao.get_sites_by_codes(siteCodesArr) # if len(siteResultArr) == 0: # return None siteInfoResponse = WaterML.SiteInfoResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) # TODO: check on how this should be done for multiple sites. pType = WaterML.parameterType(name='site', value=siteArg) criteria = WaterML.criteriaType(MethodCalled='GetSites') criteria.add_parameter(pType) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) if siteResultArr: for siteResult in siteResultArr: s = self.create_site_element(siteResult) siteInfoResponse.add_site(s) else: # site = WaterML.site() # siteInfoResponse.add_site(site) raise Exception("Site {} Not Found".format(siteArg)) return siteInfoResponse
def create_get_variable_info_response(self, varArg=None): if (varArg is None or varArg == ''): variableResultArr = self.dao.get_all_variables() else: varCodesArr = varArg.split(',') varCodesArr = [self.get_variable_code(v) for v in varCodesArr] variableResultArr = self.dao.get_variables_by_codes(varCodesArr) variableInfoResponse = WaterML.VariablesResponseType() # TODO: Should queryInfo be in thois response? Suds doesn't # like when it is. If it should be in the response, then the # WSDL needs to be updated queryInfo = WaterML.QueryInfoType() criteria = WaterML.criteriaType(MethodCalled='GetVariableInfo') if varArg is not None: pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) queryInfo.set_criteria(criteria) queryInfoNote = WaterML.NoteType('Web Service') queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') variableInfoResponse.set_queryInfo(queryInfo) variables = WaterML.variablesType() for variableResult in variableResultArr: v = self.create_variable_element(variableResult) variables.add_variable(v) variableInfoResponse.set_variables(variables) return variableInfoResponse
def create_get_variable_info_response(self, varArg=None): if (varArg is None or varArg == ''): variableResultArr = self.dao.get_all_variables() else: varCodesArr = varArg.split(',') varCodesArr = [self.get_variable_code(v) for v in varCodesArr] variableResultArr = self.dao.get_variables_by_codes(varCodesArr) variableInfoResponse = WaterML.VariablesResponseType() # TODO: Should queryInfo be in thois response? Suds doesn't # like when it is. If it should be in the response, then the # WSDL needs to be updated queryInfo = WaterML.QueryInfoType() criteria = WaterML.criteriaType(MethodCalled='GetVariableInfo') if varArg is not None: pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) queryInfo.set_criteria(criteria) queryInfoNote = WaterML.NoteType('Web Service') queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') variableInfoResponse.set_queryInfo(queryInfo) variables = WaterML.variablesType() for variableResult in variableResultArr: v = self.create_variable_element(variableResult) variables.add_variable(v) variableInfoResponse.set_variables(variables) return variableInfoResponse
def create_get_site_info_multiple_response(self, siteArg): siteCodesArr = siteArg.split(',') siteCodesArr = [self.get_site_code(s) for s in siteCodesArr] siteInfoResponse = WaterML.SiteInfoResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetSiteInfo') pType_site = WaterML.parameterType(name='site', value=siteArg) criteria.add_parameter(pType_site) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) for siteArg in siteCodesArr: siteCode = self.get_site_code(siteArg) siteResult = self.dao.get_site_by_code(siteCode) seriesResultArr = self.dao.get_series_by_sitecode(siteCode) # if len(seriesResultArr) == 0: # return None s = self.create_site_element(siteResult, seriesResultArr) siteInfoResponse.add_site(s) return siteInfoResponse
def create_get_site_response(self, siteArg=None): if siteArg is None or siteArg == '': siteResultArr = self.dao.get_all_sites() else: siteCodesArr = siteArg.split(',') siteCodesArr = [self.get_site_code(s) for s in siteCodesArr] siteResultArr = self.dao.get_sites_by_codes(siteCodesArr) # if len(siteResultArr) == 0: # return None siteInfoResponse = WaterML.SiteInfoResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) # TODO: check on how this should be done for multiple sites. pType = WaterML.parameterType(name='site', value=siteArg) criteria = WaterML.criteriaType(MethodCalled='GetSites') criteria.add_parameter(pType) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) if siteResultArr: for siteResult in siteResultArr: s = self.create_site_element(siteResult) siteInfoResponse.add_site(s) else: # site = WaterML.site() # siteInfoResponse.add_site(site) raise Exception("Site {} Not Found".format(siteArg)) return siteInfoResponse
def create_get_site_response(self, siteArg=None): # Flavio: # Creates in siteResultArr an array of Site objects, # corresponding to an array of sites represented as # "network:siteCode" if siteArg is None or siteArg == '': siteResultArr = self.dao.get_all_sites() else: # Flavio: # builds an array of siteCodes and cleans every siteCode # (by eliminating the network part in the network:siteCode representation) siteCodesArr = siteArg.split(',') siteCodesArr = [self.get_site_code(s) for s in siteCodesArr] siteResultArr = self.dao.get_sites_by_codes(siteCodesArr) # if len(siteResultArr) == 0: # return None # Flavio: Creates a SiteInfoResponseType object (siteInfoResponse) siteInfoResponse = WaterML.SiteInfoResponseType() # Flavio: Creates a QueryInfoType object with current datetime queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) # TODO: check on how this should be done for multiple sites. # Flavio: Creates a parameterType object with parameter site and values siteArg, # adds to a criteriaType object with GetSites as MethodCalled, # sets the criteria of the QueryInfoType object to the criteriaType # object and sets the queryInfo of the SiteInfoResponseType to # the QueryInfoType object pType = WaterML.parameterType(name='site', value=siteArg) criteria = WaterML.criteriaType(MethodCalled='GetSites') criteria.add_parameter(pType) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) # Flavio: For every site in siteResultArr create a siteType element # (composed of a siteInfoType element and possibly # one seriesCatalogType element - not in this case) # and adds it to siteInfoResponse # if siteResultArray is None or empty raises an Exception if siteResultArr: for siteResult in siteResultArr: s = self.create_site_element(siteResult) siteInfoResponse.add_site(s) else: # site = WaterML.site() # siteInfoResponse.add_site(site) raise Exception("Site {} Not Found".format(siteArg)) return siteInfoResponse
def create_get_site_box_response(self, west, south, east, north, IncludeSeries): IncludeSeries = self.to_bool(IncludeSeries) siteResultArr = self.dao.get_sites_by_box(west, south, east, north) siteInfoResponse = WaterML.SiteInfoResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetSitesByBox') pType_west = WaterML.parameterType(name='west', value=west) pType_west = WaterML.parameterType(name='south', value=south) pType_west = WaterML.parameterType(name='east', value=east) pType_west = WaterML.parameterType(name='north', value=north) pType_west = WaterML.parameterType(name='IncludeSeries', value=IncludeSeries) # noqa criteria.add_parameter(pType_west) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') siteInfoResponse.set_queryInfo(queryInfo) for siteResult in siteResultArr: seriesResultArr = None if IncludeSeries: seriesResultArr = self.dao.get_series_by_sitecode(siteResult.SiteCode) # noqa # if len(seriesResultArr) == 0: # return None s = self.create_site_element( siteResult, seriesResultArr, IncludeSeries ) siteInfoResponse.add_site(s) return siteInfoResponse
def create_get_values_response(self, siteArg, varArg, startDateTime=None, endDateTime=None): # TODO: Tim thinks the DAO should handle network and vocab parsing, # not WOF # Flavio: # cleans the siteCode, by eliminating the network part in the # network:siteCode representation # cleans the varCode, by eliminating the vocabulary part in the # vocabular:varCode representation siteCode = self.get_site_code(siteArg) varCode = self.get_variable_code(varArg) valueResultArr = self.dao.get_datavalues(siteCode, varCode, startDateTime, endDateTime) # if not valueResultArr: # raise Exception( # "ERROR: No data found for {}:{} for dates {} - {}".format( # siteCode, varCode, startDateTime, endDateTime # ) # ) # Flavio: # Creates timeSeriesResponse (a WaterML1.1 TimeSeriesResponseType object) # with queryInfo (site, variable, startDate, endDate) timeSeriesResponse = WaterML.TimeSeriesResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetValues') pType_site = WaterML.parameterType(name='site', value=siteArg) criteria.add_parameter(pType_site) pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) if startDateTime is not None: pType_sdate = WaterML.parameterType(name='startDate', value=startDateTime) criteria.add_parameter(pType_sdate) if endDateTime is not None: pType_edate = WaterML.parameterType(name='endDate', value=endDateTime) criteria.add_parameter(pType_edate) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') timeSeriesResponse.set_queryInfo(queryInfo) logging.debug( 'create_get_values_response: timeSeriesResponse created with queryInfo' ) # if not valueResultArr: # timeSeries = WaterML.TimeSeriesType() # timeSeriesResponse.add_timeSeries(timeSeries) # return timeSeriesResponse if not valueResultArr: raise Exception( "Values Not Found for {}:{} for dates {} - {}".format( siteCode, varCode, startDateTime, endDateTime)) if isinstance(valueResultArr, dict): logging.debug('create_get_values_response: valueResultArr is dict') for key in valueResultArr.keys(): timeSeries = self.create_timeseries(siteCode, key, valueResultArr[key]) timeSeriesResponse.add_timeSeries(timeSeries) else: logging.debug( 'create_get_values_response: valueResultArr is not dict') timeSeries = self.create_timeseries(siteCode, varCode, valueResultArr) timeSeriesResponse.add_timeSeries(timeSeries) return timeSeriesResponse
def create_get_variable_info_response(self, varArg=None): # Flavio: # Creates in variableResultArr an array of Variable objects, # corresponding to an array of variables in varCodesArr # or all variables if no array if (varArg is None or varArg == ''): variableResultArr = self.dao.get_all_variables() else: varCodesArr = varArg.split(',') varCodesArr = [self.get_variable_code(v) for v in varCodesArr] variableResultArr = self.dao.get_variables_by_codes(varCodesArr) # Flavio: Creates a VariablesResponseType object (variableInfoResponse) variableInfoResponse = WaterML.VariablesResponseType() # TODO: Should queryInfo be in thois response? Suds doesn't # like when it is. If it should be in the response, then the # WSDL needs to be updated # Flavio: Creates a QueryInfoType object (queryInfo) queryInfo = WaterML.QueryInfoType() # Flavio: creates a criteriaType object (criteria) with GetVariableInfo as # MethodCalled; if not None, adds varArg as a variable parameter # sets the criteria of queryInfo to criteria # and sets the queryInfo of variableInfoResponse to queryInfo criteria = WaterML.criteriaType(MethodCalled='GetVariableInfo') if varArg is not None: pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) queryInfo.set_criteria(criteria) queryInfoNote = WaterML.NoteType('Web Service') queryInfo.add_note(queryInfoNote) logging.debug('create_get_variable_info_response: queryInfo created') # queryInfo.set_extension('') variableInfoResponse.set_queryInfo(queryInfo) # Flavio: creates a variablesType element (variables) # adds to it every variable in variableResultArr, # sets it to variableInfoResponse and returns # variableInfoResponse variables = WaterML.variablesType() for v in variableResultArr: logging.debug('VariableID: {!s}, VariableCode: {!s}, '.format( v.VariableID, v.VariableCode) + 'VariableName: {!s}, VariableUnitsID: {!s}, '.format( v.VariableName, v.VariableUnitsID) + 'SampleMedium: {!s}, ValueType: {!s}, '.format( v.SampleMedium, v.ValueType) + 'IsRegular: {!s}, TimeSupport: {!s}, '.format( v.IsRegular, v.TimeSupport) + 'TimeUnitsID: {!s}, DataType: {!s}, '.format( v.TimeUnitsID, v.DataType) + 'GeneralCategory: {!s}, NoDataValue: {!s}'.format( v.GeneralCategory, v.NoDataValue)) for variableResult in variableResultArr: v = self.create_variable_element(variableResult) logging.debug( 'create_get_variable_info_response: variable {!s} created'. format(variableResult.VariableCode)) variables.add_variable(v) logging.debug('create_get_variable_info_response: variables created') variableInfoResponse.set_variables(variables) return variableInfoResponse
def create_get_values_response(self, siteArg, varArg, startDateTime=None, endDateTime=None): # TODO: Tim thinks the DAO should handle network and vocab parsing, # not WOF siteCode = self.get_site_code(siteArg) varCode = self.get_variable_code(varArg) valueResultArr = self.dao.get_datavalues(siteCode, varCode, startDateTime, endDateTime) # if not valueResultArr: # raise Exception( # "ERROR: No data found for {}:{} for dates {} - {}".format( # siteCode, varCode, startDateTime, endDateTime # ) # ) timeSeriesResponse = WaterML.TimeSeriesResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetValues') pType_site = WaterML.parameterType(name='site', value=siteArg) criteria.add_parameter(pType_site) pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) if startDateTime is not None: pType_sdate = WaterML.parameterType(name='startDate', value=startDateTime) criteria.add_parameter(pType_sdate) if endDateTime is not None: pType_edate = WaterML.parameterType(name='endDate', value=endDateTime) criteria.add_parameter(pType_edate) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') timeSeriesResponse.set_queryInfo(queryInfo) # if not valueResultArr: # timeSeries = WaterML.TimeSeriesType() # timeSeriesResponse.add_timeSeries(timeSeries) # return timeSeriesResponse if not valueResultArr: raise Exception( "Values Not Found for {}:{} for dates {} - {}".format( siteCode, varCode, startDateTime, endDateTime)) if isinstance(valueResultArr, dict): for key in valueResultArr.keys(): timeSeries = self.create_timeseries(siteCode, key, valueResultArr[key]) timeSeriesResponse.add_timeSeries(timeSeries) else: timeSeries = self.create_timeseries(siteCode, varCode, valueResultArr) timeSeriesResponse.add_timeSeries(timeSeries) return timeSeriesResponse
def create_get_values_response(self, siteArg, varArg, startDateTime=None, endDateTime=None): # TODO: Tim thinks the DAO should handle network and vocab parsing, # not WOF siteCode = self.get_site_code(siteArg) varCode = self.get_variable_code(varArg) valueResultArr = self.dao.get_datavalues(siteCode, varCode, startDateTime, endDateTime) # if not valueResultArr: # raise Exception( # "ERROR: No data found for {}:{} for dates {} - {}".format( # siteCode, varCode, startDateTime, endDateTime # ) # ) timeSeriesResponse = WaterML.TimeSeriesResponseType() queryInfo = WaterML.QueryInfoType(creationTime=datetime.datetime.now()) criteria = WaterML.criteriaType(MethodCalled='GetValues') pType_site = WaterML.parameterType(name='site', value=siteArg) criteria.add_parameter(pType_site) pType_var = WaterML.parameterType(name='variable', value=varArg) criteria.add_parameter(pType_var) if startDateTime is not None: pType_sdate = WaterML.parameterType( name='startDate', value=startDateTime ) criteria.add_parameter(pType_sdate) if endDateTime is not None: pType_edate = WaterML.parameterType( name='endDate', value=endDateTime ) criteria.add_parameter(pType_edate) queryInfo.set_criteria(criteria) # queryInfoNote = WaterML.NoteType() # queryInfo.add_note(queryInfoNote) # queryInfo.set_extension('') timeSeriesResponse.set_queryInfo(queryInfo) # if not valueResultArr: # timeSeries = WaterML.TimeSeriesType() # timeSeriesResponse.add_timeSeries(timeSeries) # return timeSeriesResponse if not valueResultArr: raise Exception( "Values Not Found for {}:{} for dates {} - {}".format( siteCode, varCode, startDateTime, endDateTime) ) if isinstance(valueResultArr, dict): for key in valueResultArr.keys(): timeSeries = self.create_timeseries( siteCode, key, valueResultArr[key] ) timeSeriesResponse.add_timeSeries(timeSeries) else: timeSeries = self.create_timeseries( siteCode, varCode, valueResultArr ) timeSeriesResponse.add_timeSeries(timeSeries) return timeSeriesResponse