From 5a8c316eb84d832ca248178149a30a04ca23795e Mon Sep 17 00:00:00 2001 From: roe-dl Date: Sun, 4 Aug 2024 12:02:53 +0200 Subject: [PATCH] fix update issue in health submodule #69 --- bin/user/weatherserviceshealth.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/user/weatherserviceshealth.py b/bin/user/weatherserviceshealth.py index faa87cd..7cbbf46 100644 --- a/bin/user/weatherserviceshealth.py +++ b/bin/user/weatherserviceshealth.py @@ -228,7 +228,7 @@ def __init__(self, name, conf_dict, archive_interval): self.area = conf_dict.get('area') self.target_path = conf_dict.get('path','.') self.filename = '%s-%s' % (self.model,conf_dict.get('file',self.area)) - self.data = dict() + self.data = [] self.tab = (dict(),dict()) loginf("thread '%s': area '%s', URL '%s'" % (self.name,self.area,self.url)) self.last_update = 0 @@ -721,18 +721,25 @@ def getRecord(self): except Exception as e: if self.log_failure: logerr("thread '%s': write HTML %s - %s" % (self.name,e.__class__.__name__,e)) + data.sort() try: self.lock.acquire() self.last_update = last_update self.next_update = next_update self.area_name = area_name - if self.data: - self.data = [self.data[-1]] + data + x = None + for i in self.data: + if i[1]==data[0][0]: + x = i + break + if x: + self.data = [x] + data else: self.data = data self.tab = tabtimespans finally: self.lock.release() + #loginf("getRecord %s" % ','.join(['(%s,%s)' % (i[0],i[1]) for i in self.data])) def waiting_time(self): now = time.time()