Skip to content

Commit

Permalink
feat: added qrcode expiration reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
DDSRem committed Dec 28, 2024
1 parent a5abbef commit e06dd75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion glue_python/aliyuntoken/aliyuntoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('等待用户扫码...')
Expand Down Expand Up @@ -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('未知的扫码模式')
Expand Down
8 changes: 7 additions & 1 deletion glue_python/aliyuntoken/aliyuntoken_nn.ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('等待用户扫码...')
Expand Down Expand Up @@ -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('未知的扫码模式')
Expand Down

0 comments on commit e06dd75

Please sign in to comment.