aboutsummaryrefslogtreecommitdiff
path: root/src/Watcher/report_creation.py
diff options
context:
space:
mode:
authorLibravatar Waishnav <[email protected]>2022-03-12 22:38:01 +0530
committerLibravatar Waishnav <[email protected]>2022-03-12 22:38:01 +0530
commit6352e4288ab5489c57ead68b97e3fc1f60bc6097 (patch)
tree3c0d76c049a0dfbca55d3917ce824510a72cf321 /src/Watcher/report_creation.py
parent5ff9b08a4230210572c4b02dfc784c31c1986dea (diff)
downloadshopno-os-log-sync-6352e4288ab5489c57ead68b97e3fc1f60bc6097.tar.gz
shopno-os-log-sync-6352e4288ab5489c57ead68b97e3fc1f60bc6097.zip
completed week overview feature
Diffstat (limited to '')
-rwxr-xr-xsrc/Watcher/report_creation.py59
1 files changed, 15 insertions, 44 deletions
diff --git a/src/Watcher/report_creation.py b/src/Watcher/report_creation.py
index bde5d2d..1e080db 100755
--- a/src/Watcher/report_creation.py
+++ b/src/Watcher/report_creation.py
@@ -37,7 +37,9 @@ def final_report(window_opened, time_spent):
time = to.time_addition(j[1], time)
report.update({i:time})
- #report.pop("User-logged-in")
+ #print(report)
+ if "User-logged-in" in report.keys():
+ report.pop("User-logged-in")
# sort report dictonary in decreasing order of Usages
sorted_values = []
for x,y in report.items():
@@ -56,56 +58,25 @@ def final_report(window_opened, time_spent):
# ░ ▒ █ ───
#print("▒▒▒\t▒▒▒\n███")
-def prints_report(window_opened, time_spent, is_week):
+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)
- if is_week:
- print(Color.YELLOW("\n Week's Screen-Time\t\t ") + Color.BLUE(to.convert_time(Total_screen_time)))
- else:
- print(Color.YELLOW("\n Today's Screen-Time\t\t ") + Color.BLUE(to.convert_time(Total_screen_time)))
+
+ if len(to.format_time(Total_screen_time)) == 3:
+ print(Color.YELLOW("\n Today's Screen-Time\t\t ") + Color.BLUE(f'{to.format_time(Total_screen_time):>16}'))
+ elif len(to.format_time(Total_screen_time)) == 7:
+ print(Color.YELLOW("\n Today's Screen-Time\t\t ") + Color.BLUE(f'{to.format_time(Total_screen_time):>11}'))
+ elif len(to.format_time(Total_screen_time)) == 11:
+ print(Color.YELLOW("\n Today's Screen-Time\t\t ") + Color.BLUE(to.format_time(Total_screen_time)))
+
print(" ────────────────────────────────────────────────")
- print(Color.RED(f'{" App Usages":>28}'))
+ print(Color.RED(f'{" App Usages":>29}'))
print(" ────────────────────────────────────────────────")
for x,y in final_report(window_opened, time_spent).items():
if x == "":
x = "Home-Screen"
- print(" " + Color.GREEN(f'{x:<22}') + '\t ',f'{to.convert_time(y):>12}')
-
-def daily_summary():
- date = get_date()
- window_opened, time_spent = extract_data(date)
- prints_report(window_opened, time_spent, False)
-
-def week_summary():
- dates = []
- theday = datetime.date.today()
- weekday = theday.isoweekday() - 1 # week starts on Monday and ends on Sunday
- start = theday - datetime.timedelta(days=weekday)
- dates = [start + datetime.timedelta(days=d) for d in range(weekday+1)]
- dates = [str(d) for d in dates]
-
- window_opened = list()
- time_spent = list()
- for i in dates:
- window_opened, time_spent = extract_data(i)
- 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(" "+Total_screen_time, end=' ')
-
- print("\n Mon Tue Wed Thu Fri Sat Sun" )
-
- for i in dates:
- x, y = extract_data(str(i))
- window_opened += x # smth is wrong here
- time_spent += y
- prints_report(window_opened, time_spent, True)
-
-
-#d = os.popen('''date -d "2022-03-10" +%a''').read()
-if __name__ == "__main__":
- daily_summary()
- #week_summary()
+ print(" " + Color.GREEN(f'{x:<22}') + '\t ',f'{to.format_time(y):>12}')
+