diff --git a/edbob/win32.py b/edbob/win32.py index e74e650..96a76bd 100644 --- a/edbob/win32.py +++ b/edbob/win32.py @@ -163,6 +163,20 @@ def RegDeleteTree(key, subkey): pass +def capture_output(command): + """ + Runs ``command`` and returns any output it produces. + """ + + # We *need* to pipe ``stdout`` because that's how we capture the output of + # the ``hg`` command. However, we must pipe *all* handles in order to + # prevent issues when running as a GUI but *from* the Windows console. + # See also: http://bugs.python.org/issue3905 + kwargs = dict(stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output = subprocess.Popen(command, **kwargs).communicate()[0] + return output + + def delayed_auto_start_service(name): """ Configures the Windows service named ``name`` such that its startup type is