aboutsummaryrefslogtreecommitdiff
path: root/src/Watcher/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/Watcher/commands.py')
-rwxr-xr-xsrc/Watcher/commands.py45
1 files changed, 32 insertions, 13 deletions
diff --git a/src/Watcher/commands.py b/src/Watcher/commands.py
index dd1d2c4..5e6826e 100755
--- a/src/Watcher/commands.py
+++ b/src/Watcher/commands.py
@@ -34,20 +34,33 @@ class Color:
def UNDERLINE(text):
return '\033[4m' + text + '\033[0m'
-
-def daily_summary():
- date = get_date()
+def daily_summary(date = get_date()):
window_opened, time_spent = anls.extract_data(date)
Total_screen_time = "00:00:00"
for x,y in anls.final_report(window_opened, time_spent).items():
Total_screen_time = to.time_addition(y, 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:
+ if date == get_date():
+ 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)))
+ elif date == os.popen("""date -d "1 day ago" '+%Y-%m-%d'""").read()[:-1]:
+ if len(to.format_time(Total_screen_time)) == 3:
+ print(Color.YELLOW("\n Yestarday's Screen-Time\t ") + Color.BLUE(f'{to.format_time(Total_screen_time):>16}'))
+ elif len(to.format_time(Total_screen_time)) == 7:
+ print(Color.YELLOW("\n Yestarday's Screen-Time\t ") + Color.BLUE(f'{to.format_time(Total_screen_time):>11}'))
+ elif len(to.format_time(Total_screen_time)) == 11:
+ print(Color.YELLOW("\n Yestarday's Screen-Time\t ") + Color.BLUE(to.format_time(Total_screen_time)))
+ else:
+ if len(to.format_time(Total_screen_time)) == 3:
+ print(Color.YELLOW("\n "+date+"'s Screen-Time\t ") + Color.BLUE(f'{to.format_time(Total_screen_time):>6}'))
+ elif len(to.format_time(Total_screen_time)) == 7:
+ print(Color.YELLOW("\n "+ date+ "'s Screen-Time\t ") + Color.BLUE(f'{to.format_time(Total_screen_time):>1}'))
+ elif len(to.format_time(Total_screen_time)) == 11:
+ print(Color.YELLOW("\n "+date+"'s Screen-Time\t ") + Color.BLUE(to.format_time(Total_screen_time)))
print(" ────────────────────────────────────────────────")
print(Color.RED(f'{" App Usages":>29}'))
@@ -58,10 +71,9 @@ def daily_summary():
x = "Home-Screen"
print(" " + Color.GREEN(f'{x:<22}') + '\t ',f'{to.format_time(y):>12}')
-def week_summary():
- W_Y = os.popen('''date +"W%V-%Y"''').read()[0:-1]
+def week_summary(week = os.popen('''date +"W%V-%Y"''').read()[:-1]):
user = os.getlogin()
- filename = "/home/"+user+"/.cache/Watcher/Analysis/"+W_Y+".csv"
+ filename = "/home/"+user+"/.cache/Watcher/Analysis/"+week+".csv"
with open(filename, 'r') as file:
csvreader = csv.reader(file, delimiter='\t')
week_overview = dict()
@@ -76,7 +88,12 @@ def week_summary():
for x, y in week_overview.items():
week_screen_time = to.time_addition(y, week_screen_time)
- print(Color.PURPLE("\n Week's screen-time\t\t ") + Color.BLUE(to.format_time(week_screen_time)))
+ if week == os.popen('''date +"W%V-%Y"''').read()[:-1]:
+ print(Color.PURPLE("\n Week's screen-time\t\t ") + Color.BLUE(to.format_time(week_screen_time)))
+ else:
+ print(Color.PURPLE("\n "+week[1:3]+ "th week of\t ") + Color.BLUE(to.format_time(week_screen_time)))
+ print(Color.PURPLE(" "+week[4:] +" screen-time\t "))
+
print(" ────────────────────────────────────────────────")
for x, y in week_overview.items():
@@ -91,5 +108,7 @@ def week_summary():
x = "Home-Screen"
print(" " + Color.GREEN(f'{x:<22}') + '\t ',f'{to.format_time(y):>12}')
+#testing
if __name__ == "__main__":
- week_summary()
+ week_summary("W27-2022")
+ #daily_summary("2022-07-18")