5

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.

  1. How can I open two consoles?

  2. 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..
3
  • No, i have two module. Commented 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? Commented Jul 1, 2013 at 13:45
  • yes,exactly i want you say. Commented Jul 1, 2013 at 13:49

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

4 Comments

I don't want to write log in a file. I only will show log in console. And i am on windows.
Edited the answer to include how to do this without files.
I thought it is easy problem :)
Files are a fairly straightforward solution to this. There are a thousand other ways to skin this problem but files are the easiest way to go about doing it in my opinion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.