import ServerClass import subprocess import sys import os def restart_program(): """Restarts the current program. Note: this function does not return. Any cleanup action (like saving data) must be done before calling this function.""" python = sys.executable os.execl(python, python, * sys.argv) while 1: server = ServerClass.ServerHandler(34600) tried = server.openSocket() test = server.receiveData(2) if test == 'START APP': print 'start' subprocess.Popen(args=['gnome-terminal','--command= python /home/gsmselftest/gsm-selftest/For\ Weekly\ Test/tricode/gsmselftest-website2.py']) print server.closeConnection() del server restart_program()