-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
33 lines (24 loc) · 791 Bytes
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import json
import argparse
import time
from datetime import datetime
def read_arguments():
parser = argparse.ArgumentParser(description="Update digital twin.")
args = parser.parse_args()
args = vars(args)
return args
if __name__ == '__main__':
args = read_arguments()
while True:
# get the current time
current_time = datetime.now().isoformat()
# create a dictionary to store the time
time_data = {
"current_time": current_time
}
# save the time to a JSON file
with open("time.json", "w") as json_file:
json.dump(time_data, json_file, indent=4)
print("Current time saved to time.json")
# wait for 50 seconds before the next update
time.sleep(50)