Generate a new UUID for each time the statemachine plays.

This commit is contained in:
jpunkt 2022-01-20 16:53:04 +01:00
parent d139cb1b1f
commit ae2f3fec34
2 changed files with 12 additions and 8 deletions

View file

@ -12,12 +12,21 @@ Paths to files
""" """
# Base paths # Base paths
_STORY_SOUNDS = '/home/pi/sounds/' _STORY_SOUNDS = '/home/pi/sounds/'
_SFX_SOUNDS = 'sounds/'
_REC_FILES = '/home/pi/pizzafiles/' _REC_FILES = '/home/pi/pizzafiles/'
USB_STICK = _REC_FILES + '.stick' 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): class FileType(Enum):
REC = 'r' REC = 'r'
STORY = 's' STORY = 's'
@ -36,13 +45,7 @@ class FileHandle:
# Create a uuid and fitting folder if not present # Create a uuid and fitting folder if not present
# All RecFiles for this session will be added to this foldere # All RecFiles for this session will be added to this foldere
if FileHandle.uuid is None: if FileHandle.uuid is None:
FileHandle.uuid = str(uuid4()) generate_session_id()
logger.info(f'generated uuid for session: {FileHandle.uuid}')
try:
os.mkdir(_REC_FILES + FileHandle.uuid)
FileHandle.uuid += '/'
except OSError:
FileHandle.uuid = ''
def __str__(self): def __str__(self):
""" """

View file

@ -159,6 +159,7 @@ class Statemachine:
Select language, then run the storyboard Select language, then run the storyboard
""" """
self.story.hal = self.hal self.story.hal = self.hal
fs_names.generate_session_id()
while self.story.hasnext(): while self.story.hasnext():
self.story.play_chapter() self.story.play_chapter()