diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2021-01-08 08:40:20 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2021-01-08 08:40:20 +0100 |
commit | a0165f6957904ba45c5d40475bcb687a02536083 (patch) | |
tree | 5a29d862de98d33c34c78e6d64f6c3eced513789 | |
parent | b173f02cdc5099ce90268f9d2633b2d2e02818a3 (diff) |
gracefully handle zbar unavailability
-rw-r--r-- | lib/loader.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/loader.py b/lib/loader.py index 2f45a99..0d8231d 100644 --- a/lib/loader.py +++ b/lib/loader.py @@ -1357,6 +1357,7 @@ class EnergyTraceWithBarcode: self.errors.append( 'zbar module is not available. Try "apt install python3-zbar"' ) + self.interval_power = None return list() ( @@ -1426,9 +1427,12 @@ class EnergyTraceWithBarcode: * `uW_mean_delta_next`: Differenz zwischen uW_mean und uW_mean des Folgezustands """ + energy_trace = list() first_sync = self.find_first_sync() - energy_trace = list() + if first_sync is None: + logger.error("did not find initial synchronization pulse") + return energy_trace expected_transitions = list() for trace_number, trace in enumerate(traces): @@ -1558,6 +1562,9 @@ class EnergyTraceWithBarcode: return energy_trace def find_first_sync(self): + # zbar unavailable + if self.interval_power is None: + return None # LED Power is approx. self.led_power W, use self.led_power/2 W above surrounding median as threshold sync_threshold_power = ( np.median(self.interval_power[: int(3 * self.sample_rate)]) |