- def get_value(self, key):
- """Get the real value of the environment variable "key", not ${key}
- It can help env scripts
- :param key str: the environment variable
- """
- return self.environ[key]
-
- def add(self, key, value):
- """prepend value to key using sep
-
- :param key str: the environment variable to prepend
- :param value str: the value to prepend to key
- """
- if key in self.specialKeys.keys():
- self.output.write(self.begin+'addTo%s(r"%s")\n' %
- (self.specialKeys[key],
- self.change_to_launcher(value)))
- self.environ[key]+=":"+value
- return
- sep=special_path_separator(key)
- self.output.write(self.indent+
- '#temporary solution!!! have to be defined in API a '
- '?dangerous? addToSpecial(r"%s", r"%s")\n' %
- (key, value))
- #pathsep not precised because do not know future os launch?
- self.output.write(self.begin+'addToSpecial(r"%s", r"%s")\n'
- % (key, self.change_to_launcher(value)))
- self.environ[key]+=sep+value #here yes we know os for current execution
-
- def command_value(self, key, command):
- """\
- Get the value given by the system command "command"
- and put it in the environment variable key.
-
- :param key str: the environment variable
- :param command str: the command to execute
- """
- self.output.write(self.indent+'#`%s`\n' % command)
-
- import shlex, subprocess
- args = shlex.split(command)
- res=subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, __ = res.communicate()
- self.output.write(self.begin+
- self.setVarEnv+
- '(r"%s", r"%s", overwrite=True)\n' % (key, out))