fix undefined name 'abort' and 'qreader'

This commit is contained in:
scito
2022-12-29 04:15:36 +01:00
parent 47e84e4462
commit c90526dcf2
4 changed files with 25 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ COPY . .
ARG RUN_TESTS=true
RUN apt-get update && apt-get install -y libzbar0 python3-opencv nano \
&& pip install -r requirements.txt \
&& pip install --no-cache-dir -r requirements.txt \
&& if [ "$RUN_TESTS" = "true" ]; then /extract/run_pytest.sh; else echo "Not running tests..."; fi
WORKDIR /files

View File

@@ -9,7 +9,7 @@ ARG RUN_TESTS=true
RUN apk add --no-cache nano zlib jpeg \
&& echo "Arch: $(apk --print-arch)" \
&& if [[ "$(apk --print-arch)" == "aarch64" ]]; then apk add --no-cache --virtual .build-deps gcc libc-dev python3-dev py3-setuptools zlib-dev jpeg-dev; fi \
&& pip install protobuf qrcode Pillow \
&& pip install --no-cache-dir protobuf qrcode Pillow \
&& if [[ "$(apk --print-arch)" == "aarch64" ]]; then apk del .build-deps; fi \
&& if [[ "$RUN_TESTS" == "true" ]]; then /extract/run_pytest.sh test_extract_otp_secret_keys_pytest.py -k "not qreader" --relaxed; else echo "Not running tests..."; fi

View File

@@ -266,6 +266,19 @@ pip install git+https://github.com/scito/extract_otp_secret_keys
python -m extract_otp_secret_keys
```
#### For development
```
pip install git+https://github.com/scito/extract_otp_secret_keys@support_img_read
python -m extract_otp_secret_keys
```
```
# pip install -e git+https://github.com/scito/extract_otp_secret_keys@$(git ls-remote git@github.com:scito/extract_otp_secret_keys@support_img_read.git | head -1 | awk '{print $1;}')#egg=extract_otp_secret_keys
pip3.11 install -e git+https://github.com/scito/extract_otp_secret_keys.git@$(git ls-remote git@github.com:scito/extract_otp_secret_keys.git | grep support_img_read | head -1 | awk '{print $1;}')#egg=extract_otp_secret_keys
python -m extract_otp_secret_keys
```
#### Example
```
@@ -330,10 +343,10 @@ docker run --rm -v "$(pwd)":/files:ro extract_otp_secret_keys example_export.png
```
docker run --rm -v "$(pwd)":/files:ro -i extract_otp_secret_keys = < example_export.png
docker run --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix extract_otp_secret_keys
docker run --pull always --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix scit0/extract_otp_secret_keys
docker run --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro extract_otp_secret_keys
docker run --pull always --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro scit0/extract_otp_secret_keys
docker run --entrypoint /bin/bash -it --rm -v "$(pwd)":/files:ro extract_otp_secret_keys
docker run --entrypoint /bin/bash -it --rm -v "$(pwd)":/files:ro --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix scit0/extract_otp_secret_keys
docker run --entrypoint /bin/bash -it --rm -v "$(pwd)":/files:ro --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro scit0/extract_otp_secret_keys
docker run --pull always --rm -v "$(pwd)":/files:ro -i scit0/extract_otp_secret_keys
docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro extract_otp_secret_keys

View File

@@ -57,6 +57,12 @@ from qrcode import QRCode
import protobuf_generated_python.google_auth_pb2
def abort(*args, **kwargs):
eprint(*args, **kwargs)
sys.exit(1)
try:
import cv2
import numpy
@@ -183,7 +189,7 @@ def extract_otps_from_camera(args):
cv2.polylines(img, [pts], True, rect_color_success if otp_url else rect_color, rect_thickness)
extract_otps_from_otp_url(otp_url, otp_urls, otps, args)
else:
assert False, f"ERROR: Wrong QReader mode {qreader.name}"
assert False, f"ERROR: Wrong QReader mode {qr_mode.name}"
cv2.putText(img, f"Mode: {qr_mode.name} (Hit space to change)", pos_text, font, font_scale, text_color, font_thickness, font_line)
cv2.putText(img, "Hit ESC to quit", tuple(map(add, pos_text, font_dy)), font, font_scale, text_color, font_thickness, font_line)
@@ -530,10 +536,5 @@ def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
def abort(*args, **kwargs):
eprint(*args, **kwargs)
sys.exit(1)
if __name__ == '__main__':
sys_main()