12046.1.2
by Danilo Segan
Make version info reading CWD-independent. |
1 |
# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
|
8687.15.18
by Karl Fogel
Add the copyright header block to files under lib/canonical/. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
3 |
||
9297.2.1
by Barry Warsaw
Get base template release number from the version.txt file instead of hard |
4 |
"""Give access to bzr and other version info, if available.
|
3618.1.44
by Steve Alexander
add revno to main template |
5 |
|
6 |
The bzr version info file is expected to be in the Launchpad root in the
|
|
7 |
file bzr-version-info.py.
|
|
8 |
||
9 |
From this module, you can get:
|
|
10 |
||
11 |
versioninfo: the version_info dict
|
|
12 |
revno: the revision number
|
|
13 |
date: the date of the last revision
|
|
4962.2.1
by Diogo Matsubara
[r=kiko] Add revision number and branch nickname to oops reports |
14 |
branch_nick: the branch nickname
|
15 |
||
16 |
If the bzr-version-info.py file does not exist, then revno, date and
|
|
17 |
branch_nick will all be None.
|
|
18 |
||
9297.2.1
by Barry Warsaw
Get base template release number from the version.txt file instead of hard |
19 |
If that file exists, and contains valid Python, revno, date and branch_nick
|
4962.2.1
by Diogo Matsubara
[r=kiko] Add revision number and branch nickname to oops reports |
20 |
will have appropriate values from version_info.
|
3618.1.44
by Steve Alexander
add revno to main template |
21 |
|
9297.2.1
by Barry Warsaw
Get base template release number from the version.txt file instead of hard |
22 |
If that file exists, and contains invalid Python, there will be an error when
|
12408.1.3
by Jonathan Lange
version.txt is unused. |
23 |
this module is loaded. This module is imported into lp/app/__init__.py so
|
24 |
that such errors are caught at start-up.
|
|
3618.1.44
by Steve Alexander
add revno to main template |
25 |
"""
|
26 |
||
9297.2.1
by Barry Warsaw
Get base template release number from the version.txt file instead of hard |
27 |
__all__ = [ |
28 |
'branch_nick', |
|
29 |
'date', |
|
30 |
'revno', |
|
31 |
'versioninfo', |
|
32 |
]
|
|
33 |
||
34 |
||
3618.1.44
by Steve Alexander
add revno to main template |
35 |
def read_version_info(): |
36 |
try: |
|
12046.1.2
by Danilo Segan
Make version info reading CWD-independent. |
37 |
import launchpadversioninfo |
12046.1.3
by Danilo Segan
Fix lint issue. |
38 |
except ImportError: |
3618.1.44
by Steve Alexander
add revno to main template |
39 |
return None |
40 |
else: |
|
12046.1.2
by Danilo Segan
Make version info reading CWD-independent. |
41 |
return getattr(launchpadversioninfo, 'version_info', None) |
3618.1.44
by Steve Alexander
add revno to main template |
42 |
|
43 |
||
44 |
versioninfo = read_version_info() |
|
45 |
||
46 |
||
47 |
if versioninfo is None: |
|
48 |
revno = None |
|
49 |
date = None |
|
4962.2.1
by Diogo Matsubara
[r=kiko] Add revision number and branch nickname to oops reports |
50 |
branch_nick = None |
3618.1.44
by Steve Alexander
add revno to main template |
51 |
else: |
52 |
revno = versioninfo.get('revno') |
|
53 |
date = versioninfo.get('date') |
|
4962.2.1
by Diogo Matsubara
[r=kiko] Add revision number and branch nickname to oops reports |
54 |
branch_nick = versioninfo.get('branch_nick') |