python使用定时器和检测程序是否运行

  网上有很多代码,此方法可行:
  非常不错!

def an2_anbdj(self,event):
fow=gg.fileopenbox("打开文件以恢复分区数据",default='*.bin',filetypes=['*.bin','*.img','*.*'])
if len(fow)!=0:
sups.run("android\\fastboot.exe flash "+self.bjk1.Value+" "+ fow,shell=True)
def pros():
p = sups.run('tasklist | findstr fastboot.exe',shell=True)
pp = str(p)
if int(pp[-2]) == 0:
timerx = threading.Timer(2, pros())
timerx.start()
else:
gg.msgbox("分区数据恢复成功!", "消息提示", ok_button="确定")
timerx = threading.Timer(2, pros())
timerx.start()

def an8_anbdj(self,event):
try:
sups.run('taskkill.exe /T /F /IM adb.exe',shell=True)
sups.run('taskkill.exe /T /F /IM fastboot.exe',shell=True)
finally:
pass

def an9_anbdj(self,event):
try:
sups.run('android\\adb.exe reboot', shell=True,timeout=1)
sups.run('android\\fastboot.exe reboot', shell=True,timeout=1)
finally:
pass
posted @ 2021-06-16 19:43  MMCDLONG  阅读(601)  评论(0编辑  收藏  举报