aboutsummaryrefslogtreecommitdiff
path: root/src/Watcher
diff options
context:
space:
mode:
authorLibravatar Waishnav <waishnavdeore@gmail.com>2022-07-19 22:25:50 +0530
committerLibravatar Waishnav <waishnavdeore@gmail.com>2022-07-19 22:25:50 +0530
commit9a9c5b176997c1aec0c1c05a9fbe3d3cc26eff99 (patch)
treecfcd11cdc158d9f3fc34fa1688d124928e23c6aa /src/Watcher
parente30c4bdfcae8b0e826c7a8a100526fe95845a933 (diff)
downloadshopno-os-log-sync-9a9c5b176997c1aec0c1c05a9fbe3d3cc26eff99.tar.gz
shopno-os-log-sync-9a9c5b176997c1aec0c1c05a9fbe3d3cc26eff99.zip
added two commands -ds -y and -ws -pw
Diffstat (limited to 'src/Watcher')
-rwxr-xr-xsrc/Watcher/analysis.py14
-rwxr-xr-xsrc/Watcher/commands.py3
2 files changed, 10 insertions, 7 deletions
diff --git a/src/Watcher/analysis.py b/src/Watcher/analysis.py
index d37010c..6e26d29 100755
--- a/src/Watcher/analysis.py
+++ b/src/Watcher/analysis.py
@@ -66,7 +66,7 @@ def get_sunday_of_week(week):
return first + datetime.timedelta(days=base - first.isocalendar()[2] + 7 * (week - 1)) + datetime.timedelta(days=6.9)
# getting dates of particular week for week summary
-def get_dates(theday=datetime.date.today()):
+def week_dates(theday=datetime.date.today()):
weekday = theday.isoweekday() - 1
# The start of the week (Monday)
start = theday - datetime.timedelta(days=weekday)
@@ -79,17 +79,17 @@ def weekday_from_date(date):
day = os.popen('''date -d "'''+ date + '''" +%a''').read()
return day[0:-1]
-def weekly_logs(week = str(os.popen('''date +"w%v-%y"''').read()[0:-1])):
+def weekly_logs(week = str(os.popen('''date +"W%V-%Y"''').read()[0:-1])):
user = os.getlogin()
filename = "/home/"+user+"/.cache/Watcher/Analysis/"+week+".csv"
with open(filename, "w") as csvfile:
csvwriter = csv.writer(csvfile, delimiter='\t')
#csvwriter.writerow(["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"])
- if os.popen('''date +"w%v-%y"''').read()[0:-1] == week:
- dates = get_date()
+ if os.popen('''date +"W%V-%Y"''').read()[0:-1] == week:
+ dates = week_dates()
else:
- dates = get_dates(get_sunday_of_week(week))
+ dates = week_dates(get_sunday_of_week(week))
window_opened = list()
time_spent = list()
@@ -110,5 +110,5 @@ def weekly_logs(week = str(os.popen('''date +"w%v-%y"''').read()[0:-1])):
#testing
if __name__ == "__main__":
- print(get_dates(get_sunday_of_week("W27-2022")))
- weekly_logs("W27-2022")
+ weekly_logs("W29-2022")
+
diff --git a/src/Watcher/commands.py b/src/Watcher/commands.py
index 5e6826e..7d1fe97 100755
--- a/src/Watcher/commands.py
+++ b/src/Watcher/commands.py
@@ -90,6 +90,9 @@ def week_summary(week = os.popen('''date +"W%V-%Y"''').read()[:-1]):
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)))
+ elif week == os.popen("""date -d 'last week' '+W%W-%Y'""").read()[:-1]:
+ print(Color.PURPLE("\n Previous Week's \t\t ") + Color.BLUE(to.format_time(week_screen_time)))
+ print(Color.PURPLE(" 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 "))