From 58e90a84bc3b003fc602b58e7e51258828fea8d7 Mon Sep 17 00:00:00 2001
From: David Hammer <dhammer@mailbox.org>
Date: Mon, 22 Mar 2021 19:22:19 +0100
Subject: [PATCH] Explicitly set read mode on h5py.File

---
 cal_tools/cal_tools/agipdlib.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py
index e22b228d7..285315908 100644
--- a/cal_tools/cal_tools/agipdlib.py
+++ b/cal_tools/cal_tools/agipdlib.py
@@ -75,7 +75,7 @@ def get_acq_rate(fast_paths: Tuple[str, str, int],
     fast_data_file = Path(fast_data_file)
     if fast_data_file.is_file():
         fast_data_path = f'INSTRUMENT/{karabo_id}/DET/{module}CH0:xtdf/image/pulseId'  # noqa
-        with h5py.File(fast_data_file) as fin:
+        with h5py.File(fast_data_file, "r") as fin:
             if fast_data_path in fin:
                 # pulses is of shape (NNNN, 1), of type uint8.
                 # Squeeze out the data, and subtract the 3rd entry from the 2nd
@@ -132,7 +132,7 @@ def get_gain_mode(fname: str, h5path_ctrl: str) -> AgipdGainMode:
 
     h5path_run = h5path_ctrl.replace("CONTROL/", "RUN/", 1)
     h5path_gainmode = f'{h5path_run}/gainModeIndex/value'
-    with h5py.File(fname, 'r') as fd:
+    with h5py.File(fname, "r") as fd:
         if h5path_gainmode in fd:
             return AgipdGainMode(fd[h5path_gainmode][0])
     return AgipdGainMode.ADAPTIVE_GAIN
@@ -299,7 +299,7 @@ class AgipdCorrections:
         data_dict = self.shared_dict[i_proc]
         data_dict['moduleIdx'][0] = module_idx
         try:
-            f = h5py.File(file_name, 'r')
+            f = h5py.File(file_name, "r")
             group = f[agipd_base]["image"]
 
             (_, first_index, last_index,
@@ -362,7 +362,7 @@ class AgipdCorrections:
             return
         trains = data_dict['trainId'][:n_img]
 
-        with h5py.File(ofile_name, 'w') as outfile:
+        with h5py.File(ofile_name, "w") as outfile:
             # Copy any other data from the input file.
             # This includes indexes, so it's important that the corrected data
             # we write is aligned with the raw data.
-- 
GitLab