From 16acc74181767343289c729f668fb34d50212441 Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Wed, 19 Jul 2006 10:14:03 -0400 Subject: [PATCH] Use subprocess-native functionality for changing directory --- libbe/bzr.py | 9 +-------- libbe/rcs.py | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/libbe/bzr.py b/libbe/bzr.py index b53429c..ddda334 100644 --- a/libbe/bzr.py +++ b/libbe/bzr.py @@ -25,14 +25,7 @@ def invoke_client(*args, **kwargs): expect = kwargs.get('expect', (0, 1)) cl_args = ["bzr"] cl_args.extend(args) - if directory: - old_dir = os.getcwd() - os.chdir(directory) - try: - status,output,error = invoke(cl_args, expect) - finally: - if directory: - os.chdir(old_dir) + status,output,error = invoke(cl_args, expect, cwd=directory) return status, output def add_id(filename, paranoid=False): diff --git a/libbe/rcs.py b/libbe/rcs.py index e7097aa..fddfeb6 100644 --- a/libbe/rcs.py +++ b/libbe/rcs.py @@ -44,8 +44,8 @@ class CommandError(Exception): self.err_str = err_str self.status = status -def invoke(args, expect=(0,)): - q = Popen(args, stdout=PIPE, stderr=PIPE) +def invoke(args, expect=(0,), cwd=None): + q = Popen(args, stdout=PIPE, stderr=PIPE, cwd=cwd) output, error = q.communicate() status = q.wait() if status not in expect: -- 2.26.2