Bumped to version 1.0.1
[be.git] / libbe / util / subproc.py
index 8806e26497b8999bac640961cf0d1c986dfbab0f..bb60b4712f38e1fbeb00a9da7dfd221217e8b064 100644 (file)
@@ -1,18 +1,20 @@
-# Copyright (C) 2009 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2009-2011 Chris Ball <cjb@laptop.org>
+#                         W. Trevor King <wking@drexel.edu>
 #
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# This file is part of Bugs Everywhere.
 #
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# Bugs Everywhere is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 2 of the License, or (at your
+# option) any later version.
 #
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# Bugs Everywhere is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Bugs Everywhere.  If not, see <http://www.gnu.org/licenses/>.
 
 """
 Functions for running external commands in subprocesses.
@@ -36,7 +38,7 @@ if _POSIX == True:
 class CommandError(Exception):
     def __init__(self, command, status, stdout=None, stderr=None):
         strerror = ['Command failed (%d):\n  %s\n' % (status, stderr),
-                    'while executing\n  %s' % command]
+                    'while executing\n  %s' % str(command)]
         Exception.__init__(self, '\n'.join(strerror))
         self.command = command
         self.status = status
@@ -61,7 +63,7 @@ def invoke(args, stdin=None, stdout=PIPE, stderr=PIPE, expect=(0,),
         else:
             assert _MSWINDOWS==True, 'invalid platform'
             # win32 don't have os.execvp() so have to run command in a shell
-            q = Popen(args, stdin=PIPE, stdout=stdout, stderr=stderr, 
+            q = Popen(args, stdin=PIPE, stdout=stdout, stderr=stderr,
                       shell=True, cwd=cwd)
     except OSError, e:
         raise CommandError(args, status=e.args[0], stderr=e)
@@ -133,7 +135,7 @@ class Pipe (object):
                 thread.start()
                 threads.append(thread)
                 std_X_arrays.append(stderr_array)
-    
+
             # also listen to the last processes stdout
             stdout_array = []
             thread = Thread(target=proc._readerthread,
@@ -142,11 +144,11 @@ class Pipe (object):
             thread.start()
             threads.append(thread)
             std_X_arrays.append(stdout_array)
-    
+
             # join threads as they die
             for thread in threads:
                 thread.join()
-    
+
             # read output from reader threads
             std_X_strings = []
             for std_X_array in std_X_arrays: