I have a Python Script that I am trying to write to run other Python Scripts. The goal is to be able to have a script I run all the time to execute my other scripts overnight. (I tried this using a batch file, and it would execute them, but they would not create the .csv files for some reason) Here is the code I have now.
import time
import subprocess
from threading import Timer
fileRan = False
#Function to launch other python files
def runFiles():
print('Running Scripts Now')
subprocess.call("cmd","report1.py",shell=True)
subprocess.call("cmd","report2.py",shell=True)
subprocess.call("cmd","report3.py",shell=True)
subprocess.call("cmd","report4.py",shell=True)
subprocess.call("cmd","report5.py",shell=True)
subprocess.call("cmd","report6.py",shell=True)
#Function to check current system time against time reports should run
def checkTime(fileRan):
startTime = '15:20'
endTime = '15:25'
print('Current Time Is: ', time.strftime('%H:%M', time.localtime()))
print(fileRan)
if startTime < time.strftime('%H:%M', time.localtime()) < endTime and fileRan is False:
runFiles()
fileRan = True
return fileRan
#Timer itself
t = Timer(60.0, checkTime(fileRan))
t.start()
It will make the first pass and print the current time, and the state of fileRan just fine. It appears to break either when I make the second check, or when it tried to execute the files. Here is the error I am getting:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner
self.run()
File "C:\Python34\lib\threading.py", line 1187, in run
self.function(*self.args, **self.kwargs)
TypeError: 'NoneType' object is not callable
Any help I could get would be great!