aboutsummaryrefslogtreecommitdiff
path: root/src/Watcher/report_creation.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/Watcher/report_creation.py')
-rwxr-xr-xsrc/Watcher/report_creation.py67
1 files changed, 21 insertions, 46 deletions
diff --git a/src/Watcher/report_creation.py b/src/Watcher/report_creation.py
index 3bae496..c635f93 100755
--- a/src/Watcher/report_creation.py
+++ b/src/Watcher/report_creation.py
@@ -2,82 +2,57 @@ import csv
import os
import time_operations as to
from log_files import get_date
+from colored_text import Color
-class color:
- GREY = '\033[30m'
- PURPLE = '\033[95m'
- CYAN = '\033[96m'
- DARKCYAN = '\033[36m'
- BLUE = '\033[34m'
- GREEN = '\033[32m'
- YELLOW = '\033[33m'
- RED = '\033[31m'
- BOLD = '\033[1m'
- UNDERLINE = '\033[4m'
- END = '\033[0m'
-
-date = get_date()
-def load_raw_data(date):
+def imp(date):
user = os.getlogin()
path = "/home/" + user +"/.cache/Watcher/raw_data/"
filename = path + date + ".csv"
- l = list()
+ l = list() # l = list of (app_name, time spent on app on that session)
d = dict()
with open(filename, 'r') as file:
reader = csv.reader(file)
for row in reader:
for column in row:
- l.append([column[0:8],column[9::]])
- d.update({column[9::]: "opened"})
- #print(column[0:8])
- #print(column[9::])
-
- d = list(d)
- return l, d
-#print(raw_data_list[1][1]
-#print(window_opened)
-def each_session(raw_data_list):
- time_spent = []
- for i in range(len(raw_data_list)-1):
- a = raw_data_list[i][0]
- b = raw_data_list[i+1][0]
- time_spent.append([raw_data_list[i][1], to.time_difference(a, b)])
+ l.append([column[18::],column[9:18]])
+ d.update({column[18::]: "O"})
- return time_spent
+ d = list(d) # list of app opened on that day
+ return d, l
-# creating dictionary to store time spend on each applicaitons
+# creating dictionary to store time spend on each applicaitons on that particular day
def final_report(window_opened, time_spent):
report = dict()
- for i in window_opened:
+ for i in window_opened: # i is applications name
time = '00:00:00'
- for j in time_spent:
+ for j in time_spent: # j is list of applicaions_name and time_spent in particular session
if i == j[0]:
- #print(j[to.1],i)
time = to.time_addition(j[1], time)
report.update({i:time})
+ report.pop("User-loged-in")
return report
# ░ ▒ █ ───
#print("▒▒▒\t▒▒▒\n███")
-raw_data_list, window_opened = load_raw_data(date)
-time_spent = each_session(raw_data_list)
-
-
-if __name__ == "__main__":
-
+def prints_report(window_opened, time_spent):
Total_screen_time = "00:00:00"
for x,y in final_report(window_opened, time_spent).items():
Total_screen_time = to.time_addition(y, Total_screen_time)
- print(color.YELLOW + "\n Today's Screen-Time \t\t " + color.END + color.BLUE + to.convert_time(Total_screen_time)+ color.END)
+ print(Color.YELLOW("\n Today's Screen-Time \t\t ") + Color.BLUE(to.convert_time(Total_screen_time)))
print("─────────────────────────────────────────────────")
- print(color.RED + f'{"App Usages":>28}' + color.END)
+ print(Color.RED(f'{"App Usages":>28}'))
print("─────────────────────────────────────────────────")
for x,y in final_report(window_opened, time_spent).items():
if x == "":
- x = "HOME-SCREEN"
- print(color.GREEN + " "+f'{x:<21}' + color.END ,'\t',to.convert_time(y))
+ x = "Home-Screen"
+ print(" " + Color.GREEN(f'{x:<21}') + '\t\t ',to.convert_time(y))
+
+if __name__ == "__main__":
+ date = get_date()
+ window_opened, time_spent = imp(date)
+ prints_report(window_opened, time_spent)