Refactored
This commit is contained in:
+5
-3
@@ -61,12 +61,12 @@ def main():
|
|||||||
while True:
|
while True:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
_date = get_date()
|
_date = get_date()
|
||||||
|
timestamp = create_timestamp()
|
||||||
if date_has_changed(_date_last, _date):
|
if date_has_changed(_date_last, _date):
|
||||||
record_id = 0
|
record_id = 0
|
||||||
record_list = []
|
record_list = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
timestamp = create_timestamp()
|
|
||||||
data = w.get(endpoint)
|
data = w.get(endpoint)
|
||||||
record_list.append({'info': {'record_id': record_id, 'timestamp': timestamp}, 'data': data})
|
record_list.append({'info': {'record_id': record_id, 'timestamp': timestamp}, 'data': data})
|
||||||
folder = f_mgr.update(f"results/{vin}", _date)
|
folder = f_mgr.update(f"results/{vin}", _date)
|
||||||
@@ -78,11 +78,13 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Exception: {e}")
|
print(f"Exception: {e}")
|
||||||
|
|
||||||
|
_date_last = _date
|
||||||
|
record_id += 1
|
||||||
|
|
||||||
|
# wait until next loop
|
||||||
stop = time.time()
|
stop = time.time()
|
||||||
diff = int(stop - start)
|
diff = int(stop - start)
|
||||||
time.sleep(max(0, INTERVAL - diff))
|
time.sleep(max(0, INTERVAL - diff))
|
||||||
_date_last = _date
|
|
||||||
record_id += 1
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user