python 定时任务管理封装

news2024/12/24 12:57:06

ba9020c2dabe42aaa508da75e09c2c07.png

主逻辑代码

# -*- coding: utf-8 -*-
# import apscheduler
import  pandas as pd
from datetime import datetime
# 导入调度器,此处使用BackgroundScheduler阻塞调度器
from apscheduler.schedulers.background import BackgroundScheduler
# 导入触发器,此处使用IntervalTrigger特定时间间隔触发
from apscheduler.triggers.interval import IntervalTrigger
from apscheduler.triggers.cron import CronTrigger
from apscheduler.triggers.date import DateTrigger
from apscheduler.executors.pool import ThreadPoolExecutor,ProcessPoolExecutor
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.util import undefined
import os,time,sys,random,copy,json
from QhTestJob import Ui_Form
from PyQt5.QtWidgets import QApplication
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt

# cron定时调度(某一定时时刻执行)
# (int|str) 表示参数既可以是int类型,也可以是str类型
# (datetime | str) 表示参数既可以是datetime类型,也可以是str类型
# year (int|str) – 4-digit year -(表示四位数的年份,如2008年)
# month (int|str) – month (1-12) -(表示取值范围为1-12月)
# day (int|str) – day of the (1-31) -(表示取值范围为1-31日)
# week (int|str) – ISO week (1-53) -(格里历2006年12月31日可以写成2006年-W52-7(扩展形式)或2006W527(紧凑形式))
# day_of_week (int|str) – number or name of weekday (0-6 or mon,tue,wed,thu,fri,sat,sun) - (表示一周中的第几天,既可以用0-6表示也可以用其英语缩写表示)
# hour (int|str) – hour (0-23) - (表示取值范围为0-23时)
# minute (int|str) – minute (0-59) - (表示取值范围为0-59分)
# second (int|str) – second (0-59) - (表示取值范围为0-59秒)
# start_date (datetime|str) – earliest possible date/time to trigger on (inclusive) - (表示开始时间)
# end_date (datetime|str) – latest possible date/time to trigger on (inclusive) - (表示结束时间)
# timezone (datetime.tzinfo|str) – time zone to use for the date/time calculations (defaults to scheduler timezone) -(表示时区取值)

#  interval 间隔调度(每隔多久执行)
# weeks (int) – number of weeks to wait
# days (int) – number of days to wait
# hours (int) – number of hours to wait
# minutes (int) – number of minutes to wait
# seconds (int) – number of seconds to wait
# start_date (datetime|str) – starting point for the interval calculation
# end_date (datetime|str) – latest possible date/time to trigger on
# timezone (datetime.tzinfo|str) – time zone to use for the date/time calculations

# date 定时调度(作业只会执行一次)
# run_date (datetime|str) – the date/time to run the job at  -(任务开始的时间)
# timezone (datetime.tzinfo|str) – time zone for run_date if it doesn’t have one already
def QhRR(QhVALUE,QhVALUE1):
    print("{}--{}执行定时任务...".format(QhVALUE,QhVALUE1))

class QhApscheduler():
    QhFiled = {
                "QhJabId": "None",            # 任务ID
                "QhJabName": "None",          # 任务名称
                "QhJabFuncName": "None",      # 任务名称 执行的程序名
                "QhTimesType": "None",        # 任务类型  重复 间隔 一次
                "QhYear": "None",             # 年
                "QhMonth": "None",            # 月
                "QhDay": "None",              # 日
                "QhWeek": "None",             # 周
                "QhDayOfWeek": "None",        # 星期几
                "QhHour": "None",             # 小时
                "QhMinute": "None",           # 分钟
                "QhSecond": "None",           # 秒钟
                "QhJabArgs": "None",          # 任务参数  函数参数
                "QhJabKwargs": "None",        # 任务参数  函数参数
                "QhJabStartDate": "None",     # 开始时间
                "QhJabNextRunTime": "None",   # 下次运行时间
                "QhJabLastRunTime": "None",    # 上次运行时间
                "QhJabStatus": "None"         # 任务状态 
                }
    def __init__(self, 
                 *args, **kwargs):
        self.QhCheduPath = os.path.dirname(os.path.abspath(__file__))         #绝对路径 用于获取定时模块的根目录
        print(self.QhCheduPath)
        self.QhCheduPoolJobDf = self._QhinitJobPoolCsv()
        QhExecutors = {
                'default':ThreadPoolExecutor(20),
                'processpool':ProcessPoolExecutor(10)
                    }
        self.QhJobstores = {
            'default': SQLAlchemyJobStore(url='sqlite:///QhJobPoolDb/QhJabSqlite.sqlite')
                }
        self.Qhscheduler = BackgroundScheduler(jobstores=self.QhJobstores,executors=QhExecutors,misfire_grace_time=3,coalescing=True)
        self.Qhscheduler.start()
        self._QhInitAddJobFor()

    
    def _QhInitAddJobFor(self,QhIsFor = True):
        if self.QhCheduPoolJobDf.shape[0] == 0: return
        for QhInx,QhRow in self.QhCheduPoolJobDf.iterrows():
            QhJabId = QhRow["QhJabId"]
            QhJabName = QhRow["QhJabName"]
            QhJabFuncName = QhRow["QhJabFuncName"]
            QhTimesType = QhRow["QhTimesType"]
            QhYear = self.QhGeShiZH(QhRow["QhYear"])
            QhMonth = self.QhGeShiZH(QhRow["QhMonth"])
            QhDay = self.QhGeShiZH(QhRow["QhDay"])
            QhWeek = self.QhGeShiZH(QhRow["QhWeek"])
            QhDayOfWeek = self.QhGeShiZH(QhRow["QhDayOfWeek"])
            QhHour = self.QhGeShiZH(QhRow["QhHour"])
            QhMinute = self.QhGeShiZH(QhRow["QhMinute"])
            QhSecond = self.QhGeShiZH(QhRow["QhSecond"])
            QhJabArgs = self.QhGeShiZH(QhRow["QhJabArgs"])
            QhJabKwargs = self.QhGeShiZH(QhRow["QhJabKwargs"])       
            QhJabStartDate = QhRow["QhJabStartDate"]
            QhJabNextRunTime = QhRow["QhJabNextRunTime"]
            # QhJabLastRunTime = QhRow["QhJabLastRunTime"]
            # QhJabEndDate = QhRow["QhJabEndDate"]
            QhJabStatus = self.QhGeShiZH(QhRow["QhJabStatus"])
            print(QhYear,QhMonth,QhDay,QhWeek,QhDayOfWeek,QhHour,QhMinute,QhSecond)
            print(type(QhYear),type(QhMonth),type(QhDay),type(QhWeek),type(QhDayOfWeek),type(QhHour),type(QhMinute),type(QhSecond))
            self.QhAddJob(QhJabId,
                          QhTimesType=QhTimesType,
                          QhJabFuncName = QhJabFuncName,
                          QhJabArgs=QhJabArgs,
                          QhJabKwargs=QhJabKwargs,
                          QhName = QhJabName,
                          QhYear = QhYear,
                          QhMonth = QhMonth,
                          QhDay = QhDay,
                          QhWeek = QhWeek,
                          QhDayOfWeek = QhDayOfWeek,
                          QhHour = QhHour,
                          QhMinute = QhMinute,
                          QhSecond = QhSecond,
                          QhIsFor = QhIsFor,
                          QhJabStatus=QhJabStatus)
        # QhIsFor当为True时,保存到csv文件,批量增加时的场景
        if QhIsFor == True:self.QhCheduPoolJobDf.to_csv(self.QhCheduPoolJobCsv, index=False,encoding='gbk')
                      
    def _QhinitJobPoolCsv(self):
        # 初始化定时任务数据库文件夹
        # 作者:阙辉
        QhCheduPathpd = "{}\QhJobPoolDb".format(self.QhCheduPath)
        if os.path.exists(QhCheduPathpd):
            print("{} is exist!".format(QhCheduPathpd))
        else:
            os.mkdir(QhCheduPathpd)
            print("{} is not exist, create it!".format(QhCheduPathpd))
        self.QhCheduPoolJobCsv = "{}\QhJobPoolCsv.csv".format(QhCheduPathpd)
        if not os.path.exists(self.QhCheduPoolJobCsv):
            QhFiled = list(QhApscheduler.QhFiled.keys())
            self.QhCheduPoolJobDf = pd.DataFrame(columns=QhFiled)
            self.QhCheduPoolJobDf.to_csv(self.QhCheduPoolJobCsv, index=False)
        else:
            self.QhCheduPoolJobDf = pd.read_csv(self.QhCheduPoolJobCsv, encoding='gbk')
        self.QhCheduPoolJobDf.fillna("None", inplace=True)
        return self.QhCheduPoolJobDf

    def QhAddJob(self, 
                 QhJabId,
                 QhTimesType,    # 重复 间隔 一次
                 QhJabFuncName,
                 QhJabArgs=None,
                 QhJabKwargs=None,
                 QhName=None,
                 QhYear = None,
                 QhMonth = None,
                 QhDay = None,
                 QhWeek = None,
                 QhDayOfWeek = None,
                 QhHour = None,
                 QhMinute = None,
                 QhSecond = None,
                 QhStartDate = None,
                 QhEndDate = None,
                 QhTimezone=None,
                 QhJitter=None,
                 misfire_grace_time=undefined,
                 next_run_time=undefined,
                 jobstore='default',
                 executor='default',
                 coalesce=undefined,
                 max_instances=undefined,
                 replace_existing=False,
                 QhIsFor = False,
                 QhJabStatus = None,
                 QhJobIsOpen = False,
                 ):
        
        if self.Qhscheduler.get_job(QhJabId): 
            print("{} is exist!".format(QhJabId))
            return   # 如果任务已经存在,则不添加
        if QhJabStatus == "已关闭" and (not QhJobIsOpen):
            print("{} 任务已关闭,不用新建!".format(QhJabId))
            return
        QhTiggers = self.QhTiggers(QhTimesType =QhTimesType,
                                   QhYear = QhYear,
                                   QhMonth = QhMonth,
                                   QhDay = QhDay,
                                   QhWeek = QhWeek,
                                   QhDayOfWeek = QhDayOfWeek,
                                   QhHour = QhHour,
                                   QhMinute = QhMinute,
                                   QhSecond = QhSecond,
                                   QhStartDate = QhStartDate,
                                   QhEndDate = QhEndDate,
                                   QhTimezone=QhTimezone,
                                   QhJitter=QhJitter)
        if QhJabArgs!=None:
            QhJabArgs = tuple(QhJabArgs.split("+"))
        if QhJabKwargs != None:
           QhJabKwargs = QhJabKwargs.replace("+",',')
           QhJabKwargs = QhJabKwargs.replace("'",'"')
           QhJabKwargs = json.loads(QhJabKwargs)
     
        self.Qhscheduler.add_job(func=globals()[QhJabFuncName],
                                 trigger=QhTiggers,
                                 args=QhJabArgs,
                                 kwargs=QhJabKwargs,
                                 id=QhJabId,
                                 name=QhName,
                                 misfire_grace_time=misfire_grace_time,
                                 next_run_time=next_run_time,
                                 jobstore=jobstore,
                                 executor=executor,
                                 coalesce=coalesce,
                                 max_instances=max_instances,
                                 replace_existing=replace_existing,)

        # 函数参数还原输入格式处理  阙辉
        # print(QhJabArgs,type(QhJabArgs))
        if isinstance(QhJabArgs, tuple):
            QhJabArgs = str(QhJabArgs).replace("'",'').replace("(",'').\
            replace(")",'').replace(",","+").replace("+  ","+").replace("+ ","+")
        #     print(QhJabArgs,type(QhJabArgs))
        # print(QhJabKwargs,type(QhJabKwargs))
        if isinstance(QhJabKwargs, dict):
            QhJabKwargs = str(QhJabKwargs).replace("'",'"').replace(",","+")
            # print(QhJabKwargs,type(QhJabKwargs))
        QhAddJoblDic = copy.deepcopy(QhApscheduler.QhFiled) 
        QhAddJoblDic["QhJabId"] = QhJabId
        QhAddJoblDic["QhJabName"] = QhName
        QhAddJoblDic["QhJabFuncName"] = "None" if QhJabFuncName==None else QhJabFuncName
        QhAddJoblDic["QhTimesType"] = QhTimesType
        QhAddJoblDic["QhYear"] = "None" if QhYear==None else QhYear
        QhAddJoblDic["QhMonth"] = "None" if QhMonth==None else QhMonth
        QhAddJoblDic["QhDay"] = "None" if QhDay==None else QhDay
        QhAddJoblDic["QhWeek"] = "None" if QhWeek==None else QhWeek
        QhAddJoblDic["QhDayOfWeek"] = "None" if QhDayOfWeek==None else QhDayOfWeek
        QhAddJoblDic["QhHour"] = "None" if QhHour==None else QhHour
        QhAddJoblDic["QhMinute"] = "None" if QhMinute==None else QhMinute
        QhAddJoblDic["QhSecond"] = "None" if QhSecond==None else QhSecond
        QhAddJoblDic["QhJabArgs"] = "None" if QhJabArgs==None else QhJabArgs
        QhAddJoblDic["QhJabKwargs"] = "None" if QhJabKwargs==None else QhJabKwargs
        # QhAddJoblDic["QhJabStartDate"] = "None"
        # QhAddJoblDic["QhJabNextRunTime"] = "None"
        # QhAddJoblDic["QhJabLastRunTime"] = "None"
        QhAddJoblDic["QhJabStatus"] = "已运行"

        try:   # 任务id存在,则更新任务,不存在则新增
            self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf["QhJabId"]==QhJabId].index[0]
            for QhKey,QhValue in QhAddJoblDic.items():
                if QhKey == "QhJabId":continue   
                self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf["QhJabId"]==QhJabId,QhKey] = QhValue
        except:
            QhCheduPoolJobDfRow = pd.DataFrame([QhAddJoblDic])
            print(QhCheduPoolJobDfRow)
            try:
                self.QhCheduPoolJobDf = self.QhCheduPoolJobDf._append(QhCheduPoolJobDfRow)
            except:
                self.QhCheduPoolJobDf = self.QhCheduPoolJobDf.append(QhCheduPoolJobDfRow)
            print(self.QhCheduPoolJobDf)
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        if (not QhIsFor):self.QhCheduPoolJobDf.to_csv(self.QhCheduPoolJobCsv, index=False,encoding='gbk')
       
    def QhTiggers(self,QhTimesType,
                  QhYear = None,
                  QhMonth = None,
                  QhDay = None,
                  QhWeek = None,
                  QhDayOfWeek = None,
                  QhHour = None,
                  QhMinute = None,
                  QhSecond = None,
                  QhStartDate = None,
                  QhEndDate = None,
                  QhTimezone=None,
                  QhJitter=None
                  ):
        if QhTimesType == "重复":
            QhTiggers = CronTrigger(year=QhYear,
                                    month=QhMonth,
                                    day=QhDay,
                                    week=QhWeek,
                                    day_of_week=QhDayOfWeek,
                                    hour=QhHour,
                                    minute=QhMinute,
                                    second=QhSecond,
                                    start_date=QhStartDate,
                                    end_date=QhEndDate,
                                    timezone=QhTimezone,
                                    jitter=QhJitter)
        elif QhTimesType == "间隔":
            QhTiggers = IntervalTrigger(weeks= int(0) if QhWeek == None else QhWeek,
                                        days= 0 if QhDay == None else QhDay,
                                        hours= 0 if QhHour == None else QhHour,
                                        minutes= 0 if QhMinute == None else QhMinute,
                                        seconds= 0 if QhSecond == None else QhSecond,
                                        start_date=QhStartDate,
                                        end_date=QhEndDate,
                                        timezone=QhTimezone,
                                        jitter=QhJitter)
        elif QhTimesType == "一次":
            QhRunDate = datetime(0 if QhYear == None else QhYear, 
                                 0 if QhMonth == None else QhMonth, 
                                 0 if QhDay == None else QhDay, 
                                 0 if QhHour == None else QhHour, 
                                 0 if QhMinute == None else QhMinute, 
                                 0 if QhSecond == None else QhSecond)
            QhTiggers = DateTrigger(run_date=QhRunDate,
                                    timezone=QhTimezone)
            
        return QhTiggers

    def QhPauseJob(self,QhJabId,QhIsFor=False):
        # 暂停任务 
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        # 阙辉
        try:
            if QhJabId == "":
                print("任务ID不能空,请输入任务ID")
                return
            if self.Qhscheduler.get_job(QhJabId):
                self.Qhscheduler.pause_job(QhJabId)
                print("暂停任务",QhJabId)
                self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStatus'] = '已暂停'
                if (not QhIsFor):self.QhCheduPoolJobDf.to_csv(self.QhCheduPoolJobCsv, index=False, encoding='gbk')
                # AA = self.Qhscheduler.get_job(QhJabId)
                # print(AA.state)
            else:
                print("暂停失败,请检查任务ID,任务可能不存在")
        except:
            print("暂停失败,请检查任务ID,任务可能不存在")
    
    def QhPauseJobFor(self,QhIsFor=True):
        # 暂停所有任务
        for QhInx,QhRow in self.QhCheduPoolJobDf.iterrows():
            self.QhPauseJob(QhRow['QhJabId'],QhIsFor)
     

    def QhGetJobsState(self):
        for job in self.Qhscheduler.get_jobs():
            print(f"Job ID: {job.id}, 任务的下一次运行时间: {job.next_run_time}")
            print(f"Job ID: {job.id}, 任务是否有待执行: {job.pending}")
            # print(f"Job ID: {job.id}, 任务是否有待执行: {job.job_state}")
            # print(f"Job ID: {job.id}, 任务是否正在运行: {job.running}")

    def QhResumeJob(self,QhJabId,QhIsFor=False):
        # 恢复任务
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        # 阙辉
        try:
            if QhJabId == "":
                print("任务ID不能空,请输入任务ID")
                return
            if self.Qhscheduler.get_job(QhJabId):
                self.Qhscheduler.resume_job(QhJabId)
                print("恢复任务",QhJabId)
                self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStatus'] = '已运行'
                if (not QhIsFor):self.QhCheduPoolJobDf.to_csv(self.QhCheduPoolJobCsv, index=False, encoding='gbk')
            else:
                print("恢复失败,请检查任务ID,任务可能不存在")
        except:
            print("恢复失败,请检查任务ID,任务可能不存在")

    def QhResumeJobFor(self,QhIsFor=True):
        # 恢复所有任务
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        # 阙辉
        for QhInx,QhRow in self.QhCheduPoolJobDf.iterrows():
            self.QhResumeJob(QhRow['QhJabId'],QhIsFor)

    def QhRemoveJob(self,QhJabId,QhIsFor=False):
        # 删除任务
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        # 阙辉
        try:
            if QhJabId == "":
                print("任务ID不能空,请输入任务ID")
                return
            if self.Qhscheduler.get_job(QhJabId):
                self.Qhscheduler.remove_job(QhJabId)
                print("删除任务",QhJabId)
                self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStatus'] = '已关闭'
                if (not QhIsFor):self.QhCheduPoolJobDf.to_csv(self.QhCheduPoolJobCsv, index=False, encoding='gbk')
            else:
                print("删除失败,请检查任务ID,任务可能不存在")
        except:
            print("删除失败,请检查任务ID,任务可能不存在")
    def QhRemoveJobFor(self,QhIsFor=True):
        # 删除所有任务
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        # 阙辉
        for QhInx,QhRow in self.QhCheduPoolJobDf.iterrows():
            self.QhRemoveJob(QhRow['QhJabId'],QhIsFor)

    def QhReopenJob(self,QhJabId,QhIsFor=False):
        # 重新打开任务
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        # 阙辉
        # try:
        if QhJabId == "":
            print("任务ID不能空,请输入任务ID")
            return
        QhJabStatus = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStatus'].values[0])
        if not self.Qhscheduler.get_job(QhJabId):
            if QhJabStatus == "已关闭":
                # QhJabId = QhRow["QhJabId"]
                QhJabName = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabName'].values[0]
                QhJabFuncName = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabFuncName'].values[0]
                QhTimesType = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhTimesType'].values[0]
                QhYear = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhYear'].values[0])
                QhMonth = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhMonth'].values[0])
                QhDay = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhDay'].values[0])
                QhWeek = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhWeek'].values[0])
                QhDayOfWeek = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhDayOfWeek'].values[0])
                QhHour = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhHour'].values[0])
                QhMinute = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhMinute'].values[0])
                QhSecond = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhSecond'].values[0])
                QhJabArgs = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabArgs'].values[0])
                QhJabKwargs = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabKwargs'].values[0])       
                QhJabStartDate = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStartDate'].values[0]
                QhJabNextRunTime = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabNextRunTime'].values[0]
                # QhJabLastRunTime = QhRow["QhJabLastRunTime"]
                # QhJabEndDate = QhRow["QhJabEndDate"]
                # QhJabStatus = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStatus'].values[0])
                print(QhYear,QhMonth,QhDay,QhWeek,QhDayOfWeek,QhHour,QhMinute,QhSecond)
                print(type(QhYear),type(QhMonth),type(QhDay),type(QhWeek),type(QhDayOfWeek),type(QhHour),type(QhMinute),type(QhSecond))
                self.QhAddJob(QhJabId,
                            QhTimesType=QhTimesType,
                            QhJabFuncName = QhJabFuncName,
                            QhJabArgs=QhJabArgs,
                            QhJabKwargs=QhJabKwargs,
                            QhName = QhJabName,
                            QhYear = QhYear,
                            QhMonth = QhMonth,
                            QhDay = QhDay,
                            QhWeek = QhWeek,
                            QhDayOfWeek = QhDayOfWeek,
                            QhHour = QhHour,
                            QhMinute = QhMinute,
                            QhSecond = QhSecond,
                            QhJabStatus=QhJabStatus,
                            QhIsFor = QhIsFor,
                            QhJobIsOpen = True)  # 状态已在此函数更新
                    
        # except:
        #     print("打开任务失败,请检查任务ID,任务可能不存在")
                    
    def QhReopenJobFor(self,QhIsFor=True):
        # 重新打开所有任务
        # QhIsFor当为False时,保存到csv文件,单个增加时的场景
        # 阙辉
        for QhInx,QhRow in self.QhCheduPoolJobDf.iterrows():
            self.QhReopenJob(QhRow['QhJabId'],QhIsFor)

    def QhShouDongRunJob(self,QhJabId):
        # 手动运行任务
        # 阙辉
        try:
            if QhJabId == "":
                print("任务ID不能空,请输入任务ID")
                return
            # if self.Qhscheduler.get_job(QhJabId):
            QhJabFuncName = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabFuncName'].values[0]
            QhJabArgs = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabArgs'].values[0])
            QhJabKwargs = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabKwargs'].values[0])
            QhJabFunc = globals().get(QhJabFuncName)
            if QhJabFunc:
                if QhJabArgs!= None:
                    QhJabArgs = tuple(QhJabArgs.split("+"))
                    QhJabFunc(*QhJabArgs)
                elif QhJabKwargs != None:
                    QhJabKwargs = QhJabKwargs.replace("+",',')
                    QhJabKwargs = QhJabKwargs.replace("'",'"')
                    QhJabKwargs = json.loads(QhJabKwargs)
                    QhJabFunc(**QhJabKwargs)
            else:
                print(f"Function '{QhJabFuncName}' not found.")
            # self.Qhscheduler.run_job(QhJabId)
                print("手动执行任务",QhJabId)
        except Exception as e:
            print(f"An error occurred while executing the job: {e}")
            print("2手动执行任务失败,请检查任务ID,任务可能不存在")

    def QhShouDongRunJobFor(self):
        # 手动运行所有任务
        # 阙辉
        for QhInx,QhRow in self.QhCheduPoolJobDf.iterrows():
            self.QhShouDongRunJob(QhRow['QhJabId'])

        
         
    def QhXiuGaiJob(self,QhJabId,
                    QhIsFor=True):
        # 修改任务方案:先删除,修改后重新添加
        pass
        # self.QhCheduPoolJobDf = self._QhinitJobPoolCsv()  # 重新加载任务池数据
        # QhJabName = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabName'].values[0]
        # QhJabFuncName = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabFuncName'].values[0]
        # QhTimesType = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhTimesType'].values[0]
        # QhYear = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhYear'].values[0])
        # QhMonth = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhMonth'].values[0])
        # QhDay = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhDay'].values[0])
        # QhWeek = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhWeek'].values[0])
        # QhDayOfWeek = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhDayOfWeek'].values[0])
        # QhHour = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhHour'].values[0])
        # QhMinute = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhMinute'].values[0])
        # QhSecond = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhSecond'].values[0])
        # QhJabArgs = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabArgs'].values[0])
        # QhJabKwargs = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabKwargs'].values[0])       
        # QhJabStartDate = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStartDate'].values[0]
        # QhJabNextRunTime = self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabNextRunTime'].values[0]
        # # QhJabLastRunTime = QhRow["QhJabLastRunTime"]
        # # QhJabEndDate = QhRow["QhJabEndDate"]
        # # QhJabStatus = self.QhGeShiZH(self.QhCheduPoolJobDf.loc[self.QhCheduPoolJobDf['QhJabId'] == QhJabId, 'QhJabStatus'].values[0])
        # print(QhYear,QhMonth,QhDay,QhWeek,QhDayOfWeek,QhHour,QhMinute,QhSecond)
        # print(type(QhYear),type(QhMonth),type(QhDay),type(QhWeek),type(QhDayOfWeek),type(QhHour),type(QhMinute),type(QhSecond))
        # self.Qhscheduler.modify_job()


    def QhGeShiZH(self,QhValue):
        # 时间格式转化  后期需要优化
        # 作者:阙辉
        try:
            if isinstance(QhValue, str):
                if QhValue in ["None","","0"]:
                    # print("zhuan01")
                    return None
                else:
                    try:
                        # print("zhuan02")
                        return int(QhValue)
                        
                    except:
                        # print("zhuan03")
                        return QhValue
            else:
                # print("zhuan04")
                return int(QhValue)
        except:
            # print("zhuan05")
            return None
        
class QhTestApschedulerGui(QtWidgets.QWidget,Ui_Form):
    def __init__(self, parent=None):
        super(QhTestApschedulerGui, self).__init__(parent)
        self.setupUi(self)
        self.aa=QhApscheduler()
       
        self.pushButton_2.clicked.connect(self.QhPauseJob)
        self.pushButton_18.clicked.connect(self.QhResumeJob)
        self.pushButton_19.clicked.connect(self.aa.QhGetJobsState)
        self.pushButton.clicked.connect(self.QhAddJob)
        self.pushButton_3.clicked.connect(self.QhRemoveJob)
        self.pushButton_20.clicked.connect(self.aa.QhPauseJobFor)
        self.pushButton_21.clicked.connect(self.aa.QhResumeJobFor)
        self.pushButton_22.clicked.connect(self.aa.QhRemoveJobFor)
        self.pushButton_23.clicked.connect(self.aa.QhReopenJobFor)
        self.pushButton_6.clicked.connect(self.QhReopenJob)
        self.pushButton_4.clicked.connect(self.QhShouDongRunJob)
        self.pushButton_24.clicked.connect(self.aa.QhShouDongRunJobFor)
        
    
    def QhAddJob(self):

        QhJobId = self.lineEdit_5.text()
        if QhJobId == "":
            print("任务ID不能空,请输入任务ID")
            return
        QhJobName = "{}-Name".format(QhJobId)
        QhScoends = random.randint(8, 20)
        QhTimesType = "间隔"
        QhJabFuncName = "QhRR"

        self.aa.QhAddJob(QhJobId,
                          QhTimesType=QhTimesType,
                          QhJabFuncName = QhJabFuncName,
                          QhName = QhJobName,
                          QhSecond = QhScoends,
                          QhJabArgs = "{QhJobId}-测试顺序+QUEHUI".format(QhJobId=QhJobId),

                          )
        print("添加任务{}".format(QhJobId))




    def QhPauseJob(self):

        QhJobId = self.lineEdit.text()
        print(QhJobId)
        self.aa.QhPauseJob(QhJobId)

    def QhResumeJob(self):
        QhJobId = self.lineEdit_18.text()
        print(QhJobId)
        self.aa.QhResumeJob(QhJobId)

    def QhRemoveJob(self):
        QhJobId = self.lineEdit_2.text()
        print(QhJobId)
        self.aa.QhRemoveJob(QhJobId)

    def QhReopenJob(self):
        QhJobId = self.lineEdit_6.text()
        print(QhJobId)
        self.aa.QhReopenJob(QhJobId)

    def QhShouDongRunJob(self):
        QhJobId = self.lineEdit_3.text()
        print(QhJobId)
        self.aa.QhShouDongRunJob(QhJobId)





        





if __name__ == '__main__':
    # aa=QhApscheduler()
    # aa._QhInitAddJobFor() 

    # # 保持主线程运行
    # try:
    #     while True:
    #         time.sleep(2)
    # except (KeyboardInterrupt, SystemExit):
    #     aa.Qhscheduler.shutdown()
    QApplication.setHighDpiScaleFactorRoundingPolicy(
            Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
    qh_app = QApplication(sys.argv)                 # 创建应用实例
    qh_MyWindows = QhTestApschedulerGui()                        # 创建窗口实例
    qh_MyWindows.show()                             # 显示窗口
    qh_n = qh_app.exec()              # 执行exec()方法,进入事件循环,如果遇到窗口退出命令,返回整数qh_n
    print(qh_n)                       # 输出输出关闭事件返回的整数
    try:                              # 捕获程序退出事件
        sys.exit(qh_n)                    # 通知python系统,结束程序运行
    except SystemExit:
        print("请在此做一些其他工作。")       # python解释器停止执行前的工作

UI代码

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'QhTestJob.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(632, 610)
        self.gridLayout = QtWidgets.QGridLayout(Form)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout_5.addWidget(self.pushButton)
        self.lineEdit_5 = QtWidgets.QLineEdit(Form)
        self.lineEdit_5.setMinimumSize(QtCore.QSize(500, 28))
        self.lineEdit_5.setMaximumSize(QtCore.QSize(500, 16777215))
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.horizontalLayout_5.addWidget(self.lineEdit_5)
        self.verticalLayout.addLayout(self.horizontalLayout_5)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.pushButton_2 = QtWidgets.QPushButton(Form)
        self.pushButton_2.setObjectName("pushButton_2")
        self.horizontalLayout_4.addWidget(self.pushButton_2)
        self.lineEdit = QtWidgets.QLineEdit(Form)
        self.lineEdit.setMinimumSize(QtCore.QSize(230, 28))
        self.lineEdit.setMaximumSize(QtCore.QSize(500, 16777215))
        self.lineEdit.setObjectName("lineEdit")
        self.horizontalLayout_4.addWidget(self.lineEdit)
        self.verticalLayout.addLayout(self.horizontalLayout_4)
        self.horizontalLayout_18 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_18.setObjectName("horizontalLayout_18")
        self.pushButton_18 = QtWidgets.QPushButton(Form)
        self.pushButton_18.setObjectName("pushButton_18")
        self.horizontalLayout_18.addWidget(self.pushButton_18)
        self.lineEdit_18 = QtWidgets.QLineEdit(Form)
        self.lineEdit_18.setMinimumSize(QtCore.QSize(230, 28))
        self.lineEdit_18.setMaximumSize(QtCore.QSize(500, 16777215))
        self.lineEdit_18.setObjectName("lineEdit_18")
        self.horizontalLayout_18.addWidget(self.lineEdit_18)
        self.verticalLayout.addLayout(self.horizontalLayout_18)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.pushButton_3 = QtWidgets.QPushButton(Form)
        self.pushButton_3.setObjectName("pushButton_3")
        self.horizontalLayout_3.addWidget(self.pushButton_3)
        self.lineEdit_2 = QtWidgets.QLineEdit(Form)
        self.lineEdit_2.setMinimumSize(QtCore.QSize(230, 28))
        self.lineEdit_2.setMaximumSize(QtCore.QSize(500, 16777215))
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.horizontalLayout_3.addWidget(self.lineEdit_2)
        self.verticalLayout.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.pushButton_6 = QtWidgets.QPushButton(Form)
        self.pushButton_6.setObjectName("pushButton_6")
        self.horizontalLayout_6.addWidget(self.pushButton_6)
        self.lineEdit_6 = QtWidgets.QLineEdit(Form)
        self.lineEdit_6.setMinimumSize(QtCore.QSize(230, 28))
        self.lineEdit_6.setMaximumSize(QtCore.QSize(500, 16777215))
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.horizontalLayout_6.addWidget(self.lineEdit_6)
        self.verticalLayout.addLayout(self.horizontalLayout_6)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.pushButton_4 = QtWidgets.QPushButton(Form)
        self.pushButton_4.setObjectName("pushButton_4")
        self.horizontalLayout_2.addWidget(self.pushButton_4)
        self.lineEdit_3 = QtWidgets.QLineEdit(Form)
        self.lineEdit_3.setMinimumSize(QtCore.QSize(230, 28))
        self.lineEdit_3.setMaximumSize(QtCore.QSize(500, 16777215))
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.horizontalLayout_2.addWidget(self.lineEdit_3)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pushButton_5 = QtWidgets.QPushButton(Form)
        self.pushButton_5.setObjectName("pushButton_5")
        self.horizontalLayout.addWidget(self.pushButton_5)
        self.lineEdit_4 = QtWidgets.QLineEdit(Form)
        self.lineEdit_4.setMinimumSize(QtCore.QSize(230, 28))
        self.lineEdit_4.setMaximumSize(QtCore.QSize(500, 16777215))
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.horizontalLayout.addWidget(self.lineEdit_4)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.pushButton_19 = QtWidgets.QPushButton(Form)
        self.pushButton_19.setObjectName("pushButton_19")
        self.verticalLayout.addWidget(self.pushButton_19)
        self.pushButton_24 = QtWidgets.QPushButton(Form)
        self.pushButton_24.setObjectName("pushButton_24")
        self.verticalLayout.addWidget(self.pushButton_24)
        self.pushButton_20 = QtWidgets.QPushButton(Form)
        self.pushButton_20.setObjectName("pushButton_20")
        self.verticalLayout.addWidget(self.pushButton_20)
        self.pushButton_21 = QtWidgets.QPushButton(Form)
        self.pushButton_21.setObjectName("pushButton_21")
        self.verticalLayout.addWidget(self.pushButton_21)
        self.pushButton_22 = QtWidgets.QPushButton(Form)
        self.pushButton_22.setObjectName("pushButton_22")
        self.verticalLayout.addWidget(self.pushButton_22)
        self.pushButton_23 = QtWidgets.QPushButton(Form)
        self.pushButton_23.setObjectName("pushButton_23")
        self.verticalLayout.addWidget(self.pushButton_23)
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "添加任务"))
        self.pushButton_2.setText(_translate("Form", "暂停任务"))
        self.pushButton_18.setText(_translate("Form", "启动任务"))
        self.pushButton_3.setText(_translate("Form", "删除任务"))
        self.pushButton_6.setText(_translate("Form", "打开任务"))
        self.pushButton_4.setText(_translate("Form", "手动执行"))
        self.pushButton_5.setText(_translate("Form", "获取任务状态"))
        self.pushButton_19.setText(_translate("Form", "获取所有任务的状态"))
        self.pushButton_24.setText(_translate("Form", "手动执行所有任务"))
        self.pushButton_20.setText(_translate("Form", "暂停所有任务"))
        self.pushButton_21.setText(_translate("Form", "恢复所有任务"))
        self.pushButton_22.setText(_translate("Form", "关闭所有任务"))
        self.pushButton_23.setText(_translate("Form", "打开所有任务"))

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2264730.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

国标GB28181协议平台Liveweb:搭建建筑工地无线视频联网监控系统方案

随着科技高速发展,视频信号经过数字压缩,通过互联网宽带或者移动4G网络传递,可实现远程视频监控功能。将这一功能运用于施工现场安全管理,势必会大大提高管理效率,提升监管层次。而这些,通过Liveweb监控系统…

C++----------函数的调用机制

栈帧的创建与销毁 栈帧创建过程 当一个函数被调用时,系统会在程序的栈空间中为该函数创建一个栈帧。首先,会将函数的返回地址(即调用该函数的下一条指令的地址)压入栈中,这确保函数执行完后能回到正确的位置继续执行后…

【Leetcode】855. 考场就座

文章目录 题目思路代码复杂度分析时间复杂度空间复杂度 结果总结 题目 题目链接🔗 在考场里,有 n n n 个座位排成一行,编号为 0 0 0 到 n − 1 n - 1 n−1。 当学生进入考场后,他必须坐在离最近的人最远的座位上。如果有多个…

Unity引擎学习总结------动画控件

左侧窗格可以在参数视图和图层视图之间切换。参数视图允许您创建、查看和编辑动画控制器参数。这些是您定义的变量,用作状态机的输入。要添加参数,请单击加号图标并从弹出菜单中选择参数类型。要删除参数,请在列表中选择该参数并按删除键&…

UE4_用户控件_1_滑块控制图像颜色的变化

祝愿大美兰陵越来越好,祝愿祖国繁荣昌盛,祝愿人民幸福安康! 一、样式展示: 效果,当角色靠近物体(只有一个胶囊碰撞体)时显示用户控件,调整控件中的滑块值,可以改变UE4lo…

网络编程 02:IP 地址,IP 地址的作用、分类,通过 Java 实现 IP 地址的信息获取

一、概述 记录时间 [2024-12-18] 前置文章:网络编程 01:计算机网络概述,网络的作用,网络通信的要素,以及网络通信协议与分层模型 本文讲述网络编程相关知识——IP 地址,包括 IP 地址的作用、分类&#xff…

【pycharm】远程服务器之后如何打开终端

【pycharm】远程服务器之后如何打开终端 在pycharm中,我们通过远程连接服务器,此时如果我们需要在终端运行的话,并不能直接在本地终端运行,而是需要连接到服务器终端才能运行命令 设置如下: 输入服务器的ip、端口、…

C#+OpenCv深度学习开发(常用模型汇总)

在使用 OpenCvSharp 结合深度学习进行机器视觉开发时,有许多现成的模型可以使用。以下是一些常用的深度学习模型,适用于不同的机器视觉任务,包括物体检测、图像分类和分割等。 使用示例 在 OpenCvSharp 中加载和使用这些模型的基本示例&…

dolphinscheduler服务注册中心源码解析(三)RPC提供者服务整合注册中心注册服务实现源码

RPC提供者服务整合注册中心注册服务实现源码 1.概述2.源码解读思路3.实现2.1.应用服务的RPC服务接口定义2.1.1.MasterServer应用中提供的RPC接口服务2.1.2.WorkerServer应用中提供的RPC接口服务2.2.应用服务的RPC服务接口实现2.2.1.MasterServer应用中提供的RPC接口服务实现类2…

重生之我在异世界学编程之C语言:数据在内存中的存储篇(上)

大家好,这里是小编的博客频道 小编的博客:就爱学编程 很高兴在CSDN这个大家庭与大家相识,希望能在这里与大家共同进步,共同收获更好的自己!!! 目录 引言正文一、数据类型介绍1.内置类型2.自定义…

线程的概念及基本应用

目录 线程的概念 Java中多线程应用 继承Thread类 实现Runnable接口 实现Callable接口 线程的生命周期 线程的基本操作及原理 Thread.join的使用及原理 Thread.sleep的作用 问题 Thread.sleep的工作流程 wait和notify的使用 wait notify 例子 生产者消费者模式 Th…

联通软研院:基于OceanBase落地检索增强生成 (RAG) 的应用实践

本文作者:邱永刚,联通软件研究院OceanBase研发负责人,主要负责中国联通自研关系型数据库分布式CUDB研发、支撑、运维工作。 近年来,生成式人工智能技术取得了飞速进步,很多大模型在自然语言处理及对话系统领域的运用吸…

【更新】LLM Interview

课程链接:BV1o217YeELo 文章目录 LLM基础相关1. LLMs概述2. 大语言模型尺寸3. LLMs的优势与劣势4. 常见的大模型分类5. 目前主流的LLMs开源模型体系有哪些(Prefix Decoder,Causal Decoder,Encoder-Decoder的区别是什么&#xff09…

模型 课题分离

系列文章 分享 模型,了解更多👉 模型_思维模型目录。明确自我与他人责任。 1 课题分离的应用 1.1课题分离在心理治疗中的应用案例:李晓的故事 李晓,一位28岁的软件工程师,在北京打拼。他面临着工作、家庭和感情的多重…

sqlite 自定以脚本解释器

应用程序使用 libfdt 解析设备树,获取兼容性配置 内核源码支持libfdt 标准设备树语法,不用自己再创造 非常的爽,因为设备树支持预编译 一些可以跑类 BSD 系统的设备也可以使用这样的方法,不仅仅是在linux 系统上跑 有pylibfdt 支持解析设备树,校验设备树是否是正确的…

某医院vsan部署技术手册

环境配置 服务器4900G5五台 配置信息:cpu 8368*2颗 ,内存256GB ,双口万兆网卡两个,四口千兆,RAID卡LSI9361-8i12G SAS RAID ,两块固态盘480SSD ,2*1.92TB NVME盘,5*8T盘。 万兆交换机两台H3C…

【编辑器扩展】打开持久化路径/缓存路径/DataPath/StreamingAssetsPath文件夹

代码 [MenuItem("Assets/Open Explorer/PersistentDataPath")]public static void OpenPersistentDataPath(){Application.OpenURL(Application.persistentDataPath);}[MenuItem("Assets/Open Explorer/DataPath")]public static void OpenDataPath(){Appl…

【day14】异常处理与Object类深入解析

【day13】回顾 在深入探讨异常处理与Object类之前,让我们回顾一下【day13】中的关键内容: 权限修饰符: public:最广的访问范围,任何地方都可以访问。protected:在同包和子类中可以访问。默认(无…

【NLP 17、NLP的基础——分词】

我始终相信,世间所有的安排都有它的道理;失之东隅,收之桑榆 —— 24.12.20 一、中文分词的介绍 1.为什么讲分词? ① 分词是一个被长期研究的任务,通过了解分词算法的发展,可以看到NLP的研究历程 ② 分词…

11.vector的介绍及模拟实现

1.vector的介绍 记得之前我们用C语言实现过顺序表,vector本质上也是顺序表,一个能够动态增长的数组。 vector 的底层实现机制 - 动态数组:vector 的底层实现是动态数组。它在内存中连续存储元素,就像一个可以自动调整大小的数…