Skip to content

Commit aa79021

Browse files
committed
I04_1-268: file path did not work for .exe bundle
1 parent 385a38d commit aa79021

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

dls_barcode/geometry/unipuck_locator.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import math
44
import os
55

6+
import sys
7+
68
from dls_util.image.contours_manager import ContoursManager
79
from dls_util.image.image_morphology import ImageMorphology
810
from dls_barcode.geometry.unipuck import Unipuck
@@ -101,8 +103,12 @@ def _find_contours_of_features(self, x, y, rad):
101103

102104
def _find_feature(self, features_cnt): # do this better
103105
# compares the feature from the image with the features found on the edge of the puck
104-
dir_path = os.path.dirname(os.path.realpath(__file__))
105-
f_path = os.path.join(dir_path, '..', '..', 'resources', 'features', 'fit.png')
106+
if getattr(sys, 'frozen', False): # for the .exe bundle
107+
#see: #see https://pythonhosted.org/PyInstaller/runtime-information.html
108+
f_path = os.path.join('..', 'resources', 'features', 'fit.png')
109+
else:
110+
dir_path = os.path.dirname(os.path.abspath(__file__))
111+
f_path = os.path.join(dir_path, '..', '..', 'resources', 'features', 'fit.png')
106112
img_feature_cnt = ContoursManager(255 - self._read_feature_image(f_path))
107113
img_feature_cnt.find_all()
108114

0 commit comments

Comments
 (0)