Run terminal from Python program

0

I am doing a distributed systems job, in which I am using PYRO, in it I am using objeto.adapter.rebindURI() to use the same object when the server that was (downed) is "restarted" ...

I want this restart to be from my Python program ... in case I thought about calling a new window and running my server program ...

Does anyone know how to do it? I tried N times and I could not. It gives the following error:

Traceback (most recent call last):
  File "serverApp.py", line 7, in <module>
    subprocess.Popen(cmd, stdout=subprocess.PIPE)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",
line 710, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",
line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

I've tried something like this ...

import subprocess

cmd = ["xterm"]

cmd.extend(['-e','bash','-c','python serverApp.py; exec $SHELL'])
    
asked by anonymous 21.05.2018 / 16:41

2 answers

0

Apparently you do not have xterm installed on your machine.

I believe that you should be trying to give a subprocess.call in cmd, the command that is executed will be:

$ xterm -e bash -c python serverApp.py; exec $SHELL

Try running this at your command prompt and you'll probably see the same problem.

I did not understand why you would run xterm before. Try to run python directly and see if the problem is not resolved.

Ex:

python> subprocess.call(['python', 'serverApp.py'])

    
21.05.2018 / 19:29
0

If xterm is installed, the best way to ensure it is running is to pass its absolute path to the subprocess.

To find the absolute path:

~ which xterm
/usr/bin/xterm

Include this way in Python Subprocess:

import subprocess
cmd = ["/usr/bin/xterm"]
    
23.05.2018 / 20:10