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 |
||
14565.2.15
by Curtis Hovey
Moved canonical.launchpad.scripts __init__ to lp.services.scripts. |
33 |
from lp.services.scripts import execute_zcml_for_scripts |
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
34 |
from lp.services.webapp.interfaces import ( |
14612.2.7
by William Grant
scripts |
35 |
IStoreSelector, |
36 |
MAIN_STORE, |
|
37 |
SLAVE_FLAVOR, |
|
38 |
)
|
|
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
39 |
|
40 |
||
41 |
def get_stacked_branches(): |
|
7109.3.2
by Jonathan Lange
Docstrings and coding standard compliance. |
42 |
"""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. |
43 |
# Avoiding circular import.
|
44 |
from lp.code.model.branch import Branch |
|
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
45 |
store = getUtility(IStoreSelector).get(MAIN_STORE, SLAVE_FLAVOR) |
46 |
return store.find(Branch, Not(Branch.stacked_on == None)) |
|
47 |
||
48 |
||
49 |
def main(): |
|
7109.3.2
by Jonathan Lange
Docstrings and coding standard compliance. |
50 |
"""Print all stacked branches from the database.
|
51 |
||
52 |
See the module docstring for more information.
|
|
53 |
"""
|
|
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
54 |
execute_zcml_for_scripts() |
55 |
for db_branch in get_stacked_branches(): |
|
12707.8.2
by Tim Penhey
Update the stacking fixit scripts. |
56 |
stacked_on = db_branch.stacked_on |
57 |
print '%s %s %s %s %s' % ( |
|
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
58 |
db_branch.id, db_branch.branch_type.name, db_branch.unique_name, |
12707.8.2
by Tim Penhey
Update the stacking fixit scripts. |
59 |
stacked_on.id, stacked_on.unique_name) |
7109.3.1
by Jonathan Lange
Initial version of stacking update scripts. |
60 |
|
61 |
||
62 |
if __name__ == '__main__': |
|
63 |
main() |