From bd0edc2d18e0e2ca986ca50c2639156b7d588f3f Mon Sep 17 00:00:00 2001 From: woetu Date: Thu, 5 Aug 2021 08:22:19 +0800 Subject: [PATCH 1/6] update --- clock_sign.py => clock_sign.pyw | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) rename clock_sign.py => clock_sign.pyw (84%) diff --git a/clock_sign.py b/clock_sign.pyw similarity index 84% rename from clock_sign.py rename to clock_sign.pyw index 417802b..53f5b78 100644 --- a/clock_sign.py +++ b/clock_sign.pyw @@ -1,8 +1,8 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- # @Author : https://www.bajins.com -# @Description : -# @File : clock_sign.py +# @Description : pythonw clock_sign.pyw +# @File : clock_sign.pyw # @Version: 1.1.0 # @Time : 2020/7/26 11:00 # @Project: scripts_python @@ -14,7 +14,7 @@ 把以下代码复制到其中并保存 Set Shell = CreateObject("WScript.Shell") -Shell.Run "python clock_sign.py", 0, False +Shell.Run "python clock_sign.pyw", 0, False """ import datetime @@ -44,12 +44,15 @@ def run(range=1): if range == 10: # 运行到第10次 set_time(scheduler) return - res = requests.get("https://www.bajins.com", - headers={"User-Agent": USER_AGENT}, verify=False, timeout=600) + detect() + scheduler.enter(60, 0, run, (range + 1,)) # 1分钟后再次运行 + + +def detect(): + res = requests.get("https://www.bajins.com", headers={"User-Agent": USER_AGENT}, verify=False, timeout=600) if res.status_code != 200 or res is None: login() print(res.status_code) - scheduler.enter(60, 0, run, (range + 1,)) # 1分钟后再次运行 def login(): @@ -59,15 +62,14 @@ def login(): session.headers["User-Agent"] = USER_AGENT session.verify = False session.timeout = 600 - res = session.get( - "http://192.168.10.253:8080/smsauth/3/pc.php?params=pwd&force_modify_password=") # 登录页面 + res = session.get("http://192.168.10.253:8080/smsauth/3/pc.php?params=pwd&force_modify_password=") # 登录页面 cookie = '' for name, value in session.cookies.items(): cookie += '{0}={1}'.format(name, value) session.headers["Referer"] = res.url session.headers["Cookie"] = cookie - res = session.get( - "http://192.168.10.253:8080/login_check_password_ageout.php?username=temp004&passwd=temp004") # 登录验证 + # 登录验证 + res = session.get("http://192.168.10.253:8080/login_check_password_ageout.php?username=temp004&passwd=temp004") res = session.get(session.headers["Referer"]) # 再次请求登录页面 res = session.post("http://192.168.10.253:8080/cgi-bin/ace_web_auth.cgi?web_jumpto=&orig_referer=" "&username=temp004&userpwd=temp004&login_page=", @@ -86,6 +88,7 @@ def login(): # ct = win32api.GetConsoleTitle() # hd = win32gui.FindWindow(0, ct) # win32gui.ShowWindow(hd, 0) + detect() # 设置时间调度器 scheduler = sched.scheduler(time.time, time.sleep) set_time(scheduler) From f19d9b33d8f63ffade21af6790fd9048073cc56a Mon Sep 17 00:00:00 2001 From: woetu Date: Thu, 5 Aug 2021 08:22:33 +0800 Subject: [PATCH 2/6] update --- clock_sign.pyw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clock_sign.pyw b/clock_sign.pyw index 53f5b78..5d3948c 100644 --- a/clock_sign.pyw +++ b/clock_sign.pyw @@ -14,7 +14,7 @@ 把以下代码复制到其中并保存 Set Shell = CreateObject("WScript.Shell") -Shell.Run "python clock_sign.pyw", 0, False +Shell.Run "pythonw clock_sign.pyw", 0, False """ import datetime From 359a272e55dc07664f1413c2cfd07116741a9a01 Mon Sep 17 00:00:00 2001 From: woetu Date: Thu, 5 Aug 2021 08:54:15 +0800 Subject: [PATCH 3/6] update --- rclone_expect_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclone_expect_config.py b/rclone_expect_config.py index 7b0ea7e..bfbe95f 100644 --- a/rclone_expect_config.py +++ b/rclone_expect_config.py @@ -245,7 +245,7 @@ def one_drive(rclone_dir, drive_name, region="1", access_token=None): except pexpect.TIMEOUT: # 匹配不上将抛出超时异常 pass - index = child.expect([pexpect.EOF, "Found drive 'root' of type 'business'"]) # Drive OK? + index = child.expect([pexpect.EOF, "Drive OK?"]) # Found drive 'root' of type 'business' if index == 1: # 找到类型为“business”的驱动器 "root",输入y child.sendline('y') From f904f2ac750719c01c9f5fbe4e5941bfc3abcb90 Mon Sep 17 00:00:00 2001 From: woetu Date: Thu, 5 Aug 2021 09:43:05 +0800 Subject: [PATCH 4/6] update --- rclone_expect_config.py | 108 +++++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 35 deletions(-) diff --git a/rclone_expect_config.py b/rclone_expect_config.py index bfbe95f..19f2106 100644 --- a/rclone_expect_config.py +++ b/rclone_expect_config.py @@ -8,7 +8,7 @@ # @Project: scripts_python # @Package: # @Software: PyCharm - +import configparser import json # 如果import urllib,则在使用urllib.request时会报错 import urllib.request @@ -312,22 +312,13 @@ def google_drive(rclone_dir, drive_name): auto_rclone_config_end(child) -def write_google_drive_config(rclone_dir, name, token=None, drive_type="drive", scope="drive", team_drive=None, - root_folder_id=None, shared_with_me=None, service_account_file=None, saf=None): +def red_rclone_config(rclone_dir: str, name: str): """ - 此函数是为了方便写入在其他地方已经授权复制过来的Google Drive配置,而不需要重新创建配置 - :param name: 自定义远程配置名称 - :param token: 授权token - :param drive_type: drive类型,一般默认即可 - :param scope: rclone从驱动器请求访问时应使用的范围,对应--drive-scope参数 - :param team_drive: 团队驱动器的ID,对应--drive-team-drive参数 - :param root_folder_id: 根文件夹的ID,对应--drive-root-folder-id参数 - :param shared_with_me: 只显示与我共享的文件,对应--drive-shared-with-me参数 - :param saf: 服务帐户凭据JSON文件内容,此参数有值且service_account_file为空时默认saf.json - :param service_account_file: 服务帐户凭据JSON文件路径,对应--drive-service-account-file参数 + 获取rclone配置文件 + :param rclone_dir + :param name: :return: """ - import configparser conf = configparser.ConfigParser() # 获取rclone配置文件的路径 file = subprocess.getoutput(f"./{rclone_dir}/rclone config file") @@ -341,27 +332,74 @@ def write_google_drive_config(rclone_dir, name, token=None, drive_type="drive", if name not in node_array: # 添加远程节点 conf.add_section(name) - conf.set(name, 'type', drive_type) - conf.set(name, 'scope', scope) - if token is not None: - conf.set(name, 'token', token) - if team_drive is not None: - conf.set(name, 'team_drive', team_drive) - if root_folder_id is not None: - conf.set(name, 'root_folder_id', root_folder_id) - if shared_with_me is not None: - # "true" 或 ”false" - conf.set(name, 'shared_with_me', shared_with_me) - if saf is not None: - if service_account_file is None: - service_account_file = "saf.json" - with open(service_account_file, 'w') as f: - f.write(saf) - if service_account_file is not None: - # 服务账户授权json文件路径 https://rclone.org/drive/#service-account-support - conf.set(name, 'service_account_file ', service_account_file) - with open(file, 'w') as f: - conf.write(f) + return conf, file + + +def write_one_drive_config(rclone_dir: str, name: str, type="onedrive", drive_type="business", token=None, + drive_id=None): + """ + 此函数是为了方便写入在其他地方已经授权复制过来的One Drive配置,而不需要重新创建配置 + :param rclone_dir: + :param name: 自定义远程配置名称 + :param type: drive类型,一般默认即可 + :param drive_type: + :param token: 授权token + :param drive_id: + :return: + """ + conf, file = red_rclone_config(rclone_dir, name) + + conf.set(name, 'type', type) + conf.set(name, 'drive_type', drive_type) + if token is not None: + conf.set(name, 'token', token) + if drive_id is not None: + conf.set(name, 'drive_id', drive_id) + + with open(file, 'w') as f: + conf.write(f) + + +def write_google_drive_config(rclone_dir: str, name: str, token=None, drive_type="drive", scope="drive", + team_drive=None, root_folder_id=None, shared_with_me=None, service_account_file=None, + saf=None): + """ + 此函数是为了方便写入在其他地方已经授权复制过来的Google Drive配置,而不需要重新创建配置 + :param name: 自定义远程配置名称 + :param token: 授权token + :param drive_type: drive类型,一般默认即可 + :param scope: rclone从驱动器请求访问时应使用的范围,对应--drive-scope参数 + :param team_drive: 团队驱动器的ID,对应--drive-team-drive参数 + :param root_folder_id: 根文件夹的ID,对应--drive-root-folder-id参数 + :param shared_with_me: 只显示与我共享的文件,对应--drive-shared-with-me参数 + :param saf: 服务帐户凭据JSON文件内容,此参数有值且service_account_file为空时默认saf.json + :param service_account_file: 服务帐户凭据JSON文件路径,对应--drive-service-account-file参数 + :return: + """ + conf, file = red_rclone_config(rclone_dir, name) + + conf.set(name, 'type', drive_type) + conf.set(name, 'scope', scope) + if token is not None: + conf.set(name, 'token', token) + if team_drive is not None: + conf.set(name, 'team_drive', team_drive) + if root_folder_id is not None: + conf.set(name, 'root_folder_id', root_folder_id) + if shared_with_me is not None: + # "true" 或 ”false" + conf.set(name, 'shared_with_me', shared_with_me) + if saf is not None: + if service_account_file is None: + service_account_file = "saf.json" + with open(service_account_file, 'w') as f: + f.write(saf) + if service_account_file is not None: + # 服务账户授权json文件路径 https://rclone.org/drive/#service-account-support + conf.set(name, 'service_account_file ', service_account_file) + + with open(file, 'w') as f: + conf.write(f) """ From 8dad29567c6e488bac54424b0a3f16995e96bdb5 Mon Sep 17 00:00:00 2001 From: woetu Date: Thu, 5 Aug 2021 09:44:30 +0800 Subject: [PATCH 5/6] update --- rclone_expect_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclone_expect_config.py b/rclone_expect_config.py index 19f2106..2c1a166 100644 --- a/rclone_expect_config.py +++ b/rclone_expect_config.py @@ -184,7 +184,7 @@ def auto_rclone_config_end(child): def one_drive(rclone_dir, drive_name, region="1", access_token=None): """ - One Drive 配置 + One Drive 配置,会自动获取drive_id api返回错误信息:https://docs.microsoft.com/zh-cn/onedrive/developer/rest-api/concepts/errors :param rclone_dir: rclone运行目录 :param drive_name: 自定义远程配置名称 From c6f8590859c11661a6582064d8f3a7dfc710bbc7 Mon Sep 17 00:00:00 2001 From: woetu Date: Thu, 5 Aug 2021 09:48:17 +0800 Subject: [PATCH 6/6] update --- rclone_expect_config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rclone_expect_config.py b/rclone_expect_config.py index 2c1a166..afbd104 100644 --- a/rclone_expect_config.py +++ b/rclone_expect_config.py @@ -351,6 +351,7 @@ def write_one_drive_config(rclone_dir: str, name: str, type="onedrive", drive_ty conf.set(name, 'type', type) conf.set(name, 'drive_type', drive_type) + # conf.set(name, 'region', "global") if token is not None: conf.set(name, 'token', token) if drive_id is not None: @@ -360,9 +361,8 @@ def write_one_drive_config(rclone_dir: str, name: str, type="onedrive", drive_ty conf.write(f) -def write_google_drive_config(rclone_dir: str, name: str, token=None, drive_type="drive", scope="drive", - team_drive=None, root_folder_id=None, shared_with_me=None, service_account_file=None, - saf=None): +def write_google_drive_config(rclone_dir: str, name: str, token=None, type="drive", scope="drive", team_drive=None, + root_folder_id=None, shared_with_me=None, service_account_file=None, saf=None): """ 此函数是为了方便写入在其他地方已经授权复制过来的Google Drive配置,而不需要重新创建配置 :param name: 自定义远程配置名称 @@ -378,7 +378,7 @@ def write_google_drive_config(rclone_dir: str, name: str, token=None, drive_type """ conf, file = red_rclone_config(rclone_dir, name) - conf.set(name, 'type', drive_type) + conf.set(name, 'type', type) conf.set(name, 'scope', scope) if token is not None: conf.set(name, 'token', token)