Alon Bar-Lev has uploaded a new change for review. Change subject: core: survive reexec and different execution directory ......................................................................
core: survive reexec and different execution directory Store the original execution directory within environment of process. Change-Id: I2673cc2ade4320da1008b39c9c36659cbc306910 Signed-off-by: Alon Bar-Lev <[email protected]> --- M src/otopi/__main__.py M src/otopi/constants.py M src/otopi/context.py 3 files changed, 10 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/16/11316/1 diff --git a/src/otopi/__main__.py b/src/otopi/__main__.py index 78c63f6..a4354b9 100644 --- a/src/otopi/__main__.py +++ b/src/otopi/__main__.py @@ -44,7 +44,9 @@ def _setupEnvironment(self, environment): """Setup environment based on command-line parameters.""" - environment[constants.BaseEnv.EXECUTION_DIRECTORY] = os.getcwd() + environment[constants.BaseEnv.EXECUTION_DIRECTORY] = os.environ[ + constants.SystemEnvironment.EXEC_DIR + ] for arg in sys.argv[1:]: for statement in shlex.split(arg): @@ -74,8 +76,12 @@ def main(self): try: installer = main.Otopi() - self._setupEnvironment(installer.environment) + os.environ.setdefault( + constants.SystemEnvironment.EXEC_DIR, + os.getcwd() + ) os.chdir('/') + self._setupEnvironment(installer.environment) installer.execute() os.chdir( installer.environment[ diff --git a/src/otopi/constants.py b/src/otopi/constants.py index cd92277..dfe2e1c 100644 --- a/src/otopi/constants.py +++ b/src/otopi/constants.py @@ -76,6 +76,7 @@ LOG_FILE = 'OTOPI_LOGFILE' LOG_DIR = 'OTOPI_LOGDIR' CONFIG = 'OTOPI_CONFIG' + EXEC_DIR = '_OTOPI_EXECDIR' @util.export diff --git a/src/otopi/context.py b/src/otopi/context.py index 9224e4c..f8b2780 100644 --- a/src/otopi/context.py +++ b/src/otopi/context.py @@ -185,6 +185,7 @@ constants.BaseEnv.ERROR: False, constants.BaseEnv.ABORTED: False, constants.BaseEnv.EXCEPTION_INFO: [], + constants.BaseEnv.EXECUTION_DIRECTORY: '.', constants.BaseEnv.LOG: False, constants.BaseEnv.PLUGIN_PATH: config.otopiplugindir, constants.BaseEnv.PLUGIN_GROUPS: 'otopi', -- To view, visit http://gerrit.ovirt.org/11316 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2673cc2ade4320da1008b39c9c36659cbc306910 Gerrit-PatchSet: 1 Gerrit-Project: otopi Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
