From: adam Date: Fri, 1 Apr 2011 14:49:45 +0000 (+0000) Subject: Launch salome foreground when gui is activated. X-Git-Tag: Start_BR_19998_21191 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=107331dd3c7e00bfa60abccb929bbcce642bbebb;p=modules%2Fkernel.git Launch salome foreground when gui is activated. Ctrl-c, everything is cleaned IAPP crashes, everything is cleaned kill -9 runSalome*, everything is cleaned runSalome & ; kill %1, everything is cleaned --- diff --git a/bin/runSalome.py b/bin/runSalome.py index 7d220a7cd..7cdde509e 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -467,6 +467,7 @@ def startSalome(args, modules_list, modules_root_dir): sys.stdout.flush() return clt session.GetInterface() + args["session_object"] = session return clt # Save Naming service port name into @@ -618,6 +619,7 @@ def startSalome(args, modules_list, modules_root_dir): session=clt.waitNS("/Kernel/Session",SALOME.Session) else: session=clt.waitNSPID("/Kernel/Session",mySessionServ.PID,SALOME.Session) + args["session_object"] = session end_time = os.times() if verbose(): print print "Start SALOME, elapsed time : %5.1f seconds"% (end_time[4] @@ -943,7 +945,73 @@ def main(): # ----------------------------------------------------------------------------- +def foreGround(clt, args): + # -- + if "session_object" not in args: + return + session = args["session_object"] + # -- + # Wait until gui is arrived + # tmax = nbtot * dt + # -- + gui_detected = False + dt = 0.1 + nbtot = 100 + nb = 0 + while 1: + try: + status = session.GetStatSession() + gui_detected = status.activeGUI + except: + pass + if gui_detected: + break + from time import sleep + sleep(dt) + nb += 1 + if nb == nbtot: + break + pass + # -- + if not gui_detected: + return + # -- + from salome_utils import getPortNumber + port = getPortNumber() + # -- + server = Server({}) + server.CMD = ["killSalomeWithPort.py", "--spy", "%s"%(os.getpid()), "%s"%(port)] + server.run() + # os.system("killSalomeWithPort.py --spy %s %s &"%(os.getpid(), port)) + # -- + dt = 1.0 + try: + while 1: + try: + status = session.GetStatSession() + assert status.activeGUI + except: + break + from time import sleep + sleep(dt) + pass + pass + except KeyboardInterrupt: + from killSalomeWithPort import killMyPort + killMyPort(port) + pass + return + +# ----------------------------------------------------------------------------- + if __name__ == "__main__": import user clt,args = main() + # -- + test = args['gui'] and args['session_gui'] + test = test or args['wake_up_session'] + if test: + foreGround(clt, args) + pass + # -- pass