~launchpad-pqm/launchpad/devel

10637.3.1 by Guilherme Salgado
Use the default python version instead of a hard-coded version
1
#!/usr/bin/python -S
8687.15.4 by Karl Fogel
Add the copyright header block to more files; tweak format in a few files.
2
#
3
# Copyright 2009 Canonical Ltd.  This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
7444.4.2 by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad.
6
"""Get useful hosting information for a branch.
7
8
Usage: get-branch-info <branch_url>
9
"""
10
11
import _pythonpath
12
13
import sys
14
15
from bzrlib.urlutils import join
16
17
from zope.component import getUtility
18
14605.1.1 by Curtis Hovey
Moved canonical.config to lp.services.
19
from lp.services.config import config
14565.2.15 by Curtis Hovey
Moved canonical.launchpad.scripts __init__ to lp.services.scripts.
20
from lp.services.scripts import execute_zcml_for_scripts
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
21
from lp.services.webapp.publisher import canonical_url
8555.2.12 by Tim Penhey
Fix cronscripts and utilities too.
22
from lp.code.enums import BranchType
8508.1.1 by Jonathan Lange
Fix up imports, avoiding circular import.
23
from lp.code.interfaces.branchlookup import IBranchLookup
24
from lp.codehosting.vfs import branch_id_to_path
7444.4.2 by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad.
25
26
27
def main(args):
28
    branch_url = args[1]
29
    execute_zcml_for_scripts()
7940.2.17 by Jonathan Lange
Remove __getitem__ from BranchSet interface.
30
    branch_lookup = getUtility(IBranchLookup)
31
    branch = branch_lookup.getByUrl(branch_url)
7444.4.2 by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad.
32
    if branch is None:
33
        print "Could not find branch at %r" % (branch_url,)
34
        return
35
    print branch.bzr_identity
36
    print
37
    print 'Unique name:', branch.unique_name
38
    print 'ID:', branch.id
39
    print 'Private:', branch.private
40
    print 'Type:', branch.branch_type
41
    print 'URL:', canonical_url(branch)
42
    if branch.url is not None:
43
        print 'External URL:', branch.url
44
    branch_path = branch_id_to_path(branch.id)
7732.1.3 by Jonathan Lange
Get rid of the branchesdest config variable.
45
    mirrored_path = join(
46
        config.codehosting.mirrored_branches_root, branch_path)
7444.4.2 by Jonathan Lange
Add a simple utility for getting information about a branch on Launchpad.
47
    print 'Mirrored copy:', mirrored_path
48
49
50
if __name__ == '__main__':
51
    main(sys.argv)