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