-# 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.
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
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)
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,
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: