diff options
author | 2022-03-15 16:02:23 +0530 | |
---|---|---|
committer | 2022-03-15 16:02:23 +0530 | |
commit | 7754fe414354ba8cea2cb86e3a269b01f509e9d4 (patch) | |
tree | 6d3e7491b4128567c4eb0443569d4138ff74f6bd /src/Watcher/watch_log.py | |
parent | ca6527e70cc125383c2b2b85f741b1f4fb92ab1b (diff) | |
download | shopno-os-log-sync-7754fe414354ba8cea2cb86e3a269b01f509e9d4.tar.gz shopno-os-log-sync-7754fe414354ba8cea2cb86e3a269b01f509e9d4.zip |
fixing issue in watch_log | occurs is file doesn't exist
Diffstat (limited to 'src/Watcher/watch_log.py')
-rwxr-xr-x | src/Watcher/watch_log.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Watcher/watch_log.py b/src/Watcher/watch_log.py index ad4a4fd..5fca72f 100755 --- a/src/Watcher/watch_log.py +++ b/src/Watcher/watch_log.py @@ -35,6 +35,13 @@ def append_line_in_csv(date, closed_time, window_name): afk = False def log_creation(): global afk + + filename = "/home/"+os.getlogin()+"/.cache/Watcher/raw_data/"+get_date()+".csv" + if not(os.path.isfile(filename)): + with open(filename, 'a') as csvfile: + csvwriter = csv.writer(csvfile, delimiter='\t') + csvwriter.writerow([get_time(), "00:00:00", "User-logged-in"]) + append_line_in_csv(get_date(), get_time(), "User-logged-in") while True: previous_window = x.active_window() @@ -48,13 +55,5 @@ def log_creation(): afk_closed_time = get_time() append_line_in_csv(date, afk_closed_time, "AFK") - if __name__ == "__main__": - os.popen('''python /usr/share/Watcher/week_analysis.py''') - filename = "/home/"+os.getlogin()+"/.cache/Watcher/raw_data/"+get_date()+".csv" - if not(os.path.isfile(filename)): - with open(filename, 'a') as csvfile: - csvwriter = csv.writer(csvfile, delimiter='\t') - csvwriter.writerow([get_time(), "00:00:00", ""]) - log_creation() |