2 # Copyright (C) 2015-2023 CEA, EDF, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # args=["--gui", "--show-desktop=1", "--splash=0"]
26 # args=["--terminal","--modules=FIELDS,PARAVIS,GUI"]
31 KernelBasis.setSSLMode(False)
40 def start(shutdown_servers=False, with_gui=False, args=[]):
42 log = tempfile.NamedTemporaryFile(suffix='_nsport', delete=True)
45 port_log = port_log + "-%s.log"%(os.getpid())
47 "--ns-port-log=%s"%port_log,
48 "--shutdown-servers=%d"%shutdown_servers
51 salome_instance = SalomeInstance()
52 salome_instance.__run(args=instance_args, with_gui=with_gui)
55 with open(port_log) as f:
56 salome_instance.port = int(f.readline())
61 return salome_instance
64 def __run(self, args=None, with_gui=False):
68 sys.argv = ['runSalomeOld'] + args
71 # :WARNING: NOT TESTED YET
73 sys.argv += ["--show-desktop=1"]
74 sys.argv += ["--splash=0"]
75 #sys.argv += ["--standalone=study"]
76 #sys.argv += ["--embedded=SalomeAppEngine,cppContainer,registry,moduleCatalog"]
78 sys.argv += ["--terminal"]
79 #sys.argv += ["--shutdown-servers=1"]
80 #sys.argv += ["--modules=FIELDS,PARAVIS,GUI"]
86 runSalomeOld.runSalome()
91 session_server = salome.naming_service.Resolve('/Kernel/Session')
93 session_server.emitMessage("connect_to_study")
94 session_server.emitMessage("activate_viewer/ParaView")
99 from multiprocessing import Process
100 from killSalomeWithPort import killMyPort
102 with tempfile.NamedTemporaryFile():
103 p = Process(target = killMyPort, args=(self.port,))
111 if __name__ == "__main__":
112 print("##### Start instance...")
113 salome_instance = SalomeInstance.start()
114 port = salome_instance.get_port()
115 print("##### ...instance started on port %s"%port)
117 print("##### Terminate instance running on port %s"%port)
118 salome_instance.stop()