diff --git a/pizzactrl/fs_names.py b/pizzactrl/fs_names.py index f8176be..49fb3d9 100644 --- a/pizzactrl/fs_names.py +++ b/pizzactrl/fs_names.py @@ -12,12 +12,21 @@ Paths to files """ # Base paths _STORY_SOUNDS = '/home/pi/sounds/' -_SFX_SOUNDS = 'sounds/' _REC_FILES = '/home/pi/pizzafiles/' USB_STICK = _REC_FILES + '.stick' +def generate_session_id(): + FileHandle.uuid = str(uuid4()) + logger.info(f'generated uuid for session: {FileHandle.uuid}') + try: + os.mkdir(_REC_FILES + FileHandle.uuid) + FileHandle.uuid += '/' + except OSError: + FileHandle.uuid = '' + + class FileType(Enum): REC = 'r' STORY = 's' @@ -36,13 +45,7 @@ class FileHandle: # Create a uuid and fitting folder if not present # All RecFiles for this session will be added to this foldere if FileHandle.uuid is None: - FileHandle.uuid = str(uuid4()) - logger.info(f'generated uuid for session: {FileHandle.uuid}') - try: - os.mkdir(_REC_FILES + FileHandle.uuid) - FileHandle.uuid += '/' - except OSError: - FileHandle.uuid = '' + generate_session_id() def __str__(self): """ diff --git a/pizzactrl/statemachine.py b/pizzactrl/statemachine.py index a580d5d..82e0d9e 100644 --- a/pizzactrl/statemachine.py +++ b/pizzactrl/statemachine.py @@ -159,6 +159,7 @@ class Statemachine: Select language, then run the storyboard """ self.story.hal = self.hal + fs_names.generate_session_id() while self.story.hasnext(): self.story.play_chapter()