3 # Copyright (C) 2010-2013 CEA/DEN
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 import src.debug as DBG
22 import src.architecture
27 rem The following variables are used only in case of a sat package
28 set out_dir_Path=%~dp0
34 ##########################################################################
37 # cleanup a path (first parameter) from duplicated entries;
38 # second parameter is the separator
40 out_var=`echo $1 | awk -v sep=$2 '{ \\
41 na = split($1,a,sep); \\
43 for(i=0;i<=na;i++) { \\
60 }' | sed -e 's|\\(.*\\)$1|\\1|g' -e 's|^[:;]||' -e 's|[:;]$||'`
67 out_var=`cleandup $xenv $2`
71 # This line is used only in case of a sat package
72 export out_dir_Path=$(cd $(dirname ${BASH_SOURCE[0]});pwd)
74 ###########################################################################
78 [SALOME Configuration]
82 # a generated SALOME Configuration file using python syntax
85 def get_file_environ(output, shell, environ=None):
86 """Instantiate correct FileEnvironment sub-class.
88 :param output file: the output file stream.
89 :param shell str: the type of shell syntax to use.
90 :param environ dict: a potential additional environment.
93 return BashFileEnviron(output, environ)
95 return BatFileEnviron(output, environ)
96 if shell == "cfgForPy":
97 return LauncherFileEnviron(output, environ)
99 return ContextFileEnviron(output, environ)
100 raise Exception("FileEnviron: Unknown shell = %s" % shell)
102 class FileEnviron(object):
104 Base class for shell environment
106 def __init__(self, output, environ=None):
110 :param output file: the output file stream.
111 :param environ dict: a potential additional environment.
113 self._do_init(output, environ)
117 easy non exhaustive quick resume for debug print"""
119 "output" : self.output,
120 "environ" : self.environ,
122 return "%s(\n%s\n)" % (self.__class__.__name__, PP.pformat(res))
125 def _do_init(self, output, environ=None):
129 :param output file: the output file stream.
130 :param environ dict: a potential additional environment.
134 if environ is not None:
135 #if str(type(environ)) == "<type 'instance'>":
136 if id(environ) == id(os.environ):
137 DBG.tofix("set %s environ as python os.environ, are you sure it is safe ?" % self.__class__.__name__, True)
138 self.environ = environ
140 DBG.tofix("set %s environ as COPY of python os.environ, are you sure it is safe ?" % self.__class__.__name__, True)
141 self.environ = dict(os.environ) #make a copy cvw 180320
143 def add_line(self, number):
145 Add some empty lines in the shell file
147 :param number int: the number of lines to add
149 self.output.write("\n" * number)
151 def add_comment(self, comment):
153 Add a comment in the shell file
155 :param comment str: the comment to add
157 self.output.write("# %s\n" % comment)
159 def add_echo(self, text):
161 Add a "echo" in the shell file
163 :param text str: the text to echo
165 self.output.write('echo %s"\n' % text)
167 def add_warning(self, warning):
169 Add a warning "echo" in the shell file
171 :param warning str: the text to echo
173 self.output.write('echo "WARNING %s"\n' % warning)
175 def append_value(self, key, value, sep=os.pathsep):
177 append value to key using sep,
178 if value contains ":" or ";" then raise error
180 :param key str: the environment variable to append
181 :param value str: the value to append to key
182 :param sep str: the separator string
185 if src.architecture.is_windows():
189 for c in separators: # windows or linux path separators
191 if c in value and not src.architecture.is_windows():
193 elif c in value and src.architecture.is_windows() and value.count(':') > 1:
196 raise Exception("FileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
197 self.set(key, self.get(key) + sep + value)
198 if (key, sep) not in self.toclean:
199 self.toclean.append((key, sep))
201 def append(self, key, value, sep=os.pathsep):
203 Same as append_value but the value argument can be a list
205 :param key str: the environment variable to append
206 :param value str or list: the value(s) to append to key
207 :param sep str: the separator string
209 if isinstance(value, list):
211 self.append_value(key, v, sep)
213 self.append_value(key, value, sep)
215 def prepend_value(self, key, value, sep=os.pathsep):
217 prepend value to key using sep,
218 if value contains ":" or ";" then raise error
220 :param key str: the environment variable to prepend
221 :param value str: the value to prepend to key
222 :param sep str: the separator string
225 if src.architecture.is_windows():
229 for c in separators: # windows or linux path separators
231 if c in value and not src.architecture.is_windows():
233 elif c in value and src.architecture.is_windows() and value.count(':') > 1:
236 raise Exception("FileEnviron prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
237 self.set(key, value + sep + self.get(key))
238 if (key, sep) not in self.toclean:
239 self.toclean.append((key, sep))
241 def prepend(self, key, value, sep=os.pathsep):
243 Same as prepend_value but the value argument can be a list
245 :param key str: the environment variable to prepend
246 :param value str or list: the value(s) to prepend to key
247 :param sep str: the separator string
249 if isinstance(value, list):
250 for v in reversed(value): # prepend list, first item at last to stay first
251 self.prepend_value(key, v, sep)
253 self.prepend_value(key, value, sep)
255 def is_defined(self, key):
257 Check if the key exists in the environment
259 :param key str: the environment variable to check
261 return (key in self.environ)
263 def set(self, key, value):
265 Set the environment variable 'key' to value 'value'
267 :param key str: the environment variable to set
268 :param value str: the value
270 raise NotImplementedError("set is not implement for this shell!")
274 Get the value of the environment variable "key"
276 :param key str: the environment variable
280 def get_value(self, key):
281 """Get the real value of the environment variable "key"
282 It can help env scripts
283 :param key str: the environment variable
285 return self.environ[key]
287 def command_value(self, key, command):
289 Get the value given by the system command "command"
290 and put it in the environment variable key.
291 Has to be overwritten in the derived classes
292 This can be seen as a virtual method
294 :param key str: the environment variable
295 :param command str: the command to execute
297 raise NotImplementedError("command_value is not implement "
300 def finish(self, required=True):
301 """Add a final instruction in the out file (in case of file generation)
303 :param required bool: Do nothing if required is False
305 for (key, sep) in self.toclean:
307 self.output.write('clean %s "%s"\n' % (key, sep))
309 class BashFileEnviron(FileEnviron):
311 Class for bash shell.
313 def __init__(self, output, environ=None):
316 :param output file: the output file stream.
317 :param environ dict: a potential additional environment.
319 self._do_init(output, environ)
320 self.output.write(bash_header)
322 def set(self, key, value):
323 """Set the environment variable "key" to value "value"
325 :param key str: the environment variable to set
326 :param value str: the value
328 self.output.write('export %s="%s"\n' % (key, value))
329 self.environ[key] = value
331 def command_value(self, key, command):
333 Get the value given by the system command "command"
334 and put it in the environment variable key.
335 Has to be overwritten in the derived classes
336 This can be seen as a virtual method
338 :param key str: the environment variable
339 :param command str: the command to execute
341 self.output.write('export %s=$(%s)\n' % (key, command))
343 def finish(self, required=True):
344 """Add a final instruction in the out file (in case of file generation)
346 :param required bool: Do nothing if required is False
350 FileEnviron.finish(self, required)
352 class BatFileEnviron(FileEnviron):
354 for Windows batch shell.
356 def __init__(self, output, environ=None):
359 :param output file: the output file stream.
360 :param environ dict: a potential additional environment.
362 self._do_init(output, environ)
363 self.output.write(bat_header)
365 def add_comment(self, comment):
366 """Add a comment in the shell file
368 :param comment str: the comment to add
370 self.output.write("rem %s\n" % comment)
373 """Get the value of the environment variable "key"
375 :param key str: the environment variable
377 return '%%%s%%' % key
379 def set(self, key, value):
380 """Set the environment variable "key" to value "value"
382 :param key str: the environment variable to set
383 :param value str: the value
385 self.output.write('set %s=%s\n' % (key, value))
386 self.environ[key] = value
388 def command_value(self, key, command):
390 Get the value given by the system command "command"
391 and put it in the environment variable key.
392 Has to be overwritten in the derived classes
393 This can be seen as a virtual method
395 :param key str: the environment variable
396 :param command str: the command to execute
398 self.output.write('%s > tmp.txt\n' % (command))
399 self.output.write('set /p %s =< tmp.txt\n' % (key))
401 def finish(self, required=True):
403 Add a final instruction in the out file (in case of file generation)
404 In the particular windows case, do nothing
406 :param required bool: Do nothing if required is False
410 class ContextFileEnviron(FileEnviron):
411 """Class for a salome context configuration file.
413 def __init__(self, output, environ=None):
416 :param output file: the output file stream.
417 :param environ dict: a potential additional environment.
419 self._do_init(output, environ)
420 self.output.write(cfg_header)
422 def set(self, key, value):
423 """Set the environment variable "key" to value "value"
425 :param key str: the environment variable to set
426 :param value str: the value
428 self.output.write('%s="%s"\n' % (key, value))
429 self.environ[key] = value
432 """Get the value of the environment variable "key"
434 :param key str: the environment variable
436 return '%({0})s'.format(key)
438 def command_value(self, key, command):
440 Get the value given by the system command "command"
441 and put it in the environment variable key.
442 Has to be overwritten in the derived classes
443 This can be seen as a virtual method
445 :param key str: the environment variable
446 :param command str: the command to execute
448 raise NotImplementedError("command_value is not implement "
449 "for salome context files!")
451 def add_echo(self, text):
454 :param text str: the comment to add
456 self.add_comment(text)
458 def add_warning(self, warning):
461 :param text str: the warning to add
463 self.add_comment("WARNING %s" % warning)
465 def prepend_value(self, key, value, sep=os.pathsep):
466 """prepend value to key using sep
468 :param key str: the environment variable to prepend
469 :param value str: the value to prepend to key
470 :param sep str: the separator string
472 self.output.write('ADD_TO_%s: %s\n' % (key, value))
474 def append_value(self, key, value, sep=os.pathsep):
475 """append value to key using sep
477 :param key str: the environment variable to append
478 :param value str: the value to append to key
479 :param sep str: the separator string
481 self.prepend_value(key, value)
483 def finish(self, required=True):
484 """Add a final instruction in the out file (in case of file generation)
486 :param required bool: Do nothing if required is False
490 def special_path_separator(name):
492 TCLLIBPATH, TKLIBPATH, PV_PLUGIN_PATH environments variables need
493 some exotic path separator.
494 This function gives the separator regarding the name of the variable
495 to append or prepend.
497 :param name str: The name of the variable to find the separator
499 special_blanks_keys=["TCLLIBPATH", "TKLIBPATH"]
500 special_semicolon_keys=["PV_PLUGIN_PATH"]
502 if name in special_blanks_keys: res=" "
503 if name in special_semicolon_keys: res=";"
506 class LauncherFileEnviron:
508 Class to generate a launcher file script
509 (in python syntax) SalomeContext API
511 def __init__(self, output, environ=None):
514 :param output file: the output file stream.
515 :param environ dict: a potential additional environment.
519 if environ is not None:
520 self.environ = environ
522 self.environ = os.environ
523 # Initialize some variables
524 if not "PATH" in self.environ.keys():
525 self.environ["PATH"]=""
526 if not "LD_LIBRARY_PATH" in self.environ.keys():
527 self.environ["LD_LIBRARY_PATH"]=""
528 if not "PYTHONPATH" in self.environ.keys():
529 self.environ["PYTHONPATH"]=""
530 if not "TCLLIBPATH" in self.environ.keys():
531 self.environ["TCLLIBPATH"]=""
532 if not "TKLIBPATH" in self.environ.keys():
533 self.environ["TKLIBPATH"]=""
535 # four whitespaces for first indentation in a python script
537 self.prefix="context."
538 self.setVarEnv="setVariable"
540 self.begin=self.indent+self.prefix
541 self.output.write(Launcher_header)
542 self.specialKeys={"PATH": "Path",
543 "LD_LIBRARY_PATH": "LdLibraryPath",
544 "PYTHONPATH": "PythonPath"}
546 def change_to_launcher(self, value):
550 def add_line(self, number):
551 """Add some empty lines in the launcher file
553 :param number int: the number of lines to add
555 self.output.write("\n" * number)
557 def add_echo(self, text):
560 :param text str: the comment to add
562 self.output.write('# %s"\n' % text)
564 def add_warning(self, warning):
567 :param text str: the warning to add
569 self.output.write('# "WARNING %s"\n' % warning)
571 def append_value(self, key, value, sep=":"):
572 """append value to key using sep,
573 if value contains ":" or ";" then raise error
575 :param key str: the environment variable to append
576 :param value str: the value to append to key
577 :param sep str: the separator string
580 if src.architecture.is_windows():
584 for c in separators: # windows or linux path separators
586 if c in value and not src.architecture.is_windows():
588 elif c in value and src.architecture.is_windows() and value.count(':') > 1:
591 raise Exception("LauncherFileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
592 if self.is_defined(key) :
597 def append(self, key, value, sep=":"):
598 """Same as append_value but the value argument can be a list
600 :param key str: the environment variable to append
601 :param value str or list: the value(s) to append to key
602 :param sep str: the separator string
604 if isinstance(value, list):
606 self.append_value(key, v, sep)
608 self.append_value(key, value, sep)
610 def prepend_value(self, key, value, sep=":"):
611 """prepend value to key using sep,
612 if value contains ":" or ";" then raise error
614 :param key str: the environment variable to prepend
615 :param value str: the value to prepend to key
616 :param sep str: the separator string
619 if src.architecture.is_windows():
623 for c in separators: # windows or linux path separators
625 if c in value and not src.architecture.is_windows():
627 elif c in value and src.architecture.is_windows() and value.count(':') > 1:
630 raise Exception("LauncherFileEnviron prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
631 if self.is_defined(key) :
636 def prepend(self, key, value, sep=":"):
637 """Same as prepend_value but the value argument can be a list
639 :param key str: the environment variable to prepend
640 :param value str or list: the value(s) to prepend to key
641 :param sep str: the separator string
643 if isinstance(value, list):
645 self.prepend_value(key, v, sep)
647 self.prepend_value(key, value, sep)
649 def is_defined(self, key):
650 """Check if the key exists in the environment
652 :param key str: the environment variable to check
654 return key in self.environ.keys()
657 """Get the value of the environment variable "key"
659 :param key str: the environment variable
663 def set(self, key, value):
664 """Set the environment variable "key" to value "value"
666 :param key str: the environment variable to set
667 :param value str: the value
669 self.output.write(self.begin+self.setVarEnv+
670 '(r"%s", r"%s", overwrite=True)\n' %
671 (key, self.change_to_launcher(value)))
672 self.environ[key] = value
674 def get_value(self, key):
675 """Get the real value of the environment variable "key", not ${key}
676 It can help env scripts
677 :param key str: the environment variable
679 return self.environ[key]
681 def add(self, key, value):
682 """prepend value to key using sep
684 :param key str: the environment variable to prepend
685 :param value str: the value to prepend to key
687 if key in self.specialKeys.keys():
688 self.output.write(self.begin+'addTo%s(r"%s")\n' %
689 (self.specialKeys[key],
690 self.change_to_launcher(value)))
691 self.environ[key]+=":"+value
693 sep=special_path_separator(key)
694 self.output.write(self.indent+
695 '#temporary solution!!! have to be defined in API a '
696 '?dangerous? addToSpecial(r"%s", r"%s")\n' %
698 #pathsep not precised because do not know future os launch?
699 self.output.write(self.begin+'addToSpecial(r"%s", r"%s")\n'
700 % (key, self.change_to_launcher(value)))
701 self.environ[key]+=sep+value #here yes we know os for current execution
703 def command_value(self, key, command):
705 Get the value given by the system command "command"
706 and put it in the environment variable key.
708 :param key str: the environment variable
709 :param command str: the command to execute
711 self.output.write(self.indent+'#`%s`\n' % command)
713 import shlex, subprocess
714 args = shlex.split(command)
715 res=subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
716 out, __ = res.communicate()
717 self.output.write(self.begin+
719 '(r"%s", r"%s", overwrite=True)\n' % (key, out))
721 def add_comment(self, comment):
722 # Special comment in case of the distène licence
723 if comment=="DISTENE license":
724 self.output.write(self.indent+
728 '(r"%s", r"%s", overwrite=True)\n' %
729 ('DISTENE_LICENSE_FILE',
730 self.change_to_launcher(
731 'Use global envvar: DLIM8VAR')))
732 self.output.write(self.indent+
736 '(r"%s", r"%s", overwrite=True)\n' %
738 self.change_to_launcher(
741 if "setting environ for" in comment:
742 self.output.write(self.indent+"#[%s]\n" %
743 comment.split("setting environ for ")[1])
746 self.output.write(self.indent+"# %s\n" % comment)
748 def finish(self, required=True):
750 Add a final instruction in the out file (in case of file generation)
751 In the particular launcher case, do nothing
753 :param required bool: Do nothing if required is False
757 class ScreenEnviron(FileEnviron):
758 def __init__(self, output, environ=None):
759 self._do_init(output, environ)
762 def add_line(self, number):
765 def add_comment(self, comment):
768 def add_echo(self, text):
771 def add_warning(self, warning):
774 def write(self, command, name, value, sign="="):
776 self.output.write(" %s%s %s %s %s\n" % \
777 (src.printcolors.printcLabel(command),
778 " " * (12 - len(command)),
779 src.printcolors.printcInfo(name), sign, value))
781 def is_defined(self, name):
782 return name in self.defined
785 return "${%s}" % name
787 def set(self, name, value):
788 self.write("set", name, value)
789 self.defined[name] = value
791 def prepend(self, name, value, sep=":"):
792 if isinstance(value, list):
793 value = sep.join(value)
794 value = value + sep + self.get(name)
795 self.write("prepend", name, value)
797 def append(self, name, value, sep=":"):
798 if isinstance(value, list):
799 value = sep.join(value)
800 value = self.get(name) + sep + value
801 self.write("append", name, value)
803 def command_value(self, key, command):
806 def run_env_script(self, module, script):
807 self.write("load", script, "", sign="")
809 # The SALOME launcher template
811 #! /usr/bin/env python
813 ################################################################
814 # WARNING: this file is automatically generated by SalomeTools #
815 # WARNING: and so could be overwritten at any time. #
816 ################################################################
823 # Add the pwdPath to able to run the launcher after unpacking a package
824 # Used only in case of a salomeTools package
825 out_dir_Path=os.path.dirname(os.path.realpath(__file__))
827 # Preliminary work to initialize path to SALOME Python modules
830 sys.path[:0] = [ 'BIN_KERNEL_INSTALL_DIR' ]
831 os.environ['ABSOLUTE_APPLI_PATH'] = 'KERNEL_INSTALL_DIR'
833 # define folder to store omniorb config (initially in virtual application folder)
835 from salomeContextUtils import setOmniOrbUserPath
837 except Exception as e:
840 # End of preliminary work
842 # salome doc only works for virtual applications. Therefore we overwrite it with this function
843 def _showDoc(modules):
844 for module in modules:
845 modulePath = os.getenv(module+"_ROOT_DIR")
846 if modulePath != None:
847 baseDir = os.path.join(modulePath, "share", "doc", "salome")
848 docfile = os.path.join(baseDir, "gui", module.upper(), "index.html")
849 if not os.path.isfile(docfile):
850 docfile = os.path.join(baseDir, "tui", module.upper(), "index.html")
851 if not os.path.isfile(docfile):
852 docfile = os.path.join(baseDir, "dev", module.upper(), "index.html")
853 if os.path.isfile(docfile):
854 out, err = subprocess.Popen(["xdg-open", docfile]).communicate()
856 print "Online documentation is not accessible for module:", module
858 print module+"_ROOT_DIR not found!"
861 # Identify application path then locate configuration files
864 if args == ['--help']:
865 from salomeContext import usage
869 #from salomeContextUtils import getConfigFileNames
870 #configFileNames, args, unexisting = getConfigFileNames( args, checkExistence=True )
871 #if len(unexisting) > 0:
872 # print "ERROR: unexisting configuration file(s): " + ', '.join(unexisting)
875 # Create a SalomeContext which parses configFileNames to initialize environment
877 from salomeContext import SalomeContext, SalomeContextException
878 SalomeContext.addToSpecial=addToSpecial
879 context = SalomeContext(None)
881 # Here set specific variables, if needed
882 # context.addToPath('mypath')
883 # context.addToLdLibraryPath('myldlibrarypath')
884 # context.addToPythonPath('mypythonpath')
885 # context.setVariable('myvarname', 'value')
888 context.getLogger().setLevel(40)
890 # here your local standalone environment
892 if len(args) >1 and args[0]=='doc':
896 # Start SALOME, parsing command line arguments
897 out, err, status = context.runSalome(args)
900 except SalomeContextException, e:
902 logging.getLogger("salome").error(e)
905 def addToSpecial(self, name, value, pathSep=None):
906 # add special dangerous cases: TCLLIBPATH PV_PLUGIN_PATH etc...
907 # http://computer-programming-forum.com/57-tcl/1dfddc136afccb94.htm
908 # TCLLIBPATH: Tcl treats the contents of that variable as a list. Be happy, for you can now use drive letters on windows.
912 specialBlanksKeys=["TCLLIBPATH", "TKLIBPATH"]
913 specialSemicolonKeys=["PV_PLUGIN_PATH"]
915 if name in specialBlanksKeys: res=" "
916 if name in specialSemicolonKeys: res=";"
922 value = os.path.expandvars(value) # expand environment variables
923 self.getLogger().debug("Add to %s: %s", name, value)
924 env = os.getenv(name, None)
926 os.environ[name] = value
928 os.environ[name] = value + sep + env #explicitely or not special path separator ?whitespace, semicolon?
930 if __name__ == "__main__":
937 #! /usr/bin/env python3
939 ################################################################
940 # WARNING: this file is automatically generated by SalomeTools #
941 # WARNING: and so could be overwritten at any time. #
942 ################################################################
949 # Add the pwdPath to able to run the launcher after unpacking a package
950 # Used only in case of a salomeTools package
951 out_dir_Path=os.path.dirname(os.path.realpath(__file__))
953 # Preliminary work to initialize path to SALOME Python modules
956 sys.path[:0] = [ 'BIN_KERNEL_INSTALL_DIR' ]
957 os.environ['ABSOLUTE_APPLI_PATH'] = 'KERNEL_INSTALL_DIR'
959 # define folder to store omniorb config (initially in virtual application folder)
961 from salomeContextUtils import setOmniOrbUserPath
963 except Exception as e:
966 # End of preliminary work
968 # salome doc only works for virtual applications. Therefore we overwrite it with this function
969 def _showDoc(modules):
970 for module in modules:
971 modulePath = os.getenv(module+"_ROOT_DIR")
972 if modulePath != None:
973 baseDir = os.path.join(modulePath, "share", "doc", "salome")
974 docfile = os.path.join(baseDir, "gui", module.upper(), "index.html")
975 if not os.path.isfile(docfile):
976 docfile = os.path.join(baseDir, "tui", module.upper(), "index.html")
977 if not os.path.isfile(docfile):
978 docfile = os.path.join(baseDir, "dev", module.upper(), "index.html")
979 if os.path.isfile(docfile):
980 out, err = subprocess.Popen(["xdg-open", docfile]).communicate()
982 print("Online documentation is not accessible for module:", module)
984 print(module+"_ROOT_DIR not found!")
987 # Identify application path then locate configuration files
990 if args == ['--help']:
991 from salomeContext import usage
995 #from salomeContextUtils import getConfigFileNames
996 #configFileNames, args, unexisting = getConfigFileNames( args, checkExistence=True )
997 #if len(unexisting) > 0:
998 # print("ERROR: unexisting configuration file(s): " + ', '.join(unexisting))
1001 # Create a SalomeContext which parses configFileNames to initialize environment
1003 from salomeContext import SalomeContext, SalomeContextException
1004 SalomeContext.addToSpecial=addToSpecial
1005 context = SalomeContext(None)
1007 # Here set specific variables, if needed
1008 # context.addToPath('mypath')
1009 # context.addToLdLibraryPath('myldlibrarypath')
1010 # context.addToPythonPath('mypythonpath')
1011 # context.setVariable('myvarname', 'value')
1013 # Logger level error
1014 context.getLogger().setLevel(40)
1016 # here your local standalone environment
1018 if len(args) >1 and args[0]=='doc':
1022 # Start SALOME, parsing command line arguments
1023 out, err, status = context.runSalome(args)
1026 except SalomeContextException as e:
1028 logging.getLogger("salome").error(e)
1031 def addToSpecial(self, name, value, pathSep=None):
1032 # add special dangerous cases: TCLLIBPATH PV_PLUGIN_PATH etc...
1033 # http://computer-programming-forum.com/57-tcl/1dfddc136afccb94.htm
1034 # TCLLIBPATH: Tcl treats the contents of that variable as a list. Be happy, for you can now use drive letters on windows.
1038 specialBlanksKeys=["TCLLIBPATH", "TKLIBPATH"]
1039 specialSemicolonKeys=["PV_PLUGIN_PATH"]
1041 if name in specialBlanksKeys: res=" "
1042 if name in specialSemicolonKeys: res=";"
1048 value = os.path.expandvars(value) # expand environment variables
1049 self.getLogger().debug("Add to %s: %s", name, value)
1050 env = os.getenv(name, None)
1052 os.environ[name] = value
1054 os.environ[name] = value + sep + env #explicitely or not special path separator ?whitespace, semicolon?
1056 if __name__ == "__main__":