-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpanopticon.py
47 lines (40 loc) · 1.11 KB
/
panopticon.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This file is meant to routinely run and track report files and update the user with
# any changes
import subprocess
from time import sleep
reports = [
'mint_finance',
'nomie_query',
'nutrition_tracker',
'wakatime_analysis'
]
responses_library = {}
def show_update(updated_line):
print(updated_line)
def analyze_report(report_name):
global responses_library
text = subprocess.check_output(['python3', 'process/{name}.py'.format(name=report_name)])
lines = text.split(b'\n')
for i in lines:
try:
responses_library[i]
responses_library[i] = 0
except:
show_update(i)
responses_library[i] = 0
def clean_old_responses():
global responses_library
for i in list(responses_library.keys()):
if responses_library[i] > 0:
del responses_library[i]
else:
responses_library[i] += 1
def check_reports():
for i in reports:
analyze_report(i)
clean_old_responses()
ticks = 0
while True:
ticks += 1
print('Running #{0}'.format(ticks))
check_reports()