PYTON运行图
运行图.png (296 KB, 下载次数: 0)
下载附件
2024-4-10 16:42 上传
节假日数据库结构
数据库.png (224.8 KB, 下载次数: 0)
下载附件
2024-4-10 16:42 上传
后台PHP代码
后台.png (103.76 KB, 下载次数: 0)
下载附件
2024-4-10 16:42 上传
[Asm] 纯文本查看 复制代码import time
import threading
import requests
import subprocess
# 检测程序进程是否存在
def processIsRun(_processName):
processes = psutil.process_iter(['name'])
for proc in processes:
_name = proc.name().upper()
if _processName in _name:
return proc
return False
# 每分钟检查并操作一次
def checkProcess():
if mode:
processKey = [{"processName": "QtScrcpy.exe", "path": "C:\Program Files (x86)\QtScrcpy-win-x64-v2.1.2\QtScrcpy.exe"}, {
"processName": "QQ.exe", "path": "C:\Program Files (x86)\Tencent\QQ\Bin\QQScLauncher.exe"}]
for _key in processKey:
_process = processIsRun(_key['processName'].upper())
if mode == 'kill':
if _process:
_process.kill()
else:
print(_key['processName'], "没有运行,不予处理")
if mode == 'run':
if _process:
print(_key['processName'], "程序已经在运行,不予处理")
else:
print("运行", _key['path'])
try:
subprocess.Popen(_key['path'])
print("应用程序已成功启动!")
except Exception as e:
print("启动应用程序时出现错误:", e)
time.sleep(60)
else:
time.sleep(6)
checkProcess()
# 读取远程限制进程的数据
def checkHoliDay():
global mode
params = {"type": "checkHoliDay"}
response = requests.post(
url="https://查询是不是工作日的接口地址/", params=params)
if response.status_code == 200:
try:
configData = response.json()
if configData["holiday"] == 0:
mode = 'run'
if configData["holiday"] == 1:
mode = 'kill'
print(mode)
time.sleep(60*30)
except:
print("数据异常!")
time.sleep(60)
else:
print("加载失败!")
time.sleep(60)
mode = ''
checkHoliDayThread = threading.Thread(target=checkHoliDay)
checkHoliDayThread.start()
checkProcessThread = threading.Thread(target=checkProcess)
checkProcessThread.start()
python文件,php文件,sql文件我都打包上传了。 接口地址也替换了(以前发帖子不小心附带了其它网站链接被警告了,所以不敢发接口地址)
节假日数据我也是从公开的API中获取的,一年获取一次放到自己的数据库中就行了。