1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """Module for relax version information."""
24
25
26 import dep_check
27
28
29 from os import F_OK, access, sep
30 PIPE, Popen = None, None
31 if dep_check.subprocess_module:
32 from subprocess import PIPE, Popen
33
34
35 from status import Status; status = Status()
36
37
38 version = "2.1.2"
39
40
42 """Attempt to retrieve the SVN revision number, if this is a checked out copy.
43
44 @return: The SVN revision number, or None if unsuccessful.
45 @rtype: None or str
46 """
47
48
49 if not access(status.install_path+sep+'.svn', F_OK):
50 return
51
52
53 if Popen == None:
54 return
55
56
57 pipe = Popen('svn info %s' % status.install_path, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
58
59
60 if pipe.stderr.readlines():
61 return
62
63
64 for line in pipe.stdout.readlines():
65
66 row = line.split()
67
68
69 if len(row) and row[0] == 'Revision:':
70 return row[1]
71
72
74 """Attempt to retrieve the SVN URL, if this is a checked out copy.
75
76 @return: The SVN URL, or None if unsuccessful.
77 @rtype: None or str
78 """
79
80
81 if not access(status.install_path+sep+'.svn', F_OK):
82 return
83
84
85 if Popen == None:
86 return
87
88
89 pipe = Popen('svn info %s' % status.install_path, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
90
91
92 if pipe.stderr.readlines():
93 return
94
95
96 for line in pipe.stdout.readlines():
97
98 row = line.split()
99
100
101 if len(row) and row[0] == 'URL:':
102 return row[1]
103
104
106 """Return the full relax version, including all SVN info for repository versions.
107
108 @return: The relax version string.
109 @rtype: str
110 """
111
112
113 ver = version
114
115
116 if ver == 'repository checkout':
117
118 svn_rev = revision()
119 svn_url = url()
120
121
122 if svn_rev:
123 ver = version + " r" + svn_rev
124 if svn_url:
125 ver = ver + " " + svn_url
126
127
128 return ver
129