connector/apiConnector.py
def fetch_data(self, q, hr, min):
        """Data fetch thread. Runs at 00:30 every day"""
        while True:
            try:
                self.update_url()
                data = self.fetch_data_api()
                if data is not None:
                    data_list = self.extract_data(data)
                    meas_list = []
                    for row in data_list:
                        meas = self.to_senml(row[0], row[1], row[2], self.name)
                        meas_list.append(meas)
                    logger.info("length of data = "+str(len(meas_list)))
                    doc = senml.SenMLDocument(meas_list)
                    json_data = doc.to_json()
                    json_data = json.dumps(json_data)
                    q.put(json_data)
                delay = self.get_delay_time(hr, min)
                time.sleep(delay)
            except Exception as e:
                logger.error(e)
                time.sleep(10)
Data fetch thread. Runs at 00:30 every day
Data fetch thread. Runs at 00:30 every day
Data fetch thread . Runs at 00 : 30 every day
def fetch_data(self, q, hr, min):
        while True:
            try:
                self.update_url()
                data = self.fetch_data_api()
                if data is not None:
                    data_list = self.extract_data(data)
                    meas_list = []
                    for row in data_list:
                        meas = self.to_senml(row[0], row[1], row[2], self.name)
                        meas_list.append(meas)
                    logger.info("length of data = "+str(len(meas_list)))
                    doc = senml.SenMLDocument(meas_list)
                    json_data = doc.to_json()
                    json_data = json.dumps(json_data)
                    q.put(json_data)
                delay = self.get_delay_time(hr, min)
                time.sleep(delay)
            except Exception as e:
                logger.error(e)
                time.sleep(10)
def fetch_data ( self , q , hr , min ) : while True : try : self . update_url ( ) data = self . fetch_data_api ( ) if data is not None : data_list = self . extract_data ( data ) meas_list = [ ] for row in data_list : meas = self . to_senml ( row [ 0 ] , row [ 1 ] , row [ 2 ] , self . name ) meas_list . append ( meas ) logger . info ( "length of data = " + str ( len ( meas_list ) ) ) doc = senml . SenMLDocument ( meas_list ) json_data = doc . to_json ( ) json_data = json . dumps ( json_data ) q . put ( json_data ) delay = self . get_delay_time ( hr , min ) time . sleep ( delay ) except Exception as e : logger . error ( e ) time . sleep ( 10 )
Data fetch thread.
Data fetch thread .
"""Data fetch thread. Runs at 00:30 every day"""
self
q
hr
min