From 4612ab6e7fd6e14a1e55321540a32e3cd7bba3ab Mon Sep 17 00:00:00 2001 From: scito Date: Sat, 24 Dec 2022 03:25:10 +0100 Subject: [PATCH] catch zbar import error --- .github/workflows/ci.yml | 4 ++-- .github/workflows/nightly.yml | 4 ++-- extract_otp_secret_keys.py | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19b0272..92dfed5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,11 +25,11 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Install zbar lib for QReader (Linux) + - name: Install zbar shared lib for QReader (Linux) if: runner.os == 'Linux' run: | # FIXME sudo apt-get install -y libzbar0 - - name: Install zbar lib for QReader (macOS) + - name: Install zbar shared lib for QReader (macOS) if: runner.os == 'macOS' run: | brew install zbar diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9b472b0..d80bbcb 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -23,11 +23,11 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Install zbar lib for QReader (Linux) + - name: Install zbar shared lib for QReader (Linux) if: runner.os == 'Linux' run: | sudo apt-get install -y libzbar0 - - name: Install zbar lib for QReader (macOS) + - name: Install zbar shared lib for QReader (macOS) if: runner.os == 'macOS' run: | brew install zbar diff --git a/extract_otp_secret_keys.py b/extract_otp_secret_keys.py index 599e461..51d3e6d 100644 --- a/extract_otp_secret_keys.py +++ b/extract_otp_secret_keys.py @@ -187,7 +187,10 @@ def convert_img_to_line(filename): abort('\nERROR: Unable to open file for reading.\ninput file: {}'.format(filename)) # dynamic import of QReader since this module has a dependency to zbar lib - from qreader import QReader + try: + from qreader import QReader + except ImportError as e: + abort('\nERROR: Cannot import QReader module probably due to missing zbar shared library. Exception:\n{}'.format(str(e))) decoder = QReader() decoded_text = decoder.detect_and_decode(image=image)