aboutsummaryrefslogtreecommitdiff
path: root/src/Watcher/watch_log.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/Watcher/watch_log.py')
-rwxr-xr-xsrc/Watcher/watch_log.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Watcher/watch_log.py b/src/Watcher/watch_log.py
index 6a44ca5..6119e45 100755
--- a/src/Watcher/watch_log.py
+++ b/src/Watcher/watch_log.py
@@ -1,6 +1,7 @@
import os
import csv
import time
+import files
import get_windows as x
import afk as y
from time_operations import time_difference, time_addition, convert
@@ -16,7 +17,7 @@ def get_date():
return d[0:-1]
def update_csv(date, Data):
- filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv"
+ filename = files.daily_log(date)
overwrite_Data = []
with open(filename, 'w') as csvfile:
for x,y in Data.items():
@@ -43,9 +44,9 @@ def import_data(file):
# TODO: AFK feature devlopement (it will be developed after completing alpha product (after whole project up end running)
def log_creation():
- filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv"
+ filename = files.daily_log(get_date())
if not(os.path.isfile(filename)):
- creat_file = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv"
+ creat_file = filename
with open(creat_file, 'w') as fp:
pass
@@ -54,7 +55,7 @@ def log_creation():
data = import_data(filename)
while True:
date = get_date()
- filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv"
+ filename = files.daily_log(date)
afk = y.is_afk(afkTimeout)
print(data)
@@ -71,18 +72,17 @@ def log_creation():
usage = time_addition("00:00:01", usage)
data.update({active_window : usage})
- if os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv"):
+ if os.path.isfile(files.daily_log(get_date())):
update_csv(get_date(), data)
- elif not(os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv")):
- new_filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv"
+ elif not(os.path.isfile(files.daily_log(get_date()))):
+ new_filename = files.daily_log(get_date())
with open(new_filename, 'w') as fp:
pass
data.clear()
-
+
if __name__ == "__main__":
log_creation()
#afk_time = int(round(int(os.popen("xprintidle").read()[:-1])/1000, 0))
#print(afk_time)
-