From 84a9402a733e861098cfe8ad1a851bc5e3891f50 Mon Sep 17 00:00:00 2001 From: DDSRem <73049927+DDSRem@users.noreply.github.com> Date: Sat, 30 Nov 2024 11:38:09 +0800 Subject: [PATCH] Revert "feat: aliyunpan refresh token support shell qrcode" This reverts commit 42bb8c9bb49699f7dec2979dde649fce54c53851. --- glue_python/aliyuntoken/aliyuntoken.py | 47 +++-------------- glue_python/aliyuntoken/aliyuntoken_nn.ci.py | 47 +++-------------- glue_python/aliyuntoken/aliyuntoken_vercel.py | 50 +++---------------- glue_python/aliyuntoken/requirements.txt | 4 +- 4 files changed, 20 insertions(+), 128 deletions(-) diff --git a/glue_python/aliyuntoken/aliyuntoken.py b/glue_python/aliyuntoken/aliyuntoken.py index 20f8d0908c..5cef99b0e5 100644 --- a/glue_python/aliyuntoken/aliyuntoken.py +++ b/glue_python/aliyuntoken/aliyuntoken.py @@ -8,10 +8,7 @@ import os import threading import sys -import qrcode -import argparse from PIL import Image -import pyzbar.pyzbar as pyzbar from io import BytesIO from flask import Flask, send_file, render_template, jsonify @@ -42,7 +39,7 @@ } -def poll_qrcode_status(data, log_print): +def poll_qrcode_status(data): global last_status while True: re = requests.post('https://api.xhofe.top/alist/ali/ck', json=data, headers=headers) @@ -62,18 +59,10 @@ def poll_qrcode_status(data, log_print): last_status = 1 break else: - if log_print: - logging.info('等待用户扫码...') + logging.info('等待用户扫码...') time.sleep(2) -def decode_qr_code(qr_code_image_path): - img = Image.open(qr_code_image_path) - decoded_objects = pyzbar.decode(img) - for obj in decoded_objects: - return obj.data.decode('utf-8') - - @app.route("/") def index(): return render_template('index.html') @@ -104,11 +93,7 @@ def shutdown(): if __name__ == '__main__': if os.path.isfile(qrcode_dir): os.remove(qrcode_dir) - parser = argparse.ArgumentParser(description='AliyunPan Refresh Token') - parser.add_argument('--qrcode_mode', type=str, help='扫码模式') - args = parser.parse_args() logging.info('二维码生成中...') - re_count = 0 while True: re = requests.get('https://api.xhofe.top/alist/ali/qr', headers=headers) if re.status_code == 200: @@ -126,27 +111,7 @@ def shutdown(): if os.path.isfile(qrcode_dir): logging.info('二维码生成完成!') break - time.sleep(1) - re_count += 1 - if re_count == 3: - logging.error('二维码生成失败,退出进程') - os._exit(1) - if args.qrcode_mode == 'web': - threading.Thread(target=poll_qrcode_status, args=(data, True)).start() - app.run(host='0.0.0.0', port=34256) - elif args.qrcode_mode == 'shell': - threading.Thread(target=poll_qrcode_status, args=(data, False)).start() - decoded_data = decode_qr_code(qrcode_dir) - qr = qrcode.QRCode(border=1) - qr.add_data(decoded_data) - qr.make(fit=True) - qr.make_image(fill_color="black", back_color="white") - qr.print_ascii(invert=True, tty=sys.stdout.isatty()) - while last_status != 1: - time.sleep(1) - if os.path.isfile(qrcode_dir): - os.remove(qrcode_dir) - os._exit(0) - else: - logging.error('未知的扫码模式') - os._exit(1) + else: + time.sleep(1) + threading.Thread(target=poll_qrcode_status, args=(data,)).start() + app.run(host='0.0.0.0', port=34256) diff --git a/glue_python/aliyuntoken/aliyuntoken_nn.ci.py b/glue_python/aliyuntoken/aliyuntoken_nn.ci.py index 607ae04861..4ac7b39f0d 100644 --- a/glue_python/aliyuntoken/aliyuntoken_nn.ci.py +++ b/glue_python/aliyuntoken/aliyuntoken_nn.ci.py @@ -8,10 +8,7 @@ import os import threading import sys -import qrcode -import argparse from PIL import Image -import pyzbar.pyzbar as pyzbar from io import BytesIO from flask import Flask, send_file, render_template, jsonify @@ -25,7 +22,7 @@ qrcode_dir= '/aliyuntoken/qrcode.png' -def poll_qrcode_status(data, log_print): +def poll_qrcode_status(data): global last_status while True: re = requests.post('https://api-cf.nn.ci/alist/ali/ck', json=data) @@ -45,18 +42,10 @@ def poll_qrcode_status(data, log_print): last_status = 1 break else: - if log_print: - logging.info('等待用户扫码...') + logging.info('等待用户扫码...') time.sleep(2) -def decode_qr_code(qr_code_image_path): - img = Image.open(qr_code_image_path) - decoded_objects = pyzbar.decode(img) - for obj in decoded_objects: - return obj.data.decode('utf-8') - - @app.route("/") def index(): return render_template('index.html') @@ -87,11 +76,7 @@ def shutdown(): if __name__ == '__main__': if os.path.isfile(qrcode_dir): os.remove(qrcode_dir) - parser = argparse.ArgumentParser(description='AliyunPan Refresh Token') - parser.add_argument('--qrcode_mode', type=str, help='扫码模式') - args = parser.parse_args() logging.info('二维码生成中...') - re_count = 0 while True: re = requests.get('https://api-cf.nn.ci/alist/ali/qr') if re.status_code == 200: @@ -109,27 +94,7 @@ def shutdown(): if os.path.isfile(qrcode_dir): logging.info('二维码生成完成!') break - time.sleep(1) - re_count += 1 - if re_count == 3: - logging.error('二维码生成失败,退出进程') - os._exit(1) - if args.qrcode_mode == 'web': - threading.Thread(target=poll_qrcode_status, args=(data, True)).start() - app.run(host='0.0.0.0', port=34256) - elif args.qrcode_mode == 'shell': - threading.Thread(target=poll_qrcode_status, args=(data, False)).start() - decoded_data = decode_qr_code(qrcode_dir) - qr = qrcode.QRCode(border=1) - qr.add_data(decoded_data) - qr.make(fit=True) - qr.make_image(fill_color="black", back_color="white") - qr.print_ascii(invert=True, tty=sys.stdout.isatty()) - while last_status != 1: - time.sleep(1) - if os.path.isfile(qrcode_dir): - os.remove(qrcode_dir) - os._exit(0) - else: - logging.error('未知的扫码模式') - os._exit(1) + else: + time.sleep(1) + threading.Thread(target=poll_qrcode_status, args=(data,)).start() + app.run(host='0.0.0.0', port=34256) diff --git a/glue_python/aliyuntoken/aliyuntoken_vercel.py b/glue_python/aliyuntoken/aliyuntoken_vercel.py index 01d6d110ff..2d25084871 100644 --- a/glue_python/aliyuntoken/aliyuntoken_vercel.py +++ b/glue_python/aliyuntoken/aliyuntoken_vercel.py @@ -8,10 +8,7 @@ import os import threading import sys -import qrcode -import argparse from PIL import Image -import pyzbar.pyzbar as pyzbar import io from flask import Flask, send_file, render_template, jsonify @@ -25,7 +22,7 @@ qrcode_dir= '/aliyuntoken/qrcode.png' -def poll_qrcode_status(data, log_print): +def poll_qrcode_status(data): global last_status ck = str(data['ck']) t = str(data['t']) @@ -45,18 +42,10 @@ def poll_qrcode_status(data, log_print): last_status = 1 break else: - if log_print: - logging.info('等待用户扫码...') + logging.info('等待用户扫码...') time.sleep(2) -def decode_qr_code(qr_code_image_path): - img = Image.open(qr_code_image_path) - decoded_objects = pyzbar.decode(img) - for obj in decoded_objects: - return obj.data.decode('utf-8') - - @app.route("/") def index(): return render_template('index.html') @@ -87,12 +76,8 @@ def shutdown(): if __name__ == '__main__': if os.path.isfile(qrcode_dir): os.remove(qrcode_dir) - parser = argparse.ArgumentParser(description='AliyunPan Refresh Token') - parser.add_argument('--qrcode_mode', type=str, help='扫码模式') - args = parser.parse_args() - logging.info('二维码生成中...') - re_count = 0 while True: + logging.info('二维码生成中...') re = requests.get('https://aliyuntoken.vercel.app/api/generate?img=true') if re.status_code == 200: re_data = json.loads(re.content) @@ -106,28 +91,7 @@ def shutdown(): if os.path.isfile(qrcode_dir): logging.info('二维码生成完成!') break - time.sleep(1) - re_count += 1 - if re_count == 3: - logging.error('二维码生成失败,退出进程') - os._exit(1) - if args.qrcode_mode == 'web': - threading.Thread(target=poll_qrcode_status, args=(data, True)).start() - app.run(host='0.0.0.0', port=34256) - elif args.qrcode_mode == 'shell': - threading.Thread(target=poll_qrcode_status, args=(data, False)).start() - decoded_data = decode_qr_code(qrcode_dir) - qr = qrcode.QRCode(border=1) - qr.add_data(decoded_data) - qr.make(fit=True) - qr.make_image(fill_color="black", back_color="white") - qr.print_ascii(invert=True, tty=sys.stdout.isatty()) - while last_status != 1: - time.sleep(1) - if os.path.isfile(qrcode_dir): - os.remove(qrcode_dir) - os._exit(0) - else: - logging.error('未知的扫码模式') - os._exit(1) - + else: + time.sleep(1) + threading.Thread(target=poll_qrcode_status, args=(data,)).start() + app.run(host='0.0.0.0', port=34256) diff --git a/glue_python/aliyuntoken/requirements.txt b/glue_python/aliyuntoken/requirements.txt index 04ea328435..655225a68e 100644 --- a/glue_python/aliyuntoken/requirements.txt +++ b/glue_python/aliyuntoken/requirements.txt @@ -1,4 +1,2 @@ flask -pillow -pyzbar -requests \ No newline at end of file +pillow \ No newline at end of file