Skip to content

Commit 0baf4d6

Browse files
committed
I04_1-150: extracted no barcodes detected error
1 parent 9e06d76 commit 0baf4d6

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class NoBarcodesDetectedError(Exception):
2+
def __init__(self):
3+
super(NoBarcodesDetectedError, self).__init__("No barcode detected")

dls_barcode/scan/open/open_scanner.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
from dls_barcode.plate import Plate
44
from dls_barcode.geometry import Geometry
5+
from ..no_barcodes_detected_error import NoBarcodesDetectedError
56
from .open_scan_result import OpenScanResult
67

78

8-
class NoBarcodesError(Exception):
9-
pass
10-
11-
129
class OpenScanner:
1310
def __init__(self, barcode_sizes):
1411
self.plate_type = Geometry.NO_GEOMETRY
@@ -32,7 +29,7 @@ def scan_next_frame(self, frame_img, is_single_image=False):
3229
try:
3330
barcodes = self._perform_frame_scan()
3431
result.set_barcodes(barcodes)
35-
except NoBarcodesError as ex:
32+
except NoBarcodesDetectedError as ex:
3633
result.set_error(str(ex))
3734

3835
# Create a 'blank' geometry object to store the barcode locations
@@ -76,7 +73,7 @@ def _locate_all_barcodes_in_image(self):
7673
barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_sizes)
7774

7875
if len(barcodes) == 0:
79-
raise NoBarcodesError("No barcode detected")
76+
raise NoBarcodesDetectedError()
8077
return barcodes
8178

8279
def _is_barcode_new(self, barcode):

dls_barcode/scan/with_geometry/geometry_scanner.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
from .plate_scanner import PlateScanner
99
from .slot_scanner import SlotScanner
1010
from ..scan_result import ScanResult
11-
12-
13-
class NoBarcodesError(Exception):
14-
pass
15-
11+
from ..no_barcodes_detected_error import NoBarcodesDetectedError
1612

1713
class GeometryScanner:
1814
def __init__(self, plate_type, barcode_sizes):
@@ -38,7 +34,7 @@ def scan_next_frame(self, frame_img, is_single_image=False):
3834
try:
3935
self._perform_frame_scan()
4036
self._frame_result.set_plate(self._plate)
41-
except (NoBarcodesError, GeometryException, GeometryAdjustmentError) as ex:
37+
except (NoBarcodesDetectedError, GeometryException, GeometryAdjustmentError) as ex:
4238
self._frame_result.set_error(str(ex))
4339

4440
self._frame_result.end_timer()
@@ -87,7 +83,7 @@ def _locate_all_barcodes_in_image(self):
8783
barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_sizes)
8884

8985
if len(barcodes) == 0:
90-
raise NoBarcodesError("No Barcodes Detected In Image")
86+
raise NoBarcodesDetectedError()
9187

9288
return barcodes
9389

0 commit comments

Comments
 (0)