- add start date and start time to filename

This commit is contained in:
2024-10-14 19:15:06 +02:00
parent 26f5647cb4
commit 5841ffa2ed
2 changed files with 12 additions and 5 deletions
+4 -5
View File
@@ -5,9 +5,9 @@ import pprint
from wci import wci
from credentials import user, password
import json
from folder_mgr.folder_mgr import get_date, date_has_changed, FolderMgr
from folder_mgr.folder_mgr import get_date, date_has_changed, to_date_str, to_time_str, FolderMgr
INTERVAL = 60
INTERVAL = 5*60
# Values after training
# Convert and write JSON object to file
@@ -47,6 +47,7 @@ def main():
_date_last = {}
f_mgr = FolderMgr()
_date_start = get_date()
while True:
start = time.time()
_date = get_date()
@@ -58,9 +59,7 @@ def main():
print(data)
data_list.append(data)
folder = f_mgr.update(f"results/{vin}", _date)
time_str = f"{_date['hour']}-{_date['min']}-{_date['sec']}"
date_str = f"{_date['year']}-{_date['month']}-{_date['day']}"
filename = f"vehicle_data_{date_str}_{time_str}.json"
filename = f"vehicle_{vin}_{to_date_str(_date_start)}_{to_time_str(_date_start)}.json"
_path = os.path.join(folder, filename)
with open(_path, "w") as fp:
json.dump(data_list, fp, indent=4)
+8
View File
@@ -15,6 +15,14 @@ def get_date() -> dict:
return _result
def to_time_str(_date: dict):
return f"{_date['hour']:02d}-{_date['min']:02d}-{_date['sec']:02d}"
def to_date_str(_date: dict):
return f"{_date['year']:04d}-{_date['month']:02d}-{_date['day']:02d}"
def date_has_changed(d1: dict, d2: dict, fields=['year', 'month', 'day']):
count = 0