<div dir="ltr"><br><br><div class="gmail_quote">On Sun, Aug 10, 2008 at 5:37 PM, John Arbash Meinel <span dir="ltr">&lt;<a href="mailto:john@arbash-meinel.com">john@arbash-meinel.com</a>&gt;</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>
&gt; On Sun, Aug 10, 2008 at 3:48 PM, Javier Derderian &lt;<a href="mailto:javierder@gmail.com">javierder@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m working on a feature for bzr-gedit that needs reading/grabbing all the<br>
&gt;&gt; info bzr writes to stdout, it&#39;s an &quot;output window&quot;.<br>
&gt;&gt; How can i do this, since i&#39;m using bzrlib?<br>
&gt;&gt; I mean, how can I do this from &quot;inside&quot; python?<br>
&gt;<br>
&gt; You could redirect the IO to a StringIO file:<br>
&gt; <a href="http://code.activestate.com/recipes/534166/" target="_blank">http://code.activestate.com/recipes/534166/</a><br>
&gt;<br>
&gt; But does the bzrlib api produces any output? I mean, this is the work<br>
&gt; of the tool, not of the api. But I haven&#39;t tryed the extension api<br>
&gt; (yet!), so I&#39;m just guessing :)<br>
&gt;<br>
&gt; (Sorry Javier, replying to the list too now)<br>
&gt;<br>
&gt;&gt; Thanks.<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Javier Derderian<br>
&gt;&gt; <a href="mailto:javierder@gmail.com">javierder@gmail.com</a><br>
&gt;&gt; ---<br>
&gt;&gt; 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(&#39;location&#39;)<br>
<br>
or to do status<br>
<br>
working_tree = bzrlib.workingtree.WorkingTree.open(&#39;location&#39;)<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 &quot;bzr<br>
status&quot; 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&#39;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>
=:-&gt;<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&#39;s exactly what i need, to override&nbsp; sys.stdout, but I still couldn&#39;t do it, what i tied seems to don&#39;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>