diff options
author | Greg Hudson <ghudson@mit.edu> | 2010-04-24 18:53:25 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2010-04-24 18:53:25 +0000 |
commit | 3564031bf220ed784fd83b9fc6af7cc0ddf0ccf2 (patch) | |
tree | 5c06960e4061b50d91ba97bf8046cf17cdb81d1e /src/util | |
parent | 96de2891830e8418cdd0cebe83faf047cc74dbba (diff) | |
download | krb5-3564031bf220ed784fd83b9fc6af7cc0ddf0ccf2.zip krb5-3564031bf220ed784fd83b9fc6af7cc0ddf0ccf2.tar.gz krb5-3564031bf220ed784fd83b9fc6af7cc0ddf0ccf2.tar.bz2 |
Simplify how k5test scripts get run by importing runenv by pathname
(using the imp module) instead of by module name.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23933 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/k5test.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/util/k5test.py b/src/util/k5test.py index 74768de..9ac1fc8 100644 --- a/src/util/k5test.py +++ b/src/util/k5test.py @@ -307,6 +307,7 @@ import socket import string import subprocess import sys +import imp # Used when most things go wrong (other than programming errors) so # that the user sees an error message rather than a Python traceback, @@ -466,15 +467,25 @@ def _match_cmdnum(cmdnum, ind): # Return an environment suitable for running programs in the build # tree. It is safe to modify the result. def _build_env(): - global buildtop + global buildtop, _runenv env = os.environ.copy() - for (k, v) in runenv.env.iteritems(): + for (k, v) in _runenv.iteritems(): if v.find('./') == 0: env[k] = os.path.join(buildtop, v) else: env[k] = v return env + +def _import_runenv(): + global buildtop + runenv_py = os.path.join(buildtop, 'runenv.py') + if not os.path.exists(runenv_py): + fail('You must run "make fake-install" in %s first.' % buildtop) + module = imp.load_source('runenv', runenv_py) + return module.env + + # Merge the nested dictionaries cfg1 and cfg2 into a new dictionary. # cfg1 or cfg2 may be None, in which case the other is returned. If # cfg2 contains keys mapped to None, the corresponding keys will be @@ -1018,15 +1029,10 @@ _cmd_index = 1 buildtop = _find_buildtop() srctop = _find_srctop() plugins = _find_plugins() +_runenv = _import_runenv() hostname = socket.getfqdn() null_input = open(os.devnull, 'r') -# runenv.py is built in the top level by "make fake-install". Import -# it now (rather than at the beginning of the file) so that we get a -# friendly error message from _find_plugins() if "make fake-install" -# has not been run. -import runenv - krb5kdc = os.path.join(buildtop, 'kdc', 'krb5kdc') kadmind = os.path.join(buildtop, 'kadmin', 'server', 'kadmind') kadmin = os.path.join(buildtop, 'kadmin', 'cli', 'kadmin') |