How do I grab the output of a mercurial command ?

Martin Gadbois martin.gadbois at colubris.com
Wed Mar 5 10:44:17 CST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Donszelmann Mark wrote:
> I execute from a python program the command:
> 
> 	commands.unbundle(self.ui, self.repo, bundle,  
> verbose=self.ui.verbose, quiet=self.ui.quiet)
> 
> and catch its exceptions. My question is how do I also "catch/grab"  
> the output that this command
> is writing ("No changesets").

Create a file-like object (implements .open/.file, .read and .write) and
 assign an instance to sys.stdout. Keep the original to re-assign it later.

"No changesets" should be called with your object's write() method.

- --
==============         +---------------------------------------------+
Martin Gadbois         | "Please answer by yes or no.                |
Sr. SW Designer        | Uncooperative user waste precious CPU time" |
Colubris Networks Inc. | -- The Andromeda Strain, M. Crichton, 1969  |
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHzs3hMPkSU9icdA0RAqfbAJ9KnsbsB3gh9+uSKJ8DnhrsK9bLnQCfWna8
R5I5HzN07u+jeg/IBY+OS/I=
=FnVu
-----END PGP SIGNATURE-----


More information about the Mercurial mailing list