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):
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: