def append_value(self, key, value, sep=os.pathsep):
"""\
- append value to key using sep
-
+ append value to key using sep,
+ if value contains ":" or ";" then raise error
+
:param key str: the environment variable to append
:param value str: the value to append to key
:param sep str: the separator string
"""
+ for c in [";", ":"]: # windows or linux path separators
+ if c in value:
+ raise Exception("FileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
self.set(key, self.get(key) + sep + value)
if (key, sep) not in self.toclean:
self.toclean.append((key, sep))
:param sep str: the separator string
"""
if isinstance(value, list):
- self.append_value(key, sep.join(value), sep)
+ for v in value:
+ self.append_value(key, v, sep)
else:
self.append_value(key, value, sep)
def prepend_value(self, key, value, sep=os.pathsep):
"""\
- prepend value to key using sep
+ prepend value to key using sep,
+ if value contains ":" or ";" then raise error
:param key str: the environment variable to prepend
:param value str: the value to prepend to key
:param sep str: the separator string
"""
+ for c in [";", ":"]: # windows or linux path separators
+ if c in value:
+ raise Exception("FileEnviron prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
self.set(key, value + sep + self.get(key))
if (key, sep) not in self.toclean:
self.toclean.append((key, sep))
:param sep str: the separator string
"""
if isinstance(value, list):
- self.prepend_value(key, sep.join(value), sep)
+ for v in reversed(value): # prepend list, first item at last to stay first
+ self.prepend_value(key, v, sep)
else:
self.prepend_value(key, value, sep)
self.output.write('# "WARNING %s"\n' % warning)
def append_value(self, key, value, sep=":"):
- """append value to key using sep
+ """append value to key using sep,
+ if value contains ":" or ";" then raise error
:param key str: the environment variable to append
:param value str: the value to append to key
:param sep str: the separator string
"""
+ for c in [";", ":"]: # windows or linux path separators
+ if c in value:
+ raise Exception("LauncherFileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
if self.is_defined(key) :
self.add(key, value)
else :
:param sep str: the separator string
"""
if isinstance(value, list):
- self.append_value(key, sep.join(value), sep)
+ for v in value:
+ self.append_value(key, v, sep)
else:
self.append_value(key, value, sep)
def prepend_value(self, key, value, sep=":"):
- """prepend value to key using sep
+ """prepend value to key using sep,
+ if value contains ":" or ";" then raise error
:param key str: the environment variable to prepend
:param value str: the value to prepend to key
:param sep str: the separator string
"""
+ for c in [";", ":"]: # windows or linux path separators
+ if c in value:
+ raise Exception("LauncherFileEnviron prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
if self.is_defined(key) :
self.add(key, value)
else :
:param sep str: the separator string
"""
if isinstance(value, list):
- self.prepend_value(key, sep.join(value), sep)
+ for v in value:
+ self.prepend_value(key, v, sep)
else:
self.prepend_value(key, value, sep)
src.printcolors.printcInfo(name), sign, value))
def is_defined(self, name):
- return self.defined.has_key(name)
+ return name in self.defined
def get(self, name):
return "${%s}" % name
# Add the pwdPath to able to run the launcher after unpacking a package
# Used only in case of a salomeTools package
-out_dir_Path=os.path.abspath(os.path.dirname(__file__))
+out_dir_Path=os.path.dirname(os.path.realpath(__file__))
# Preliminary work to initialize path to SALOME Python modules
def __initialize():
try:
from salomeContextUtils import setOmniOrbUserPath
setOmniOrbUserPath()
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
sys.exit(1)
# End of preliminary work
# Add the pwdPath to able to run the launcher after unpacking a package
# Used only in case of a salomeTools package
-out_dir_Path=os.path.abspath(os.path.dirname(__file__))
+out_dir_Path=os.path.dirname(os.path.realpath(__file__))
# Preliminary work to initialize path to SALOME Python modules
def __initialize():