From c04f849161e427d2a5a52faa3712c7a4e097c267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Melan=C3=A7on?= Date: Sun, 23 May 2021 00:35:39 -0400 Subject: [PATCH] Set path for logfiles to be near home, not whereever run from --- pomodoroprompt.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pomodoroprompt.py b/pomodoroprompt.py index 5d7c8b4..5b11c52 100644 --- a/pomodoroprompt.py +++ b/pomodoroprompt.py @@ -91,14 +91,16 @@ def countdown_to(until): time.sleep(1) def prepare_file(utc_start, ext='csv', daily=False): + # Save timelogs relative to script directory (NOT from where called) + logpath = os.path.dirname(os.path.realpath(__file__)) + '/log' # Ensure log directory exists. - if not os.path.exists('log'): - os.makedirs('log') + if not os.path.exists(logpath): + os.makedirs(logpath) # We consider 3am the switchover to a new day, so we skip extra math # and use Pacific time to get three hours later than our Eastern time. logpath_tz = timezone('US/Pacific') logpath_date = utc_start.astimezone(logpath_tz) - timelog_path = 'log/' + str(logpath_date.year); + timelog_path = logpath + '/' + str(logpath_date.year); if (daily): timelog_path += '-' \ + format(logpath_date.month, '02') + '-' \