10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
8687.15.22
by Karl Fogel
Add the copyright header block to the remaining .py 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 |
||
7109.3.10
by Jonathan Lange
Disable lint. |
6 |
# pylint: disable-msg=W0403
|
7109.3.2
by Jonathan Lange
Docstrings and coding standard compliance. |
7 |
|
8 |
"""List the stacked branches in Launchpad.
|
|
9 |
||
10 |
Usage: ./get-stacked-on-branches.py
|
|
11 |
||
12 |
Prints the stacked branches in Launchpad to standard output in the following
|
|
13 |
format:
|
|
12707.8.2
by Tim Penhey
Update the stacking fixit scripts. |
14 |
<id> <branch_type> <unique_name> <stacked_on_id> <stacked_on_unique_name>
|
7109.3.2
by Jonathan Lange
Docstrings and coding standard compliance. |
15 |
|
16 |
<id> is the database ID of the Branch as a decimal integer.
|
|
17 |
<branch_type> is the name of the BranchType, e.g. 'HOSTED'.
|
|
18 |
<unique_name> is the unique_name property of the Branch.
|
|
12707.8.2
by Tim Penhey
Update the stacking fixit scripts. |
19 |
<stacked_on_id> is the database ID of the Branch.stacked_on branch
|
7109.3.2
by Jonathan Lange
Docstrings and coding standard compliance. |
20 |
<stacked_on_unique_name> is the unique_name property of the Branch.stacked_on
|
21 |
branch.
|
|
22 |
||
23 |
This script is intended to be used in conjunction with "update-stacked-on.py".
|
|
24 |
"""
|
|
25 |
||
26 |
__metaclass__ = type |
|
27 |
||
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
28 |
import _pythonpath |
29 |
||
30 |
from storm.locals import Not |
|
31 |
from zope.component import getUtility |
|
32 |
||
33 |
from canonical.launchpad.scripts import execute_zcml_for_scripts |
|
34 |
from canonical.launchpad.webapp.interfaces import ( |
|
35 |
IStoreSelector, MAIN_STORE, SLAVE_FLAVOR) |
|
36 |
||
37 |
||
38 |
def get_stacked_branches(): |
|
7109.3.2
by Jonathan Lange
Docstrings and coding standard compliance. |
39 |
"""Iterate over all branches that, according to the db, are stacked."""
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
40 |
# Avoiding circular import.
|
41 |
from lp.code.model.branch import Branch |
|
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
42 |
store = getUtility(IStoreSelector).get(MAIN_STORE, SLAVE_FLAVOR) |
43 |
return store.find(Branch, Not(Branch.stacked_on == None)) |
|
44 |
||
45 |
||
46 |
def main(): |
|
7109.3.2
by Jonathan Lange
Docstrings and coding standard compliance. |
47 |
"""Print all stacked branches from the database.
|
48 |
||
49 |
See the module docstring for more information.
|
|
50 |
"""
|
|
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
51 |
execute_zcml_for_scripts() |
52 |
for db_branch in get_stacked_branches(): |
|
12707.8.2
by Tim Penhey
Update the stacking fixit scripts. |
53 |
stacked_on = db_branch.stacked_on |
54 |
print '%s %s %s %s %s' % ( |
|
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
55 |
db_branch.id, db_branch.branch_type.name, db_branch.unique_name, |
12707.8.2
by Tim Penhey
Update the stacking fixit scripts. |
56 |
stacked_on.id, stacked_on.unique_name) |
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
57 |
|
58 |
||
59 |
if __name__ == '__main__': |
|
60 |
main() |