diff options
author | W. Trevor King <wking@drexel.edu> | 2009-11-17 08:25:15 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-11-17 08:25:15 -0500 |
commit | 32fbab0fb8f5defc3698d288024a10b8d32a0f25 (patch) | |
tree | 59dc5f4e2607fd9dbedf045587bdea084f8902b4 | |
parent | b1dbae97e769346246e8a36424c60ce89ef7a310 (diff) | |
download | bugseverywhere-32fbab0fb8f5defc3698d288024a10b8d32a0f25.tar.gz |
Added unicode_output option to VCS._u_invoke()
-rw-r--r-- | libbe/vcs.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libbe/vcs.py b/libbe/vcs.py index c260af1..45bc59e 100644 --- a/libbe/vcs.py +++ b/libbe/vcs.py @@ -456,10 +456,13 @@ class VCS(object): if list_string in string: return True return False - def _u_invoke(self, args, stdin=None, expect=(0,), cwd=None): + def _u_invoke(self, args, stdin=None, expect=(0,), cwd=None, + unicode_output=True): """ expect should be a tuple of allowed exit codes. cwd should be - the directory from which the command will be executed. + the directory from which the command will be executed. When + unicode_output == True, convert stdout and stdin strings to + unicode before returing them. """ if cwd == None: cwd = self.rootdir @@ -476,6 +479,9 @@ class VCS(object): raise CommandError(args, status=e.args[0], stdout="", stderr=e) stdout,stderr = q.communicate(input=stdin) status = q.wait() + if unicode_output == True: + stdout = unicode(stdout, self.encoding) + stderr = unicode(stderr, self.encoding) if self.verboseInvoke == True: print >> sys.stderr, "%d\n%s%s" % (status, stdout, stderr) if status not in expect: |