Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions clock_sign.py → clock_sign.pyw
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,7 +14,7 @@
把以下代码复制到其中并保存

Set Shell = CreateObject("WScript.Shell")
Shell.Run "python clock_sign.py", 0, False
Shell.Run "pythonw clock_sign.pyw", 0, False
"""

import datetime
Expand Down Expand Up @@ -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():
Expand All @@ -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=",
Expand All @@ -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)
Expand Down
112 changes: 75 additions & 37 deletions rclone_expect_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# @Project: scripts_python
# @Package:
# @Software: PyCharm

import configparser
import json
# 如果import urllib,则在使用urllib.request时会报错
import urllib.request
Expand Down Expand Up @@ -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: 自定义远程配置名称
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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")
Expand All @@ -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)
# conf.set(name, 'region', "global")
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, 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', 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)


"""
Expand Down