<div dir="ltr"><br><br><div class="gmail_quote">On Sun, Aug 10, 2008 at 5:37 PM, John Arbash Meinel <span dir="ltr"><<a href="mailto:john@arbash-meinel.com">john@arbash-meinel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<div class="Ih2E3d"><br>
Eduardo O. Padoan wrote:<br>
> On Sun, Aug 10, 2008 at 3:48 PM, Javier Derderian <<a href="mailto:javierder@gmail.com">javierder@gmail.com</a>> wrote:<br>
>> Hi,<br>
>><br>
>> I'm working on a feature for bzr-gedit that needs reading/grabbing all the<br>
>> info bzr writes to stdout, it's an "output window".<br>
>> How can i do this, since i'm using bzrlib?<br>
>> I mean, how can I do this from "inside" python?<br>
><br>
> You could redirect the IO to a StringIO file:<br>
> <a href="http://code.activestate.com/recipes/534166/" target="_blank">http://code.activestate.com/recipes/534166/</a><br>
><br>
> But does the bzrlib api produces any output? I mean, this is the work<br>
> of the tool, not of the api. But I haven't tryed the extension api<br>
> (yet!), so I'm just guessing :)<br>
><br>
> (Sorry Javier, replying to the list too now)<br>
><br>
>> Thanks.<br>
>><br>
>> --<br>
>> Javier Derderian<br>
>> <a href="mailto:javierder@gmail.com">javierder@gmail.com</a><br>
>> ---<br>
>> En la Alegría serás Imbatible<br>
<br>
</div>So, you *could* use the cmd_* classes to run operations. In general,<br>
though, we have a much richer api using Objects. For example:<br>
<br>
a_branch = bzrlib.branch.Branch.open('location')<br>
<br>
or to do status<br>
<br>
working_tree = bzrlib.workingtree.WorkingTree.open('location')<br>
working_tree.lock_read()<br>
basis_tree = working_tree.basis_tree()<br>
<br>
for XXX in working_tree.iter_changes(basis_tree):<br>
<br>
Which will give you nicely parsed information about changed paths, and<br>
what has changed, etc. Rather than trying to parse the output of "bzr<br>
status" to give you the same information.<br>
<br>
If you were strictly trying to just run a bzr command (say something<br>
that bzr-gedit doesn't normally allow), then I would probably do<br>
something like:<br>
<br>
cmd = bzrlib.builtins.cmd_status()<br>
cmd.outf = my_file_like_object<br>
cmd.run()<br>
<br>
Or if you really want to force it, you can override sys.stdout and<br>
sys.stderr.<br>
<br>
John<br>
=:-><br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.9 (Cygwin)<br>
Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org" target="_blank">http://enigmail.mozdev.org</a><br>
<br>
iEYEARECAAYFAkifUZAACgkQJdeBCYSNAAOL4QCgu/m+HyB8PhcfV4EGUi+BOuHc<br>
mfwAoNGQUh85lwTYYKZDVyzzDh7Thexg<br>
=G791<br>
-----END PGP SIGNATURE-----<br>
</blockquote></div><br><br clear="all">Hi!<br><br>That's exactly what i need, to override sys.stdout, but I still couldn't do it, what i tied seems to don't work.<br><br>How can i do it?<br>-- <br>Javier Derderian<br>
<a href="mailto:javierder@gmail.com">javierder@gmail.com</a><br>---<br>En la Alegría serás Imbatible<br>
</div>