def btn_callback(self): if not self.is_connected: # Attempt to connect - check that the port is still connected if self.comports.get() in PortManager.serial_ports(): # Port is still up n runnin' self.btn["text"] = "Disconnect" self.comports.config(state="disabled") # Connect to the Arduino and start processing self.msg_handler = Thread(target=MessageHandler.message_handler, args=(self.comports.get(),)) self.msg_handler.start() # Change da flag fool! self.is_connected = True else: # Port not found - refresh list self.load_ports() else: # Disconnect from Arduino MessageHandler.stop_handler() self.msg_handler.join() # Change the flag BACK! self.is_connected = False # Disconnect. Refresh port list self.btn["text"] = "Connect" self.comports.config(state="enabled") self.load_ports()
def load_ports(self): # Load all comports in pc. Select first item in the list if exists self.comports['values'] = PortManager.serial_ports() if len(self.comports['values']) > 0: self.comports.current(0) else: self.comports.set("")
def _killAll(self, unused=None): try: import PortManager # mandatory from multiprocessing import Process from killSalomeWithPort import killMyPort ports = PortManager.getBusyPorts() if ports: import tempfile for port in ports: with tempfile.NamedTemporaryFile(): p = Process(target = killMyPort, args=(port,)) p.start() p.join() except ImportError: # :TODO: should be declared obsolete from killSalome import killAllPorts killAllPorts() pass
def _killAll(self, unused=None): try: import PortManager # mandatory from multiprocessing import Process from killSalomeWithPort import killMyPort ports = PortManager.getBusyPorts() if ports: import tempfile for port in ports: with tempfile.NamedTemporaryFile(): p = Process(target=killMyPort, args=(port, )) p.start() p.join() except ImportError: # :TODO: should be declared obsolete from killSalome import killAllPorts killAllPorts() pass
def _showInfo(self, args=None): if args is None: args = [] usage = "Usage: salome info [options]" epilog = """\n Display some information about SALOME.\n Available options are: -p,--ports Show the list of busy ports (running SALOME instances). -s,--softwares [software(s)] Show the list and versions of SALOME softwares. Software names must be separated by blank characters. If no software is given, show version of all softwares. -v,--version Show running SALOME version. -h,--help Show this message. """ if not args: args = ["--version"] if "-h" in args or "--help" in args: print usage + epilog return if "-p" in args or "--ports" in args: import PortManager ports = PortManager.getBusyPorts() print "SALOME instances are running on ports:", ports if ports: print "Last started instance on port %s"%ports[-1] if "-s" in args or "--softwares" in args: if "-s" in args: index = args.index("-s") else: index = args.index("--softwares") indexEnd=index+1 while indexEnd < len(args) and args[indexEnd][0] != "-": indexEnd = indexEnd + 1 self._showSoftwareVersions(softwares=args[index+1:indexEnd]) if "-v" in args or "--version" in args: print "Running with python", platform.python_version() self._runAppli(["--version"])
def _showInfo(self, args=None): if args is None: args = [] usage = "Usage: salome info [options]" epilog = """\n Display some information about SALOME.\n Available options are: -p,--ports Show the list of busy ports (running SALOME instances). -s,--softwares [software(s)] Show the list and versions of SALOME softwares. Software names must be separated by blank characters. If no software is given, show version of all softwares. -v,--version Show running SALOME version. -h,--help Show this message. """ if not args: args = ["--version"] if "-h" in args or "--help" in args: print usage + epilog return if "-p" in args or "--ports" in args: import PortManager ports = PortManager.getBusyPorts() print "SALOME instances are running on ports:", ports if ports: print "Last started instance on port %s" % ports[-1] if "-s" in args or "--softwares" in args: if "-s" in args: index = args.index("-s") else: index = args.index("--softwares") indexEnd = index + 1 while indexEnd < len(args) and args[indexEnd][0] != "-": indexEnd = indexEnd + 1 self._showSoftwareVersions(softwares=args[index + 1:indexEnd]) if "-v" in args or "--version" in args: print "Running with python", platform.python_version() self._runAppli(["--version"])
class authenticationServer: def GET(self, userName, password): objShelve = shelve.open("authenticationDirectory.dat") val = objShelve[userName] if objShelve[userName] == password: print(val + "............" + password) return "login successful" else: return "wrong credentials" def POST(self, userName, password): objShelve = shelve.open("authenticationDirectory.dat") key = list(objShelve.keys()) if userName in key: return "Username already present" else: objShelve[userName] = password return userName + "successfully registered" if __name__ == "__main__": app = PortManager.changePort(urls, globals()) app.run(port=8084)
class directoryServer: def GET(self, fileName): try: value = "" objShelve = shelve.open("Directory_names.dat") keys = list(objShelve.keys()) if fileName == "*": for items in keys: value = value + "\n" + items elif fileName in keys: # print(type(objShelve["fileName"])) value = objShelve[fileName] else: value = "Nothing Found " except KeyError: print("Error in Keyss") except: print("Something Else") finally: objShelve.close() return value if __name__ == "__main__": app = PortManager.changePort(urls, globals()) app.run(port=8081)
def get_env(theAdditionalOptions=None, appname=salomeappname, cfgname=salomecfgname, exeName=None): ### # Collect launch configuration files: # - The environment variable "<appname>Config" (SalomeAppConfig) which can # define a list of directories (separated by ':' or ';' symbol) is checked # - If the environment variable "<appname>Config" is not set, only # ${GUI_ROOT_DIR}/share/salome/resources/gui is inspected # - ${GUI_ROOT_DIR}/share/salome/resources/gui directory is always inspected # so it is not necessary to put it in the "<appname>Config" variable # - The directories which are inspected are checked for files "<appname?salomeappname>.xml" # (SalomeApp.xml) which define SALOME configuration # - These directories are analyzed beginning from the last one in the list, # so the first directory listed in "<appname>Config" environment variable # has higher priority: it means that if some configuration options # is found in the next analyzed cofiguration file - it will be replaced # - The last configuration file which is parsed is user configuration file # situated in the home directory (if it exists): # * ~/.config/salome/.<appname>rc[.<version>]" for Linux (e.g. ~/.config/salome/.SalomeApprc.6.4.0) # * ~/<appname>.xml[.<version>] for Windows (e.g. ~/SalomeApp.xml.6.4.0) # - Command line options have the highest priority and replace options # specified in configuration file(s) ### if theAdditionalOptions is None: theAdditionalOptions = [] global args config_var = appname+'Config' # check KERNEL_ROOT_DIR kernel_root_dir = os.environ.get("KERNEL_ROOT_DIR", None) if kernel_root_dir is None: print """ For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set. KERNEL_ROOT_DIR is mandatory. """ sys.exit(1) ############################ # parse command line options pars = CreateOptionParser(theAdditionalOptions, exeName=exeName) (cmd_opts, cmd_args) = pars.parse_args(sys.argv[1:]) ############################ # Process --print-port option if cmd_opts.print_port: from searchFreePort import searchFreePort searchFreePort({}) print "port:%s"%(os.environ['NSPORT']) try: import PortManager PortManager.releasePort(os.environ['NSPORT']) except ImportError: pass sys.exit(0) pass # set resources variable SalomeAppConfig if it is not set yet dirs = [] if os.getenv(config_var): if sys.platform == 'win32': dirs += re.split(os.pathsep, os.getenv(config_var)) else: dirs += re.split('[;|:]', os.getenv(config_var)) gui_available = False if os.getenv("GUI_ROOT_DIR"): gui_resources_dir = os.path.join(os.getenv("GUI_ROOT_DIR"),'share','salome','resources','gui') if os.path.isdir( gui_resources_dir ): gui_available = True dirs.append(gui_resources_dir) pass if not gui_available: kernel_resources_dir = os.path.join(os.getenv("KERNEL_ROOT_DIR"),'bin','salome','appliskel') if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( kernel_resources_dir ): dirs.append(kernel_resources_dir) pass os.environ[config_var] = os.pathsep.join(dirs) dirs.reverse() # reverse order, like in "path" variable - FILO-style processing try: dirs.remove('') # to remove empty dirs if the variable terminate by ":" or if there are "::" inside except: pass _opts = {} # associative array of options to be filled # parse SalomeApp.xml files in directories specified by SalomeAppConfig env variable for dir in dirs: filename = os.path.join(dir, appname+'.xml') if not os.path.exists(filename): if verbose(): print "Configure parser: Warning : can not find configuration file %s" % filename else: try: p = xml_parser(filename, _opts, []) _opts = p.opts except: if verbose(): print "Configure parser: Error : can not read configuration file %s" % filename pass # parse user configuration file # It can be set via --resources=<file> command line option # or is given from default location (see defaultUserFile() function) # If user file for the current version is not found the nearest to it is used user_config = cmd_opts.resources if not user_config: user_config = userFile(appname, cfgname) if verbose(): print "Configure parser: user configuration file is", user_config if not user_config or not os.path.exists(user_config): if verbose(): print "Configure parser: Warning : can not find user configuration file" else: try: p = xml_parser(user_config, _opts, []) _opts = p.opts except: if verbose(): print 'Configure parser: Error : can not read user configuration file' user_config = "" args = _opts args['user_config'] = user_config #print "User Configuration file: ", args['user_config'] # set default values for options which are NOT set in config files for aKey in listKeys: if not args.has_key( aKey ): args[aKey] = [] for aKey in boolKeys: if not args.has_key( aKey ): args[aKey] = 0 if args[file_nam]: afile=args[file_nam] args[file_nam] = [afile] args[appname_nam] = appname # get the port number my_port = getPortNumber() args[port_nam] = my_port #################################################### # apply command-line options to the arguments # each option given in command line overrides the option from xml config file # # Options: gui, desktop, log_file, resources, # xterm, modules, embedded, standalone, # portkill, killall, interp, splash, # catch_exceptions, pinter # GUI/Terminal, Desktop, Splash, STUDY_HDF args["session_gui"] = False args[batch_nam] = False args["study_hdf"] = None if cmd_opts.gui is not None: args[gui_nam] = cmd_opts.gui if cmd_opts.batch is not None: args[batch_nam] = True if not gui_available: args[gui_nam] = False if args[gui_nam]: args["session_gui"] = True if cmd_opts.desktop is not None: args["session_gui"] = cmd_opts.desktop args[splash_nam] = cmd_opts.desktop if args["session_gui"]: if cmd_opts.splash is not None: args[splash_nam] = cmd_opts.splash else: args["session_gui"] = False args[splash_nam] = False # Logger/Log file if cmd_opts.log_file is not None: if cmd_opts.log_file == 'CORBA': args[logger_nam] = True else: args[file_nam] = [cmd_opts.log_file] # Naming Service port log file if cmd_opts.ns_port_log_file is not None: args["ns_port_log_file"] = cmd_opts.ns_port_log_file # Study files for arg in cmd_args: if arg[-4:] == ".hdf" and not args["study_hdf"]: args["study_hdf"] = arg # Python scripts from salomeContextUtils import getScriptsAndArgs, ScriptAndArgs args[script_nam] = getScriptsAndArgs(cmd_args) if args[gui_nam] and args["session_gui"]: new_args = [] for sa_obj in args[script_nam]: # args[script_nam] is a list of ScriptAndArgs objects script = re.sub(r'^python.*\s+', r'', sa_obj.script) new_args.append(ScriptAndArgs(script=script, args=sa_obj.args, out=sa_obj.out)) # args[script_nam] = new_args # xterm if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm # Modules if cmd_opts.modules is not None: args[modules_nam] = [] listlist = cmd_opts.modules for listi in listlist: args[modules_nam] += re.split( "[:;,]", listi) else: # if --modules (-m) command line option is not given # try SALOME_MODULES environment variable if os.getenv( "SALOME_MODULES" ): args[modules_nam] = re.split( "[:;,]", os.getenv( "SALOME_MODULES" ) ) pass # Embedded if cmd_opts.embedded is not None: args[embedded_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.embedded ) ) # Standalone if cmd_opts.standalone is not None: args[standalone_nam] = filter( lambda a: a.strip(), re.split( "[:;,]", cmd_opts.standalone ) ) # Normalize the '--standalone' and '--embedded' parameters standalone, embedded = process_containers_params( args.get( standalone_nam ), args.get( embedded_nam ) ) if standalone is not None: args[ standalone_nam ] = standalone if embedded is not None: args[ embedded_nam ] = embedded # Kill if cmd_opts.portkill is not None: args[portkill_nam] = cmd_opts.portkill if cmd_opts.killall is not None: args[killall_nam] = cmd_opts.killall # Interpreter if cmd_opts.interp is not None: args[interp_nam] = cmd_opts.interp # Exceptions if cmd_opts.catch_exceptions is not None: args[except_nam] = not cmd_opts.catch_exceptions # Relink config file if cmd_opts.save_config is not None: args['save_config'] = cmd_opts.save_config # Interactive python console if cmd_opts.pinter is not None: args[pinter_nam] = cmd_opts.pinter # Gdb session in xterm if cmd_opts.gdb_session is not None: args[gdb_session_nam] = cmd_opts.gdb_session # Ddd session in xterm if cmd_opts.ddd_session is not None: args[ddd_session_nam] = cmd_opts.ddd_session # valgrind session if cmd_opts.valgrind_session is not None: args[valgrind_session_nam] = cmd_opts.valgrind_session # Shutdown servers if cmd_opts.shutdown_servers is None: args[shutdown_servers_nam] = 0 else: args[shutdown_servers_nam] = cmd_opts.shutdown_servers pass # Foreground if cmd_opts.foreground is None: args[foreground_nam] = 1 else: args[foreground_nam] = cmd_opts.foreground pass # wake up session if cmd_opts.wake_up_session is not None: args[wake_up_session_nam] = cmd_opts.wake_up_session #################################################### # Add <theAdditionalOptions> values to args for add_opt in theAdditionalOptions: cmd = "args[\"{0}\"] = cmd_opts.{0}".format(add_opt.dest) exec(cmd) #################################################### # disable signals handling if args[except_nam] == 1: os.environ["NOT_INTERCEPT_SIGNALS"] = "1" pass # now modify SalomeAppConfig environment variable # to take into account the SALOME modules if os.sys.platform == 'win32': dirs = re.split('[;]', os.environ[config_var] ) else: dirs = re.split('[;|:]', os.environ[config_var] ) for module in args[modules_nam]: if module not in ["KERNEL", "GUI", ""] and os.getenv("{0}_ROOT_DIR".format(module)): d1 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)),"share","salome","resources",module.lower()) d2 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)),"share","salome","resources") #if os.path.exists( "%s/%s.xml"%(d1, appname) ): if os.path.exists( os.path.join(d1,"{0}.xml".format(salomeappname)) ): dirs.append( d1 ) #elif os.path.exists( "%s/%s.xml"%(d2, appname) ): elif os.path.exists( os.path.join(d2,"{0}.xml".format(salomeappname)) ): dirs.append( d2 ) else: #print "* '"+m+"' should be deleted from ",args[modules_nam] pass # Test if cmd_opts.test_script_file is not None: args[test_nam] = [] filename = cmd_opts.test_script_file args[test_nam] += re.split( "[:;,]", filename ) # Play if cmd_opts.play_script_file is not None: args[play_nam] = [] filename = cmd_opts.play_script_file args[play_nam] += re.split( "[:;,]", filename ) # Server launch command if cmd_opts.server_launch_mode is not None: args["server_launch_mode"] = cmd_opts.server_launch_mode # Server launch command if cmd_opts.use_port is not None: min_port = 2810 max_port = min_port + 100 if cmd_opts.use_port not in xrange(min_port, max_port+1): print "Error: port number should be in range [%d, %d])" % (min_port, max_port) sys.exit(1) args[useport_nam] = cmd_opts.use_port if cmd_opts.language is not None: langs = args["language_languages"] if "language_languages" in args else [] if cmd_opts.language not in langs: print "Error: unsupported language: %s" % cmd_opts.language sys.exit(1) args[lang_nam] = cmd_opts.language # return arguments os.environ[config_var] = os.pathsep.join(dirs) #print "Args: ", args return args
def get_env(theAdditionalOptions=None, appname=salomeappname, cfgname=salomecfgname, exeName=None): ### # Collect launch configuration files: # - The environment variable "<appname>Config" (SalomeAppConfig) which can # define a list of directories (separated by ':' or ';' symbol) is checked # - If the environment variable "<appname>Config" is not set, only # ${GUI_ROOT_DIR}/share/salome/resources/gui is inspected # - ${GUI_ROOT_DIR}/share/salome/resources/gui directory is always inspected # so it is not necessary to put it in the "<appname>Config" variable # - The directories which are inspected are checked for files "<appname?salomeappname>.xml" # (SalomeApp.xml) which define SALOME configuration # - These directories are analyzed beginning from the last one in the list, # so the first directory listed in "<appname>Config" environment variable # has higher priority: it means that if some configuration options # is found in the next analyzed cofiguration file - it will be replaced # - The last configuration file which is parsed is user configuration file # situated in the home directory (if it exists): # * ~/.config/salome/.<appname>rc[.<version>]" for Linux (e.g. ~/.config/salome/.SalomeApprc.6.4.0) # * ~/<appname>.xml[.<version>] for Windows (e.g. ~/SalomeApp.xml.6.4.0) # - Command line options have the highest priority and replace options # specified in configuration file(s) ### if theAdditionalOptions is None: theAdditionalOptions = [] global args config_var = appname + 'Config' # check KERNEL_ROOT_DIR kernel_root_dir = os.environ.get("KERNEL_ROOT_DIR", None) if kernel_root_dir is None: print """ For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set. KERNEL_ROOT_DIR is mandatory. """ sys.exit(1) ############################ # parse command line options pars = CreateOptionParser(theAdditionalOptions, exeName=exeName) (cmd_opts, cmd_args) = pars.parse_args(sys.argv[1:]) ############################ # Process --print-port option if cmd_opts.print_port: from searchFreePort import searchFreePort searchFreePort({}) print "port:%s" % (os.environ['NSPORT']) try: import PortManager PortManager.releasePort(os.environ['NSPORT']) except ImportError: pass sys.exit(0) pass # set resources variable SalomeAppConfig if it is not set yet dirs = [] if os.getenv(config_var): if sys.platform == 'win32': dirs += re.split(os.pathsep, os.getenv(config_var)) else: dirs += re.split('[;|:]', os.getenv(config_var)) gui_available = False if os.getenv("GUI_ROOT_DIR"): gui_resources_dir = os.path.join(os.getenv("GUI_ROOT_DIR"), 'share', 'salome', 'resources', 'gui') if os.path.isdir(gui_resources_dir): gui_available = True dirs.append(gui_resources_dir) pass if not gui_available: kernel_resources_dir = os.path.join(os.getenv("KERNEL_ROOT_DIR"), 'bin', 'salome', 'appliskel') if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( kernel_resources_dir): dirs.append(kernel_resources_dir) pass os.environ[config_var] = os.pathsep.join(dirs) dirs.reverse( ) # reverse order, like in "path" variable - FILO-style processing try: dirs.remove( '' ) # to remove empty dirs if the variable terminate by ":" or if there are "::" inside except: pass _opts = {} # associative array of options to be filled # parse SalomeApp.xml files in directories specified by SalomeAppConfig env variable for dir in dirs: filename = os.path.join(dir, appname + '.xml') if not os.path.exists(filename): if verbose(): print "Configure parser: Warning : can not find configuration file %s" % filename else: try: p = xml_parser(filename, _opts, []) _opts = p.opts except: if verbose(): print "Configure parser: Error : can not read configuration file %s" % filename pass # parse user configuration file # It can be set via --resources=<file> command line option # or is given from default location (see defaultUserFile() function) # If user file for the current version is not found the nearest to it is used user_config = cmd_opts.resources if not user_config: user_config = userFile(appname, cfgname) if verbose(): print "Configure parser: user configuration file is", user_config if not user_config or not os.path.exists(user_config): if verbose(): print "Configure parser: Warning : can not find user configuration file" else: try: p = xml_parser(user_config, _opts, []) _opts = p.opts except: if verbose(): print 'Configure parser: Error : can not read user configuration file' user_config = "" args = _opts args['user_config'] = user_config #print "User Configuration file: ", args['user_config'] # set default values for options which are NOT set in config files for aKey in listKeys: if not args.has_key(aKey): args[aKey] = [] for aKey in boolKeys: if not args.has_key(aKey): args[aKey] = 0 if args[file_nam]: afile = args[file_nam] args[file_nam] = [afile] args[appname_nam] = appname # get the port number my_port = getPortNumber() args[port_nam] = my_port #################################################### # apply command-line options to the arguments # each option given in command line overrides the option from xml config file # # Options: gui, desktop, log_file, resources, # xterm, modules, embedded, standalone, # portkill, killall, interp, splash, # catch_exceptions, pinter # GUI/Terminal, Desktop, Splash, STUDY_HDF args["session_gui"] = False args[batch_nam] = False args["study_hdf"] = None if cmd_opts.gui is not None: args[gui_nam] = cmd_opts.gui if cmd_opts.batch is not None: args[batch_nam] = True if not gui_available: args[gui_nam] = False if args[gui_nam]: args["session_gui"] = True if cmd_opts.desktop is not None: args["session_gui"] = cmd_opts.desktop args[splash_nam] = cmd_opts.desktop if args["session_gui"]: if cmd_opts.splash is not None: args[splash_nam] = cmd_opts.splash else: args["session_gui"] = False args[splash_nam] = False # Logger/Log file if cmd_opts.log_file is not None: if cmd_opts.log_file == 'CORBA': args[logger_nam] = True else: args[file_nam] = [cmd_opts.log_file] # Naming Service port log file if cmd_opts.ns_port_log_file is not None: args["ns_port_log_file"] = cmd_opts.ns_port_log_file # Study files for arg in cmd_args: if arg[-4:] == ".hdf" and not args["study_hdf"]: args["study_hdf"] = arg # Python scripts from salomeContextUtils import getScriptsAndArgs, ScriptAndArgs args[script_nam] = getScriptsAndArgs(cmd_args) if args[gui_nam] and args["session_gui"]: new_args = [] for sa_obj in args[ script_nam]: # args[script_nam] is a list of ScriptAndArgs objects script = re.sub(r'^python.*\s+', r'', sa_obj.script) new_args.append( ScriptAndArgs(script=script, args=sa_obj.args, out=sa_obj.out)) # args[script_nam] = new_args # xterm if cmd_opts.xterm is not None: args[xterm_nam] = cmd_opts.xterm # Modules if cmd_opts.modules is not None: args[modules_nam] = [] listlist = cmd_opts.modules for listi in listlist: args[modules_nam] += re.split("[:;,]", listi) else: # if --modules (-m) command line option is not given # try SALOME_MODULES environment variable if os.getenv("SALOME_MODULES"): args[modules_nam] = re.split("[:;,]", os.getenv("SALOME_MODULES")) pass # Embedded if cmd_opts.embedded is not None: args[embedded_nam] = filter(lambda a: a.strip(), re.split("[:;,]", cmd_opts.embedded)) # Standalone if cmd_opts.standalone is not None: args[standalone_nam] = filter(lambda a: a.strip(), re.split("[:;,]", cmd_opts.standalone)) # Normalize the '--standalone' and '--embedded' parameters standalone, embedded = process_containers_params(args.get(standalone_nam), args.get(embedded_nam)) if standalone is not None: args[standalone_nam] = standalone if embedded is not None: args[embedded_nam] = embedded # Kill if cmd_opts.portkill is not None: args[portkill_nam] = cmd_opts.portkill if cmd_opts.killall is not None: args[killall_nam] = cmd_opts.killall # Interpreter if cmd_opts.interp is not None: args[interp_nam] = cmd_opts.interp # Exceptions if cmd_opts.catch_exceptions is not None: args[except_nam] = not cmd_opts.catch_exceptions # Relink config file if cmd_opts.save_config is not None: args['save_config'] = cmd_opts.save_config # Interactive python console if cmd_opts.pinter is not None: args[pinter_nam] = cmd_opts.pinter # Gdb session in xterm if cmd_opts.gdb_session is not None: args[gdb_session_nam] = cmd_opts.gdb_session # Ddd session in xterm if cmd_opts.ddd_session is not None: args[ddd_session_nam] = cmd_opts.ddd_session # valgrind session if cmd_opts.valgrind_session is not None: args[valgrind_session_nam] = cmd_opts.valgrind_session # Shutdown servers if cmd_opts.shutdown_servers is None: args[shutdown_servers_nam] = 0 else: args[shutdown_servers_nam] = cmd_opts.shutdown_servers pass # Foreground if cmd_opts.foreground is None: args[foreground_nam] = 1 else: args[foreground_nam] = cmd_opts.foreground pass # wake up session if cmd_opts.wake_up_session is not None: args[wake_up_session_nam] = cmd_opts.wake_up_session #################################################### # Add <theAdditionalOptions> values to args for add_opt in theAdditionalOptions: cmd = "args[\"{0}\"] = cmd_opts.{0}".format(add_opt.dest) exec(cmd) #################################################### # disable signals handling if args[except_nam] == 1: os.environ["NOT_INTERCEPT_SIGNALS"] = "1" pass # now modify SalomeAppConfig environment variable # to take into account the SALOME modules if os.sys.platform == 'win32': dirs = re.split('[;]', os.environ[config_var]) else: dirs = re.split('[;|:]', os.environ[config_var]) for module in args[modules_nam]: if module not in ["KERNEL", "GUI", ""] and os.getenv( "{0}_ROOT_DIR".format(module)): d1 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)), "share", "salome", "resources", module.lower()) d2 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)), "share", "salome", "resources") #if os.path.exists( "%s/%s.xml"%(d1, appname) ): if os.path.exists(os.path.join(d1, "{0}.xml".format(salomeappname))): dirs.append(d1) #elif os.path.exists( "%s/%s.xml"%(d2, appname) ): elif os.path.exists( os.path.join(d2, "{0}.xml".format(salomeappname))): dirs.append(d2) else: #print "* '"+m+"' should be deleted from ",args[modules_nam] pass # Test if cmd_opts.test_script_file is not None: args[test_nam] = [] filename = cmd_opts.test_script_file args[test_nam] += re.split("[:;,]", filename) # Play if cmd_opts.play_script_file is not None: args[play_nam] = [] filename = cmd_opts.play_script_file args[play_nam] += re.split("[:;,]", filename) # Server launch command if cmd_opts.server_launch_mode is not None: args["server_launch_mode"] = cmd_opts.server_launch_mode # Server launch command if cmd_opts.use_port is not None: min_port = 2810 max_port = min_port + 100 if cmd_opts.use_port not in xrange(min_port, max_port + 1): print "Error: port number should be in range [%d, %d])" % ( min_port, max_port) sys.exit(1) args[useport_nam] = cmd_opts.use_port if cmd_opts.language is not None: langs = args[ "language_languages"] if "language_languages" in args else [] if cmd_opts.language not in langs: print "Error: unsupported language: %s" % cmd_opts.language sys.exit(1) args[lang_nam] = cmd_opts.language # return arguments os.environ[config_var] = os.pathsep.join(dirs) #print "Args: ", args return args