From e06dd754f5ab51ec9311c68dca403aaf75d4e889 Mon Sep 17 00:00:00 2001 From: DDSRem <73049927+DDSRem@users.noreply.github.com> Date: Sat, 28 Dec 2024 11:40:56 +0800 Subject: [PATCH] feat: added qrcode expiration reminder --- glue_python/aliyuntoken/aliyuntoken.py | 8 +++++++- glue_python/aliyuntoken/aliyuntoken_nn.ci.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/glue_python/aliyuntoken/aliyuntoken.py b/glue_python/aliyuntoken/aliyuntoken.py index a80357f389..2815688e37 100644 --- a/glue_python/aliyuntoken/aliyuntoken.py +++ b/glue_python/aliyuntoken/aliyuntoken.py @@ -64,6 +64,10 @@ def poll_qrcode_status(_data, log_print): logging.info('扫码成功, refresh_token 已写入文件!') LAST_STATUS = 1 break + elif _re_data['content']['data']['qrCodeStatus'] == 'EXPIRED': + logging.error('二维码无效或已过期!') + LAST_STATUS = 2 + break else: if log_print: logging.info('等待用户扫码...') @@ -146,10 +150,12 @@ def shutdown(): threading.Thread(target=poll_qrcode_status, args=(data, False)).start() logging.info('请打开阿里云盘扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) - while LAST_STATUS != 1: + while LAST_STATUS != 1 and LAST_STATUS != 2: time.sleep(1) if os.path.isfile(QRCODE_DIR): os.remove(QRCODE_DIR) + if LAST_STATUS == 2: + os._exit(1) os._exit(0) else: logging.error('未知的扫码模式') diff --git a/glue_python/aliyuntoken/aliyuntoken_nn.ci.py b/glue_python/aliyuntoken/aliyuntoken_nn.ci.py index 997cec8381..98401250cb 100644 --- a/glue_python/aliyuntoken/aliyuntoken_nn.ci.py +++ b/glue_python/aliyuntoken/aliyuntoken_nn.ci.py @@ -47,6 +47,10 @@ def poll_qrcode_status(_data, log_print): logging.info('扫码成功, refresh_token 已写入文件!') LAST_STATUS = 1 break + elif _re_data['content']['data']['qrCodeStatus'] == 'EXPIRED': + logging.error('二维码无效或已过期!') + LAST_STATUS = 2 + break else: if log_print: logging.info('等待用户扫码...') @@ -129,10 +133,12 @@ def shutdown(): threading.Thread(target=poll_qrcode_status, args=(data, False)).start() logging.info('请打开阿里云盘扫描此二维码!') qr.print_ascii(invert=True, tty=sys.stdout.isatty()) - while LAST_STATUS != 1: + while LAST_STATUS != 1 and LAST_STATUS != 2: time.sleep(1) if os.path.isfile(QRCODE_DIR): os.remove(QRCODE_DIR) + if LAST_STATUS == 2: + os._exit(1) os._exit(0) else: logging.error('未知的扫码模式')