2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 # \brief Module that provides services to launch SALOME
29 import sys, os, string, glob, time, pickle, re
33 from launchConfigureParser import verbose
34 from server import process_id
36 if sys.platform == "win32":
41 # -----------------------------------------------------------------------------
43 from killSalome import killAllPorts
47 kill servers from a previous SALOME exection, if needed,
48 on the CORBA port given in args of runSalome
51 from killSalomeWithPort import killMyPort
52 my_port=str(args['port'])
56 print "problem in killLocalPort()"
60 def givenPortKill(port):
62 kill servers from a previous SALOME exection, if needed,
63 on the same CORBA port
66 from killSalomeWithPort import killMyPort
71 print "problem in LocalPortKill(), killMyPort("<<port<<")"
75 def kill_salome(args):
77 Kill servers from previous SALOME executions, if needed;
78 depending on args 'killall' or 'portkill', kill all executions,
79 or only execution on the same CORBA port
84 elif args['portkill']:
85 givenPortKill(str(args['port']))
87 # -----------------------------------------------------------------------------
89 # Class definitions to launch CORBA Servers
92 class InterpServer(Server):
93 def __init__(self,args):
95 if sys.platform != "win32":
96 env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
97 self.CMD=['xterm', '-e']+ env_ld_library_path + ['python']
99 self.CMD=['cmd', '/c', 'start cmd.exe', '/K', 'python']
104 print "INTERPSERVER::command = ", command
105 if sys.platform == "win32":
107 pid = win32pm.spawnpid( string.join(command, " "),'-nc' )
109 pid = os.spawnvp(os.P_NOWAIT, command[0], command)
110 process_id[pid]=self.CMD
115 def get_cata_path(list_modules,modules_root_dir):
116 """Build a list of catalog paths (cata_path) to initialize the ModuleCatalog server
121 for module in list_modules:
122 if modules_root_dir.has_key(module):
123 module_root_dir=modules_root_dir[module]
124 module_cata=module+"Catalog.xml"
125 cata_file=os.path.join(module_root_dir, "share",setenv.salome_subdir, "resources",module.lower(), module_cata)
127 if os.path.exists(cata_file):
128 cata_path.append(cata_file)
129 modules_cata[module]=cata_file
131 cata_file=os.path.join(module_root_dir, "share",setenv.salome_subdir, "resources", module_cata)
132 if os.path.exists(cata_file):
133 cata_path.append(cata_file)
134 modules_cata[module]=cata_file
136 for path in os.getenv("SALOME_CATALOGS_PATH","").split(SEP):
137 if os.path.exists(path):
138 for cata_file in glob.glob(os.path.join(path,"*Catalog.xml")):
139 module_name= os.path.basename(cata_file)[:-11]
140 if not modules_cata.has_key(module_name):
141 cata_path.append(cata_file)
142 modules_cata[module_name]=cata_file
148 class CatalogServer(Server):
149 def __init__(self,args):
152 self.SCMD1=['SALOME_ModuleCatalog_Server','-common']
154 home_dir=os.getenv('HOME')
155 if home_dir is not None:
156 self.SCMD2=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')]
158 def setpath(self,modules_list,modules_root_dir):
159 list_modules = modules_list[:]
160 list_modules.reverse()
161 if self.args["gui"] :
162 list_modules = ["KERNEL", "GUI"] + list_modules
164 list_modules = ["KERNEL"] + list_modules
166 cata_path=get_cata_path(list_modules,modules_root_dir)
168 self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2
172 class SalomeDSServer(Server):
173 def __init__(self,args):
176 self.CMD=['SALOMEDS_Server']
180 class ConnectionManagerServer(Server):
181 def __init__(self,args):
184 self.CMD=['SALOME_ConnectionManagerServer']
188 class RegistryServer(Server):
189 def __init__(self,args):
192 self.CMD=['SALOME_Registry_Server', '--salome_session','theSession']
196 class ContainerCPPServer(Server):
197 def __init__(self,args):
200 self.CMD=['SALOME_Container','FactoryServer']
204 class ContainerPYServer(Server):
205 def __init__(self,args):
208 if sys.platform == "win32":
209 self.CMD=[os.environ["PYTHONBIN"], '\"'+os.environ["KERNEL_ROOT_DIR"] + '/bin/salome/SALOME_ContainerPy.py'+'\"','FactoryServerPy']
211 self.CMD=['SALOME_ContainerPy.py','FactoryServerPy']
215 class LoggerServer(Server):
216 def __init__(self,args):
219 from salome_utils import generateFileName
220 if sys.platform == "win32": dirpath = os.environ["HOME"]
221 else: dirpath = "/tmp"
222 logfile = generateFileName( dirpath,
228 print "==========================================================="
229 print "Logger server: put log to the file:"
231 print "==========================================================="
232 self.CMD=['SALOME_Logger_Server', logfile]
234 pass # end of LoggerServer class
238 class SessionServer(Server):
239 def __init__(self,args,modules_list,modules_root_dir):
240 self.args = args.copy()
241 # Bug 11512 (Problems with runSalome --xterm on Mandrake and Debian Sarge)
242 #self.args['xterm']=0
245 self.SCMD1=['SALOME_Session_Server']
247 if 'registry' in self.args['embedded']:
248 self.SCMD1+=['--with','Registry',
249 '(','--salome_session','theSession',')']
250 if 'moduleCatalog' in self.args['embedded']:
251 self.SCMD1+=['--with','ModuleCatalog','(','-common']
252 home_dir=os.getenv('HOME')
253 if home_dir is not None:
254 self.SCMD2+=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')]
256 if 'study' in self.args['embedded']:
257 self.SCMD2+=['--with','SALOMEDS','(',')']
258 if 'cppContainer' in self.args['embedded']:
259 self.SCMD2+=['--with','Container','(','FactoryServer',')']
260 if 'SalomeAppEngine' in self.args['embedded']:
261 self.SCMD2+=['--with','SalomeAppEngine','(',')']
263 if 'cppContainer' in self.args['standalone'] or 'cppContainer' in self.args['embedded']:
265 if 'pyContainer' in self.args['standalone'] or 'pyContainer' in self.args['embedded']:
269 if self.args.has_key('session_gui'):
270 session_gui = self.args['session_gui']
273 if self.args['splash']:
274 self.SCMD2+=['SPLASH']
276 if self.args['study_hdf'] is not None:
277 self.SCMD2+=['--study-hdf=%s'%self.args['study_hdf']]
281 if self.args['noexcepthandler']:
282 self.SCMD2+=['noexcepthandler']
283 if self.args.has_key('user_config'):
284 self.SCMD2+=['--resources=%s'%self.args['user_config']]
285 if self.args.has_key('modules'):
287 #keep only modules with GUI
288 for m in modules_list:
289 fr1 = os.path.join(modules_root_dir[m],"share","salome","resources",m.lower(),"SalomeApp.xml")
290 fr2 = os.path.join(modules_root_dir[m],"share","salome","resources","SalomeApp.xml")
291 if os.path.exists(fr1) or os.path.exists(fr2):
292 list_modules.insert(0,m)
293 self.SCMD2+=['--modules (%s)' % ":".join(list_modules)]
295 if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0:
296 self.SCMD2+=['--pyscript=%s'%(",".join(self.args['pyscript']))]
298 def setpath(self,modules_list,modules_root_dir):
299 list_modules = modules_list[:]
300 list_modules.reverse()
301 if self.args["gui"] :
302 list_modules = ["KERNEL", "GUI"] + list_modules
304 list_modules = ["KERNEL"] + list_modules
306 cata_path=get_cata_path(list_modules,modules_root_dir)
308 if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']):
309 #Use '::' instead ":" because drive path with "D:\" is invalid on windows platform
310 self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2
312 self.CMD=self.SCMD1 + self.SCMD2
313 if self.args.has_key('test'):
314 self.CMD+=['-test'] + self.args['test']
315 elif self.args.has_key('play'):
316 self.CMD+=['-play'] + self.args['play']
318 if self.args["gdb_session"] or self.args["ddd_session"]:
319 f = open(".gdbinit4salome", "w")
321 args = " ".join(self.CMD[1:])
322 args = args.replace("(", "\(")
323 args = args.replace(")", "\)")
327 if self.args["ddd_session"]:
328 self.CMD = ["ddd", "--command=.gdbinit4salome", self.CMD[0]]
329 elif self.args["gdb_session"]:
330 self.CMD = ["xterm", "-e", "gdb", "--command=.gdbinit4salome", self.CMD[0]]
334 if self.args["valgrind_session"]:
336 val = os.getenv("VALGRIND_OPTIONS")
340 self.CMD = l + self.CMD
345 class LauncherServer(Server):
346 def __init__(self,args):
349 self.SCMD1=['SALOME_LauncherServer']
352 if 'registry' in self.args['embedded']:
353 self.SCMD1+=['--with','Registry',
354 '(','--salome_session','theSession',')']
355 if 'moduleCatalog' in self.args['embedded']:
356 self.SCMD1+=['--with','ModuleCatalog','(','-common']
357 self.SCMD2+=['-personal',
358 '${HOME}/Salome/resources/CatalogModulePersonnel.xml',')']
359 if 'study' in self.args['embedded']:
360 self.SCMD2+=['--with','SALOMEDS','(',')']
361 if 'cppContainer' in self.args['embedded']:
362 self.SCMD2+=['--with','Container','(','FactoryServer',')']
364 def setpath(self,modules_list,modules_root_dir):
365 list_modules = modules_list[:]
366 list_modules.reverse()
367 if self.args["gui"] :
368 list_modules = ["KERNEL", "GUI"] + list_modules
370 list_modules = ["KERNEL"] + list_modules
372 cata_path=get_cata_path(list_modules,modules_root_dir)
374 if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']):
375 #Use '::' instead ":" because drive path with "D:\" is invalid on windows platform
376 self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2
378 self.CMD=self.SCMD1 + self.SCMD2
380 class NotifyServer(Server):
381 def __init__(self,args,modules_root_dir):
384 self.modules_root_dir=modules_root_dir
385 myLogName = os.environ["LOGNAME"]
386 self.CMD=['notifd','-c',
387 self.modules_root_dir["KERNEL"] +'/share/salome/resources/kernel/channel.cfg',
388 '-DFactoryIORFileName=/tmp/'+myLogName+'_rdifact.ior',
389 '-DChannelIORFileName=/tmp/'+myLogName+'_rdichan.ior',
390 '-DReportLogFile=/tmp/'+myLogName+'_notifd.report',
391 '-DDebugLogFile=/tmp/'+myLogName+'_notifd.debug',
395 # -----------------------------------------------------------------------------
398 """Salome Session Graphic User Interface activation"""
402 import SALOME_ModuleCatalog
403 import SALOME_Session_idl
404 session=clt.waitNS("/Kernel/Session",SALOME.Session)
405 session.GetInterface()
407 # -----------------------------------------------------------------------------
409 def startSalome(args, modules_list, modules_root_dir):
410 """Launch all SALOME servers requested by args"""
411 init_time = os.times()
413 if verbose(): print "startSalome ", args
416 # Wake up session option
418 if args['wake_up_session']:
419 if "OMNIORB_CONFIG" not in os.environ:
420 from salome_utils import generateFileName
421 home = os.getenv("HOME")
422 appli = os.getenv("APPLI")
424 if appli is not None:
425 home = os.path.join(home, appli,"USERS")
426 kwargs["with_username"] = True
428 last_running_config = generateFileName(home, prefix="omniORB",
433 os.environ['OMNIORB_CONFIG'] = last_running_config
438 # Initialisation ORB and Naming Service
441 clt=orbmodule.client(args)
444 # Wake up session option
446 if args['wake_up_session']:
450 import SALOME_ModuleCatalog
451 import SALOME_Session_idl
452 session = clt.waitNS("/Kernel/Session",SALOME.Session)
453 status = session.GetStatSession()
455 msg = "Session GUI is already active"
457 session.GetInterface()
460 # Save Naming service port name into
461 # the file args["ns_port_log_file"]
462 if args.has_key('ns_port_log_file'):
463 home = os.environ['HOME']
464 appli= os.environ.get("APPLI")
465 if appli is not None:
466 home='%s/%s'%(home,appli)
468 file_name= '%s/%s'%(home, args["ns_port_log_file"])
469 f = open(file_name, "w")
470 f.write(os.environ['NSPORT'])
473 # Launch Logger Server (optional)
474 # and wait until it is registered in naming service
478 myServer=LoggerServer(args)
480 clt.waitLogger("Logger")
482 # Notify Server launch
485 if sys.platform != "win32":
486 if verbose(): print "Notify Server to launch"
488 myServer=NotifyServer(args,modules_root_dir)
491 # Launch Session Server (to show splash ASAP)
495 mySessionServ = SessionServer(args,modules_list,modules_root_dir)
496 mySessionServ.setpath(modules_list,modules_root_dir)
500 # Launch Registry Server,
501 # and wait until it is registered in naming service
504 if ('registry' not in args['embedded']) | (args["gui"] == 0) :
505 myServer=RegistryServer(args)
507 if sys.platform == "win32":
508 clt.waitNS("/Registry")
510 clt.waitNSPID("/Registry",myServer.PID)
513 # Launch Catalog Server,
514 # and wait until it is registered in naming service
517 if ('moduleCatalog' not in args['embedded']) | (args["gui"] == 0):
518 cataServer=CatalogServer(args)
519 cataServer.setpath(modules_list,modules_root_dir)
521 import SALOME_ModuleCatalog
522 if sys.platform == "win32":
523 clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
525 clt.waitNSPID("/Kernel/ModulCatalog",cataServer.PID,SALOME_ModuleCatalog.ModuleCatalog)
528 # Launch SalomeDS Server,
529 # and wait until it is registered in naming service
532 #print "ARGS = ",args
533 if ('study' not in args['embedded']) | (args["gui"] == 0):
535 myServer=SalomeDSServer(args)
537 if sys.platform == "win32":
538 clt.waitNS("/myStudyManager")
540 clt.waitNSPID("/myStudyManager",myServer.PID)
543 # Launch LauncherServer
546 myCmServer = LauncherServer(args)
547 myCmServer.setpath(modules_list,modules_root_dir)
551 # Launch ConnectionManagerServer
554 myConnectionServer = ConnectionManagerServer(args)
555 myConnectionServer.run()
558 from Utils_Identity import getShortHostName
560 if os.getenv("HOSTNAME") == None:
561 if os.getenv("HOST") == None:
562 os.environ["HOSTNAME"]=getShortHostName()
564 os.environ["HOSTNAME"]=os.getenv("HOST")
566 theComputer = getShortHostName()
569 # Launch local C++ Container (FactoryServer),
570 # and wait until it is registered in naming service
573 if ('cppContainer' in args['standalone']) | (args["gui"] == 0) :
574 myServer=ContainerCPPServer(args)
576 if sys.platform == "win32":
577 clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
579 clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID)
582 # Launch local Python Container (FactoryServerPy),
583 # and wait until it is registered in naming service
586 if 'pyContainer' in args['standalone']:
587 myServer=ContainerPYServer(args)
589 if sys.platform == "win32":
590 clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
592 clt.waitNSPID("/Containers/" + theComputer + "/FactoryServerPy",myServer.PID)
595 # Wait until Session Server is registered in naming service
603 import SALOME_ModuleCatalog
604 import SALOME_Session_idl
605 if sys.platform == "win32":
606 session=clt.waitNS("/Kernel/Session",SALOME.Session)
608 session=clt.waitNSPID("/Kernel/Session",mySessionServ.PID,SALOME.Session)
609 end_time = os.times()
611 print "Start SALOME, elapsed time : %5.1f seconds"% (end_time[4]
614 # ASV start GUI without Loader
616 # session.GetInterface()
619 # additionnal external python interpreters
625 nbaddi = args['interp']
628 traceback.print_exc()
629 print "-------------------------------------------------------------"
630 print "-- to get an external python interpreter:runSalome --interp=1"
631 print "-------------------------------------------------------------"
633 print "additional external python interpreters: ", nbaddi
635 for i in range(nbaddi):
637 anInterp=InterpServer(args)
640 # set PYTHONINSPECT variable (python interpreter in interactive mode)
642 os.environ["PYTHONINSPECT"]="1"
650 # -----------------------------------------------------------------------------
652 def useSalome(args, modules_list, modules_root_dir):
654 Launch all SALOME servers requested by args,
655 save list of process, give info to user,
656 show registered objects in Naming Service.
662 clt = startSalome(args, modules_list, modules_root_dir)
665 traceback.print_exc()
668 print "--- Error during Salome launch ---"
672 from addToKillList import addToKillList
673 from killSalomeWithPort import getPiDict
675 filedict = getPiDict(args['port'])
676 for pid, cmd in process_id.items():
677 addToKillList(pid, cmd, args['port'])
680 if verbose(): print """
681 Saving of the dictionary of Salome processes in %s
682 To kill SALOME processes from a console (kill all sessions from all ports):
684 To kill SALOME from the present interpreter, if it is not closed :
685 killLocalPort() --> kill this session
686 (use CORBA port from args of runSalome)
687 givenPortKill(port) --> kill a specific session with given CORBA port
688 killAllPorts() --> kill all sessions
690 runSalome, with --killall option, starts with killing
691 the processes resulting from the previous execution.
695 # Print Naming Service directory list
701 print " --- registered objects tree in Naming Service ---"
705 if not args['gui'] or not args['session_gui']:
706 if args['shutdown_servers']:
707 class __utils__(object):
708 def __init__(self, port):
710 import killSalomeWithPort
711 self.killSalomeWithPort = killSalomeWithPort
714 self.killSalomeWithPort.killMyPort(self.port)
717 args['shutdown_servers'] = __utils__(args['port'])
721 # run python scripts, passed via --execute option
723 if args.has_key('pyscript'):
724 if args.has_key('gui') and args.has_key('session_gui'):
725 if not args['gui'] or not args['session_gui']:
726 toimport = args['pyscript']
728 for srcname in toimport :
729 if srcname == 'killall':
734 if os.path.isabs(srcname):
735 if os.path.exists(srcname):
737 elif os.path.exists(srcname+".py"):
738 execScript(srcname+".py")
740 print "Can't execute file %s" % srcname
744 for path in [os.getcwd()] + sys.path:
745 if os.path.exists(os.path.join(path,srcname)):
746 execScript(os.path.join(path,srcname))
749 elif os.path.exists(os.path.join(path,srcname+".py")):
750 execScript(os.path.join(path,srcname+".py"))
755 print "Can't execute file %s" % srcname
763 def execScript(script_path):
764 print 'executing', script_path
765 sys.path.insert(0, os.path.dirname(script_path))
766 execfile(script_path,globals())
769 # -----------------------------------------------------------------------------
771 def registerEnv(args, modules_list, modules_root_dir):
773 Register args, modules_list, modules_root_dir in a file
774 for further use, when SALOME is launched embedded in an other application.
776 if sys.platform == "win32":
777 fileEnv = os.getenv('TEMP')
781 fileEnv += os.getenv('USER') + "_" + str(args['port']) \
782 + '_' + args['appname'].upper() + '_env'
783 fenv=open(fileEnv,'w')
784 pickle.dump((args, modules_list, modules_root_dir),fenv)
786 os.environ["SALOME_LAUNCH_CONFIG"] = fileEnv
788 # -----------------------------------------------------------------------------
790 def searchFreePort(args, save_config=1):
791 print "Searching for a free port for naming service:",
793 if sys.platform == "win32":
794 tmp_file = os.getenv('TEMP');
797 tmp_file = os.path.join(tmp_file, '.netstat_%s'%os.getpid())
799 ###status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT))
800 os.system( "netstat -a -n > %s" % tmp_file );
801 f = open( tmp_file, 'r' );
802 ports = f.readlines();
804 os.remove( tmp_file );
806 def portIsUsed(port, data):
807 regObj = re.compile( ".*tcp.*:([0-9]+).*:.*listen", re.IGNORECASE );
810 p = int(regObj.match(item).group(1))
811 if p == port: return True
822 if not portIsUsed(NSPORT, ports):
823 print "%s - OK"%(NSPORT)
825 from salome_utils import generateFileName, getHostName
826 hostname = getHostName()
828 home = os.getenv("HOME")
829 appli = os.getenv("APPLI")
831 if appli is not None:
832 home = os.path.join(home, appli,"USERS")
833 kwargs["with_username"]=True
835 omniorb_config = generateFileName(home, prefix="omniORB",
842 initref = "NameService=corbaname::%s:%s"%(hostname, NSPORT)
843 from omniORB import CORBA
844 if CORBA.ORB_ID == "omniORB4":
845 orbdata.append("InitRef = %s"%(initref))
846 orbdata.append("giopMaxMsgSize = 2097152000 # 2 GBytes")
847 orbdata.append("traceLevel = 0 # critical errors only")
849 orbdata.append("ORBInitRef %s"%(initref))
850 orbdata.append("ORBgiopMaxMsgSize = 2097152000 # 2 GBytes")
851 orbdata.append("ORBtraceLevel = 0 # critical errors only")
854 f = open(omniorb_config, "w")
855 f.write("\n".join(orbdata))
858 os.environ['OMNIORB_CONFIG'] = omniorb_config
859 os.environ['NSPORT'] = "%s"%(NSPORT)
860 os.environ['NSHOST'] = "%s"%(hostname)
861 args['port'] = os.environ['NSPORT']
864 last_running_config = generateFileName(home, prefix="omniORB",
870 if sys.platform == "win32":
872 shutil.copyfile(omniorb_config, last_running_config)
875 os.remove(last_running_config)
878 os.symlink(omniorb_config, last_running_config)
887 msg += "Can't find a free port to launch omniNames\n"
888 msg += "Try to kill the running servers and then launch SALOME again.\n"
889 raise RuntimeError, msg
894 # -----------------------------------------------------------------------------
897 """Salome Launch, when embedded in other application"""
898 fileEnv = os.environ["SALOME_LAUNCH_CONFIG"]
899 fenv=open(fileEnv,'r')
900 args, modules_list, modules_root_dir = pickle.load(fenv)
903 searchFreePort(args, 0)
904 clt = useSalome(args, modules_list, modules_root_dir)
907 # -----------------------------------------------------------------------------
910 """Salome launch as a main application"""
911 from salome_utils import getHostName
912 print "runSalome running on %s" % getHostName()
913 args, modules_list, modules_root_dir = setenv.get_config()
916 if args.has_key('save_config'):
917 save_config = args['save_config']
920 if args['wake_up_session']:
924 searchFreePort(args, save_config)
928 setenv.set_env(args, modules_list, modules_root_dir)
929 clt = useSalome(args, modules_list, modules_root_dir)
932 # -----------------------------------------------------------------------------
934 if __name__ == "__main__":