From 52dbaeeb4fe461a523927135208882f28662c4ad Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Tue, 23 Jun 2020 15:57:21 +0200 Subject: [PATCH] handle the case where the recording has been cancelled by the user and therefore the actual number of frames is lower than initially planned --- src/lipase/catalog.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lipase/catalog.py b/src/lipase/catalog.py index d0c26e2..5a58304 100644 --- a/src/lipase/catalog.py +++ b/src/lipase/catalog.py @@ -62,7 +62,16 @@ class Sequence(object): """Gets the number of frames in the sequence """ summary = self.mmm['Summary'] - return int(summary['Frames']) + num_frames = int(summary['Frames']) + # handle the case where the recording has been cancelled by the user and therefore the actual number of frames is lower than initially planned + num_existing_frames = 0 + for frame_index in range(num_frames): + frame_key_key = 'FrameKey-%d-0-0' % (frame_index) + if not frame_key_key in self.mmm.keys(): + num_existing_frames = frame_index + break + + return num_existing_frames @property def width(self):