def update_from_os_environment(self, env, append=False): """Update all variables in the given env from their counterpart in os.environ. This allows to selectively inherit from your parent environment @param env the environment to store the values from os.environ in @param append if True, and if the environment variable is a path, it will be appended. Otherwise it will be prepended. @note this is just a utility, you could easily implement it yourself""" for evar in self._controller_settings.inherit: if evar not in os.environ: continue # end ignore un-inheritable ones value = os.environ[evar] if PY2: # we operate in unicode, and have to be sure we don't get hit by the ascii default enoding ! # We just want to get it done, and hope the default encoding does it ! # Replace should mark characters that we can't do, which might help later debugging if isinstance(value, bytes): value = value.decode(DEFAULT_ENCODING, 'replace').encode('ascii', 'replace') # end # end handle unicode if self.variable_is_path(evar): update_env_path(evar, value, append=append, environment=env) log.debug("Setting %s = %s, append = %i", evar, value, append) else: log.debug('Setting %s = %s', evar, value) env[evar] = value
def prepare_tank_engine_environment(self, startup_tree, args, env): """Alter given args or env in place in order to make the launched application. @param startup_tree Path to the root of the host application specific startup directory in the tk-multi-launchapp. It is already verified to exist @param args list of program arguments @param env dict with environment variables - already containing the tank engine specific ones @throws any exception to disable tank @default implementation will just prepend the startup directory to the configured host_app_evar variable""" if self.host_app_evar is not None: log.log(logging.TRACE, "Setting engine startup environment: %s = %s", self.host_app_evar, startup_tree) update_env_path(self.host_app_evar, startup_tree, append = False, environment = env) else: raise NotImplementedError("Either set the 'host_app_evar' class member, or implement this method")
def update_from_os_environment(self, env, append = False): """Update all variables in the given env from their counterpart in os.environ. This allows to selectively inherit from your parent environment @param env the environment to store the values from os.environ in @param append if True, and if the environment variable is a path, it will be appended. Otherwise it will be prepended. @note this is just a utility, you could easily implement it yourself""" for evar in self._controller_settings.inherit: if evar not in os.environ: continue # end ignore un-inheritable ones value = os.environ[evar] if self.variable_is_path(evar): update_env_path(evar, value, append = append, environment = env) log.debug("Setting %s = %s, append = %i", evar, value, append) else: log.debug('Setting %s = %s', evar, value) env[evar] = value