diff --git a/glue_python/aliyuntoken/aliyuntoken.py b/glue_python/aliyuntoken/aliyuntoken.py index a80357f..2815688 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 @@ if __name__ == '__main__': 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 997cec8..9840125 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 @@ if __name__ == '__main__': 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('未知的扫码模式')