-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTracker.py
More file actions
executable file
·27 lines (22 loc) · 838 Bytes
/
Tracker.py
File metadata and controls
executable file
·27 lines (22 loc) · 838 Bytes
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
from CSVManager import CSVManager
from RequestManager import RequestManager
import sched, time, json
class Tracker:
def __init__(self, file_path):
self.file_path = file_path
file = open(file_path)
config = json.load(file)
self.scheduler = sched.scheduler(time.time, time.sleep)
self.timer = config["frequency_seconds"]
def writeNewValues(self):
file = open(self.file_path)
config = json.load(file)
data = RequestManager.getPrices(config)
CSVManager.write(data[0], data[1])
print("---------------- Added Line ----------------- ")
print(data[0])
print(data[1])
self.scheduler.enter(self.timer, 1, self.writeNewValues)
def track(self):
self.scheduler.enter(0, 1, self.writeNewValues)
self.scheduler.run()