In Python, I am calling sub files from main python file.
In all sub python files, I have included try and except block.
In main file, I need the sub files to be executed in the order I have mentioned below.
Is there a way to stop executing os.system("python SubFile2.py")
statement, if any error is caught in os.system("python SubFile1.py")
statement?
And also I need to get the error details in the main python file.
This is the code snippet of main file:
import os
import sys
print("start here")
try:
print('inside try')
os.system("python SubFile1.py")
os.system("python SubFile2.py")
os.system("python SubFile4.py")
except:
print("Unexpected error:")
print(sys.exc_info()[0])
print(sys.exc_info()[1])
print(sys.exc_info()[2])
finally:
print('finally ended')
Thanks in advance