views:

49

answers:

1

I would like to access a bazaar repository and pull code from it with either a Python or PHP script.

How is this done? Is there a Python module / PEAR library that makes this easy?

If it helps, the repository is on Launchpad.

Edit: As mentioned below, running the bazaar commands directly is not an option. Also, an example would be much appreciated.

+4  A: 

There is bzrlib. Depending on your circumstance you could also just execute the command lines to do this.

Based on the Integrating with BZR page you might do something like the following to checkout code. You can also Export code which might be more appropriate:

from bzrlib.bzrdir BzrDir

accelerator_tree, source = BzrDir.open_tree_or_branch('http:URL')
source.create_checkout('/tmp/newBzrCheckout', None, True, accelerator_tree)
BrianLy
Executing the commands requires bazaar to be installed on the machine that's accessing the repository - which is not necessarily a possibility.
George Edison
A bit more detail about bzrlib here: http://stackoverflow.com/questions/2864789/2865440#2865440
Adam Glauser
@George. Is installation of bzrlib also a problem? One way of dealing with this might be to have a machine acting as a 'proxy' returning you a zip file from the LP project. This opens another can of worms though.
BrianLy
Installing bzr is just as easy as installing bzrlib, so it shouldn't be an issue. You don't have to install bzr system-wide to use it.
Ian Bicking
@Ian: So I could install it on a shared server with a limited account?
George Edison
Yeah; try using virtualenv and installing it there. You need shell access but not root. If you don't have shell it's still possible, but trickier.
Ian Bicking
@Ian: I do indeed have SSH access.
George Edison