Skip to content

Commit 64a3ac4

Browse files
authored
Merge pull request #1667 from papr/v1.16_fixes
V1.16 fixes
2 parents 6479a67 + 50cf7ad commit 64a3ac4

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

pupil_src/shared_modules/gaze_producer/model/calibration_storage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def duplicate_calibration(self, calibration):
5959
def add(self, calibration):
6060
if any(c.unique_id == calibration.unique_id for c in self._calibrations):
6161
logger.warning(
62-
"Did not add calibration {} because it is already in the "
63-
"storage".format(calibration.name)
62+
f"Did not add calibration {calibration.name} ({calibration.unique_id})"
63+
" because it is already in the storage. Currently in storage:\n"
64+
+ "\n".join(f"- {c.name} ({c.unique_id})" for c in self._calibrations)
6465
)
6566
return
6667
self._calibrations.append(calibration)

pupil_src/shared_modules/gaze_producer/ui/storage_edit_menu.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
---------------------------------------------------------------------------~(*)
1010
"""
1111
import abc
12+
import logging
1213

1314
from pyglui import ui
1415

1516
from gaze_producer import ui as plugin_ui
1617

18+
logger = logging.getLogger(__name__)
19+
1720

1821
class StorageEditMenu(plugin_ui.SelectAndRefreshMenu, abc.ABC):
1922
"""
2023
A SelectAndRefreshMenu that shows the items in a storage. It has a button above the
2124
selector to create a new item and shows for every item two buttons,
2225
one to duplicate the current item, and one to delete it.
2326
"""
27+
2428
new_button_label = "New"
2529
duplicate_button_label = "Duplicate Current Configuration"
2630

@@ -76,12 +80,18 @@ def render_item(self, item, menu):
7680
def _on_click_new_button(self):
7781
new_item = self._new_item()
7882
self._storage.add(new_item)
83+
if new_item not in self._storage:
84+
logger.error("New item could not be added. Aborting.")
85+
return
7986
self.current_item = new_item
8087
self.render()
8188

8289
def _on_click_duplicate_button(self):
8390
new_item = self._duplicate_item(self.current_item)
8491
self._storage.add(new_item)
92+
if new_item not in self._storage:
93+
logger.error("New item could not be added. Aborting.")
94+
return
8595
self.current_item = new_item
8696
self.render()
8797

pupil_src/shared_modules/pupil_recording/recording.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ def filter_multiple(self, *keys: str, mode: FilterMode) -> FilterType:
153153
for patterns in patterns_for_keys
154154
]
155155
if mode is self.FilterMode.UNION:
156-
self.__files = set.union(*sets_of_files)
156+
self.__files = list(set.union(*sets_of_files))
157157
elif mode is self.FilterMode.INTERSECTION:
158-
self.__files = set.intersection(*sets_of_files)
158+
self.__files = list(set.intersection(*sets_of_files))
159159
else:
160160
logger.warning(
161161
f"Unknown filter mode: {mode}! Must be 'union' or 'intersection'!"

pupil_src/shared_modules/storage.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@
1313
import os
1414
import random
1515
import re
16+
import uuid
1617

1718
import file_methods as fm
1819

1920
logger = logging.getLogger(__name__)
2021

22+
# Create our own uuid namespace; to be used with uuid.uuid5()
23+
# Will be used to create reproducible uuids in create_unique_id_from_string()
24+
UUID_NAMESPACE_PUPIL_LABS = uuid.uuid5(uuid.NAMESPACE_DNS, "pupil-labs.com")
25+
# Should always result in the same UUID:
26+
assert UUID_NAMESPACE_PUPIL_LABS == uuid.UUID("8ea5d78e-e022-5ee4-a198-1bc002516ff0")
27+
2128

2229
class StorageItem(abc.ABC):
2330
@property
@@ -40,18 +47,15 @@ def create_new_unique_id():
4047
"""
4148
Returns: A string like e.g. "04bfd332"
4249
"""
43-
return "{:0>8x}".format(random.getrandbits(32))
50+
return str(uuid.uuid4())
4451

4552
@staticmethod
4653
def create_unique_id_from_string(string):
4754
"""
4855
Returns: A unique id as generated by create_new_unique_id(), but for
4956
the same input string, it will always return the same id.
5057
"""
51-
old_state_of_random = random.getstate()
52-
random.seed(string)
53-
unique_id = StorageItem.create_new_unique_id()
54-
random.setstate(old_state_of_random)
58+
unique_id = str(uuid.uuid5(UUID_NAMESPACE_PUPIL_LABS, string))
5559
return unique_id
5660

5761

pupil_src/shared_modules/video_export/plugins/imotions_exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _copy_info_csv(source_folder, destination_folder):
151151

152152
data = {}
153153
data["Recording Name"] = meta.recording_name
154-
data["Start Data"] = start_date
154+
data["Start Date"] = start_date
155155
data["Start Time"] = start_time
156156
data["Start Time (System)"] = meta.start_time_system_s
157157
data["Start Time (Synced)"] = meta.start_time_synced_s

0 commit comments

Comments
 (0)