Python Access logging of another program ran in subprocess

p.infante413 at gmail.com p.infante413 at gmail.com
Sun Jun 26 12:38:06 EDT 2016


Hello, I'm currently running another Python program (prog2.py) in my program via subprocess. 

input_args = ['python', '/path/to/prog2.py'] + self.chosen_args
file = open("logfile.txt",'w')
self.process = Popen((input_args), stdout=file)

However, the logs that prog2.py contains still show at the terminal since logs are not covered in the stdout module and printed in the terminal, also, the logfile.txt is empty. Is there a way I can access those logs while in prog1.py? I can't modify prog2.py since it is not mine. I'm stuck here for days now, any tips or help will do.



More information about the Python-list mailing list