import subprocess
import sched
from time import time, sleep
# 创建sched模块的 scheduler 类的实例
scheduler = sched.scheduler(time, sleep)
def execute_robot_tests(cmd):
# 执行Robot Framework命令
subprocess.run(cmd, shell=True)
def robot_test_scheduler(cmd, delay):
# 定义调度任务
scheduler.enter(delay, 1, robot_test_scheduler, (cmd, delay))
execute_robot_tests(cmd)
def main():
# 设置Robot Framework命令
robot_command = "robot -d /Users/xxx/Desktop/working/automation/result/ -T /Users/xxx/Desktop/working/automation/creator/PGC/页面.robot"
delay = 60 # 60秒
# 进行调度
robot_test_scheduler(robot_command, delay)
# 运行调度器
run_continuously(delay)
def run_continuously(delay):
# 持续运行,直到程序被中断
while True:
scheduler.run(blocking=False)
sleep(1)
if __name__ == '__main__':
main()