Skip to content

Commit

Permalink
[#95] Fix inlite barcode reader when frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklizard99 committed Dec 9, 2016
1 parent 09c5877 commit e6b0735
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 6 additions & 1 deletion inselect/gui/plugins/barcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ def _decode_barcodes(self, engine, crop, progress):
result = strategy(crop, engine)
if result:
strategy, barcodes = result
return ' '.join(sorted([b.data.decode() for b in barcodes]))
# data could be either str or bytes
barcodes = (
b.data.decode() if hasattr(b.data, 'decode') else b.data
for b in barcodes
)
return ' '.join(sorted([value for value in barcodes]))
return None

@classmethod
Expand Down
8 changes: 8 additions & 0 deletions inselect/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ def fix_frozen_dll_path():
from ctypes import windll
windll.kernel32.SetDllDirectoryW(str(Path(sys.executable).parent))

# gencache does not realise that it is frozen and will not have write
# access to the dicts.dat file. These hacks are to prevent gencache
# from atempting to write to dicts.dat.
# Evil, evil, evil
import win32com.client.gencache
win32com.client.gencache.is_readonly = True
win32com.client.gencache.AddModuleToCache.__defaults__ = (1, False)


def get_default_locale():
"""Returns cached result of locale.getdefaultlocale()
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@
],
# Strings in braces within 'include_files' tuples expanded in cx_setup
'include_files': [
# Evil, evil, evil
# cx_Freeze breaks pywintypes and pythoncom on Python 3.5
# https://bitbucket.org/anthony_tuininga/cx_freeze/issues/194/error-with-frozen-executable-using-35-and
('{environment_root}/Lib/site-packages/win32/lib/pywintypes.py', 'pywintypes.py'),
('{environment_root}/Lib/site-packages/pythoncom.py', 'pythoncom.py'),
('{environment_root}/Library/bin/mkl_core.dll', 'mkl_core.dll'),
('{environment_root}/Library/bin/mkl_intel_thread.dll', 'mkl_intel_thread.dll'),
('{environment_root}/Library/bin/libiomp5md.dll', 'libiomp5md.dll'),
('{project_root}/inselect/gui/inselect.qss', 'inselect.qss'),
],
'extra_packages': ['win32com.gen_py'],
'extra_packages': ['win32com.gen_py', 'win32timezone'],
'excludes': [
'Tkinter', 'ttk', 'Tkconstants', 'tcl', '_ssl',
]
Expand Down

0 comments on commit e6b0735

Please sign in to comment.