843
843
profiled or debugged so easily.
845
845
:param retcode: The status code that is expected. Defaults to 0. If
846
None is supplied, the status code is not checked.
846
None is supplied, the status code is not checked.
847
:param env_changes: A dictionary which lists changes to environment
848
variables. A value of None will unset the env variable.
849
The values must be strings. The change will only occur in the
850
child, so you don't need to fix the environment after running.
852
env_changes = kwargs.get('env_changes', {})
853
def cleanup_environment():
854
for env_var, value in env_changes.iteritems():
856
del os.environ[env_var]
858
os.environ[env_var] = value
848
860
bzr_path = os.path.dirname(os.path.dirname(bzrlib.__file__))+'/bzr'
849
861
args = list(args)
850
process = Popen([sys.executable, bzr_path]+args, stdout=PIPE,
862
process = Popen([sys.executable, bzr_path]+args,
863
stdout=PIPE, stderr=PIPE,
864
preexec_fn=cleanup_environment)
852
865
out = process.stdout.read()
853
866
err = process.stderr.read()
854
867
retcode = process.wait()