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', None)
855
def cleanup_environment():
856
for env_var, value in env_changes.iteritems():
858
del os.environ[env_var]
860
os.environ[env_var] = value
861
preexec_func = cleanup_environment
848
863
bzr_path = os.path.dirname(os.path.dirname(bzrlib.__file__))+'/bzr'
849
864
args = list(args)
850
process = Popen([sys.executable, bzr_path]+args, stdout=PIPE,
865
process = Popen([sys.executable, bzr_path]+args,
866
stdout=PIPE, stderr=PIPE,
867
preexec_fn=preexec_func)
852
868
out = process.stdout.read()
853
869
err = process.stderr.read()
854
870
retcode = process.wait()