I know that it is an easy question but I can't do this. I have to do two things. One of them is a management program that will manage the program, e.g stop, pause, resume. The other thing will only show logs. So I need 2 consoles.
How can I open two consoles?
How to pass a log from management console to logging console. Example code is below:
if __name__ == '__main__':
try:
while True:
initialmyProgram()
print('Please press \'1\' key to stop program..\n')
print('Please press \'5\' key to resume program..\n')
print('Please press \'0\' key to exit program..\n')
isStart = raw_input('Please press a key that must be in above list..')
if isStart == 1:
parse.__is__process__ = False
elif isStart == 5:
parse.__is__process__ = True
elif isStart == 0 :
exit_program()
else:
continue
except Exception as ex:
logging.info('log..') #this log will write other console..
You don't really need two python consoles to accomplish this.
If you're using linux or a mac, open up a python console and a second terminal.
Then type this command in the second terminal:
tail -f path_to/filename_of_logfile
This will refresh the log file automatically.
An alternative solution if you absolutely cannot use files, is to use sockets to have to python programs communicate. Here's a link to get you started:
Python Sockets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With