from datetime import datetime, timedelta
import os, time
class DealFile():
def __init__(self):
pass
def getTimeNow(self):
now = datetime.now()
return now
def getTimeYesterday(self):
yesterday = self.getTimeNow() - timedelta(days=1)
return yesterday
def checkDataFile(self):
txt_yesterday = self.getTimeYesterday().strftime('%Y%m%d')
file_name = txt_yesterday+'.html'
file_pathwithname = '\\'.join([os.getcwd(), txt_yesterday, file_name])
res = os.path.exists(file_pathwithname)
return res
def checTargetFile(self):
txt_yesterday = self.getTimeYesterday().strftime('%Y%m%d')
file_name = txt_yesterday+'.txt'
file_pathwithname = '\\'.join([os.getcwd(), txt_yesterday, file_name])
res = os.path.exists(file_pathwithname)
return res
def action(self):
i = 0
while i == 0:
print('休息1秒')
time.sleep(1)
while self.checkDataFile():
print('开始执行文件,休息两秒')
time.sleep(2)
print('判断结果文件是否存在,如果是休息10秒')
while self.checTargetFile():
print('文件存在,10秒')
time.sleep(10)
|