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..
-
No, i have two module.hinzir– hinzir2013年07月01日 13:39:14 +00:00Commented Jul 1, 2013 at 13:39
-
I am not sure if this is even possible. You want to start a program from the terminal and you want it to open an extra terminal for you?OptimusCrime– OptimusCrime2013年07月01日 13:45:21 +00:00Commented Jul 1, 2013 at 13:45
-
yes,exactly i want you say.hinzir– hinzir2013年07月01日 13:49:49 +00:00Commented Jul 1, 2013 at 13:49
1 Answer 1
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: