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') + '-' \