Reading bazaar output?

Javier Derderian javierder at gmail.com
Sun Aug 10 22:11:07 BST 2008


On Sun, Aug 10, 2008 at 5:37 PM, John Arbash Meinel
<john at arbash-meinel.com>wrote:

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


Hi!

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.

How can i do it?
-- 
Javier Derderian
javierder at gmail.com
---
En la Alegría serás Imbatible
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/bazaar/attachments/20080810/2a1ddb7f/attachment-0001.htm 


More information about the bazaar mailing list