summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-11-15 14:17:39 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2019-11-15 14:17:39 +0100
commit2dd696f8e1e596aa30246f33e00449dcc79974f3 (patch)
treee6d1b622999e115aa76851eea65da0713b557c7d
parent444a9df5fab4c2e6d9a81d36d32adc0c5c65d0bd (diff)
handle missing python3-zbar module (e.g. on Debian Stable)
-rw-r--r--lib/dfatool.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index b29b081..8a3217b 100644
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -12,7 +12,6 @@ import struct
import sys
import tarfile
import hashlib
-import zbar
from multiprocessing import Pool
from automata import PTA
from functions import analytic
@@ -20,7 +19,14 @@ from functions import AnalyticFunction
from parameters import ParamStats
from utils import vprint, is_numeric, soft_cast_int, param_slice_eq, remove_index_from_tuple
from utils import by_name_to_by_param, match_parameter_values
-from pubcode import Code128
+
+try:
+ from pubcode import Code128
+ import zbar
+ zbar_available = True
+except ImportError:
+ zbar_available = False
+
arg_support_enabled = True
@@ -2033,6 +2039,12 @@ class EnergyTraceLog:
self.errors = list()
def load_data(self, log_data):
+
+ if not zbar_available:
+ self.errors.append('zbar module is not available. Try "apt install python3-zbar"')
+ self.is_error = True
+ return list()
+
lines = log_data.decode('ascii').split('\n')
data_count = sum(map(lambda x: len(x) > 0 and x[0] != '#', lines))
data_lines = filter(lambda x: len(x) > 0 and x[0] != '#', lines)