Set path for logfiles to be near home, not whereever run from
This commit is contained in:
parent
72b3baf57b
commit
c04f849161
1 changed files with 5 additions and 3 deletions
|
@ -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') + '-' \
|
||||
|
|
Loading…
Reference in a new issue