Skip to content

Commit f058065

Browse files
committed
moved action csv files to own subfolder, use Path to create missing dirs
1 parent 6d7b360 commit f058065

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

consumer.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ def create_museum_actions_logging_csv_file() ->str:
397397

398398
if MUSEUM_LOGGING_FILE is None:
399399
return
400-
if not os.path.exists(LOG_DIR):
401-
os.mkdir(LOG_DIR)
402-
museum_csv_actions_logging_file_name=os.path.join(LOG_DIR,MUSEUM_LOGGING_FILE+'-'+platform.node()+'-'+datetime.now().strftime("-%Y-%m-%d-%H%M")+'.csv')
400+
museum_actions_dir=os.path.join(LOG_DIR, MUSEUM_ACTIONS_DIR)
401+
Path(museum_actions_dir).mkdir(parents=True, exist_ok=True)
402+
museum_csv_actions_logging_file_name=os.path.join(museum_actions_dir, MUSEUM_LOGGING_FILE+'-'+platform.node()+'-'+datetime.now().strftime("-%Y-%m-%d-%H%M")+'.csv')
403403
with open(museum_csv_actions_logging_file_name,'w',newline='') as museum_csv_logging_file:
404404
museum_csv_writer=csv.writer(museum_csv_logging_file,dialect='excel')
405405
museum_csv_writer.writerow(['year','day_of_year','weekday','hour','minute', 'elapsed_minutes', 'actions'])
@@ -461,13 +461,11 @@ def write_actions_to_csv():
461461
save_frames_folder=os.path.join(LOG_DIR,SAVE_FRAMES_STORAGE_LOCATION)
462462
if not os.path.exists(save_frames_folder):
463463
log.info(f"creating folders to hold sample frames that will be stored every {SAVE_FRAMES_INTERVAL} new classifications")
464-
os.mkdir(save_frames_folder)
464+
Path(save_frames_folder).mkdir(parents=True, exist_ok=True)
465465
log.info(f'made folder {save_frames_folder} to save sample frames')
466466
for symbol in SYMBOL_TO_PRED_DICT.keys():
467467
symbol_folder_name=os.path.join(save_frames_folder,symbol)
468-
if not os.path.exists(symbol_folder_name):
469-
os.mkdir(symbol_folder_name)
470-
log.info(f'made folder {symbol_folder_name} to hold sample classified frames')
468+
Path(symbol_folder_name).mkdir(parents=True, exist_ok=True)
471469

472470
log.info(f"scheduling 'I am alive' logging every MUSEUM_I_AM_ALIVE_LOG_INTERVAL_MINUTES={MUSEUM_I_AM_ALIVE_LOG_INTERVAL_MINUTES}m")
473471
schedule.every(MUSEUM_I_AM_ALIVE_LOG_INTERVAL_MINUTES).minutes.do(log_i_am_alive_message)

globals_and_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
MUSEUM_WAKE_TIME_LOCAL="08:45" # time that computer wakes in local time (time of computer RTC clock, checked in bios or by timedatectl)
6464
MUSEUM_SCREEN_DIM_NO_ACTIONS_TIMEOUT_S=10 # time to dim screen if no actions for this many seconds
6565
MUSEUM_DIMMED_SCREEN_BRIGHTNESS=0.01 # how much to dim to, 0-1 range
66+
MUSEUM_ACTIONS_DIR="actions" # where the actions csv files are put
6667

6768
# saving frames
6869
SAVE_FRAMES_INTERVAL=10

0 commit comments

Comments
 (0)