mirror of
https://github.com/scito/extract_otp_secret_keys.git
synced 2025-12-06 14:54:57 +01:00
abort instead of assertion
This commit is contained in:
parent
8545dab7a5
commit
e177f860e1
2 changed files with 5 additions and 7 deletions
|
|
@ -57,7 +57,7 @@ cd extract_otp_secret_keys
|
|||
|
||||
## Program help: arguments and options
|
||||
|
||||
<pre>usage: extract_otp_secrets.py [-h] [--camera NUMBER] [--qr {QREADER,DEEP_QREADER,ZBAR,CV2,WECHAT}] [--json FILE] [--csv FILE] [--keepass FILE] [--printqr] [--saveqr DIR] [--verbose | --quiet] [infile ...]
|
||||
<pre>usage: extract_otp_secrets.py [-h] [--camera NUMBER] [--qr {QREADER,DEEP_QREADER,ZBAR,CV2,CV2_WECHAT}] [--json FILE] [--csv FILE] [--keepass FILE] [--printqr] [--saveqr DIR] [--no-color] [--verbose | --quiet] [infile ...]
|
||||
|
||||
Extracts one time password (OTP) secret keys from QR codes, e.g. from Google Authenticator app.
|
||||
If no infiles are provided, the QR codes are interactively captured from the camera.
|
||||
|
|
@ -69,13 +69,14 @@ positional arguments:
|
|||
options:
|
||||
-h, --help show this help message and exit
|
||||
--camera NUMBER, -C NUMBER camera number of system (default camera: 0)
|
||||
--qr {QREADER,DEEP_QREADER,ZBAR,CV2,WECHAT}, -Q {QREADER,DEEP_QREADER,ZBAR,CV2,WECHAT}
|
||||
--qr {QREADER,DEEP_QREADER,ZBAR,CV2,CV2_WECHAT}, -Q {QREADER,DEEP_QREADER,ZBAR,CV2,CV2_WECHAT}
|
||||
QR reader (default: ZBAR)
|
||||
--json FILE, -j FILE export json file or - for stdout
|
||||
--csv FILE, -c FILE export csv file or - for stdout
|
||||
--keepass FILE, -k FILE export totp/hotp csv file(s) for KeePass, - for stdout
|
||||
--printqr, -p print QR code(s) as text to the terminal (requires qrcode module)
|
||||
--saveqr DIR, -s DIR save QR code(s) as images to the given folder (requires qrcode module)
|
||||
--no-color, -n do not use ANSI colors in console output
|
||||
--verbose, -v verbose output
|
||||
--quiet, -q no stdout output, except output set by -
|
||||
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ def extract_otps_from_camera(args: Args) -> Otps:
|
|||
success, img = cam.read()
|
||||
new_otps_count = 0
|
||||
if not success:
|
||||
log_error("Failed to capture image")
|
||||
log_error("Failed to capture image from camera")
|
||||
break
|
||||
try:
|
||||
if qr_mode in [QRMode.QREADER, QRMode.DEEP_QREADER]:
|
||||
|
|
@ -281,10 +281,7 @@ def extract_otps_from_camera(args: Args) -> Otps:
|
|||
new_otps_count = extract_otps_from_otp_url(otp_url, otp_urls, otps, args)
|
||||
cv2_draw_box(img, raw_pts, get_color(new_otps_count, otp_url))
|
||||
else:
|
||||
assert False, f"Wrong QReader mode {qr_mode.name}"
|
||||
except AssertionError as e:
|
||||
# Exceptions not to log, but to pass further
|
||||
raise e
|
||||
abort(f"Invalid QReader mode: {qr_mode.name}")
|
||||
except Exception as e:
|
||||
log_error(f'An error occured during QR detection and decoding for QR reader {qr_mode}. Changed to the next QR reader.', e)
|
||||
qr_mode = next_qr_mode(qr_mode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue