zbar for windows
This commit is contained in:
parent
81bd8d8d67
commit
f4363e7967
|
@ -28,6 +28,7 @@ datas = [
|
||||||
(home+'lib/wordlist/english.txt', 'electrum/wordlist'),
|
(home+'lib/wordlist/english.txt', 'electrum/wordlist'),
|
||||||
(home+'lib/locale', 'electrum/locale'),
|
(home+'lib/locale', 'electrum/locale'),
|
||||||
(home+'plugins', 'electrum_plugins'),
|
(home+'plugins', 'electrum_plugins'),
|
||||||
|
('C:\\Program Files (x86)\\ZBar\\bin\\', '.')
|
||||||
]
|
]
|
||||||
datas += collect_data_files('trezorlib')
|
datas += collect_data_files('trezorlib')
|
||||||
datas += collect_data_files('btchip')
|
datas += collect_data_files('btchip')
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
# Please update these carefully, some versions won't work under Wine
|
# Please update these carefully, some versions won't work under Wine
|
||||||
NSIS_URL=https://prdownloads.sourceforge.net/nsis/nsis-3.02.1-setup.exe?download
|
NSIS_URL=https://prdownloads.sourceforge.net/nsis/nsis-3.02.1-setup.exe?download
|
||||||
NSIS_SHA256=736c9062a02e297e335f82252e648a883171c98e0d5120439f538c81d429552e
|
NSIS_SHA256=736c9062a02e297e335f82252e648a883171c98e0d5120439f538c81d429552e
|
||||||
|
ZBAR_URL=https://sourceforge.net/projects/zbarw/files/zbarw-20121031-setup.exe/download
|
||||||
|
ZBAR_SHA256=177e32b272fa76528a3af486b74e9cb356707be1c5ace4ed3fcee9723e2c2c02
|
||||||
PYTHON_VERSION=3.5.4
|
PYTHON_VERSION=3.5.4
|
||||||
|
|
||||||
## These settings probably don't need change
|
## These settings probably don't need change
|
||||||
|
@ -83,8 +85,10 @@ $PYTHON -m pip install PyQt5
|
||||||
|
|
||||||
|
|
||||||
# Install ZBar
|
# Install ZBar
|
||||||
#wget -q -O zbar.exe "https://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download"
|
wget -q -O zbar.exe "$ZBAR_URL"
|
||||||
#wine zbar.exe
|
verify_hash zbar.exe $ZBAR_SHA256
|
||||||
|
echo "Install zbar. Next-next-next; and skip the readme."
|
||||||
|
wine zbar.exe
|
||||||
|
|
||||||
# install Cryptodome
|
# install Cryptodome
|
||||||
$PYTHON -m pip install pycryptodomex
|
$PYTHON -m pip install pycryptodomex
|
||||||
|
|
|
@ -29,8 +29,8 @@ import ctypes
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
name = 'libzbar.dylib'
|
name = 'libzbar.dylib'
|
||||||
elif sys.platform == 'windows':
|
elif sys.platform in ('windows', 'win32'):
|
||||||
name = 'libzbar.dll'
|
name = 'libzbar-0.dll'
|
||||||
else:
|
else:
|
||||||
name = 'libzbar.so.0'
|
name = 'libzbar.so.0'
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ except OSError:
|
||||||
libzbar = None
|
libzbar = None
|
||||||
|
|
||||||
|
|
||||||
def scan_barcode(device='', timeout=-1, display=True, threaded=False):
|
def scan_barcode(device='', timeout=-1, display=True, threaded=False, try_again=True):
|
||||||
if libzbar is None:
|
if libzbar is None:
|
||||||
raise RuntimeError("Cannot start QR scanner; zbar not available.")
|
raise RuntimeError("Cannot start QR scanner; zbar not available.")
|
||||||
libzbar.zbar_symbol_get_data.restype = ctypes.c_char_p
|
libzbar.zbar_symbol_get_data.restype = ctypes.c_char_p
|
||||||
|
@ -50,6 +50,10 @@ def scan_barcode(device='', timeout=-1, display=True, threaded=False):
|
||||||
proc = libzbar.zbar_processor_create(threaded)
|
proc = libzbar.zbar_processor_create(threaded)
|
||||||
libzbar.zbar_processor_request_size(proc, 640, 480)
|
libzbar.zbar_processor_request_size(proc, 640, 480)
|
||||||
if libzbar.zbar_processor_init(proc, device.encode('utf-8'), display) != 0:
|
if libzbar.zbar_processor_init(proc, device.encode('utf-8'), display) != 0:
|
||||||
|
if try_again:
|
||||||
|
# workaround for a bug in "ZBar for Windows"
|
||||||
|
# libzbar.zbar_processor_init always seem to fail the first time around
|
||||||
|
return scan_barcode(device, timeout, display, threaded, try_again=False)
|
||||||
raise RuntimeError("Can not start QR scanner; initialization failed.")
|
raise RuntimeError("Can not start QR scanner; initialization failed.")
|
||||||
libzbar.zbar_processor_set_visible(proc)
|
libzbar.zbar_processor_set_visible(proc)
|
||||||
if libzbar.zbar_process_one(proc, timeout):
|
if libzbar.zbar_process_one(proc, timeout):
|
||||||
|
|
Loading…
Reference in New Issue