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 = "3.1.7"
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 if hasattr(line, 'decode'):
67 line = line.decode()
68
69
70 row = line.split()
71
72
73 if len(row) and row[0] == 'Revision:':
74 return str(row[1])
75
76
78 """Attempt to retrieve the SVN URL, if this is a checked out copy.
79
80 @return: The SVN URL, or None if unsuccessful.
81 @rtype: None or str
82 """
83
84
85 if not access(status.install_path+sep+'.svn', F_OK):
86 return
87
88
89 if Popen == None:
90 return
91
92
93 pipe = Popen('svn info %s' % status.install_path, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
94
95
96 if pipe.stderr.readlines():
97 return
98
99
100 for line in pipe.stdout.readlines():
101
102 if hasattr(line, 'decode'):
103 line = line.decode()
104
105
106 row = line.split()
107
108
109 if len(row) and row[0] == 'URL:':
110 return str(row[1])
111
112
114 """Return the full relax version, including all SVN info for repository versions.
115
116 @return: The relax version string.
117 @rtype: str
118 """
119
120
121 ver = version
122
123
124 if ver == 'repository checkout':
125
126 svn_rev = revision()
127 svn_url = url()
128
129
130 if svn_rev:
131 ver = version + " r" + svn_rev
132 if svn_url:
133 ver = ver + " " + svn_url
134
135
136 return ver
137