Belle II Software development
information.py
1
8from datetime import datetime
9from subprocess import check_output
10
11
13
14 """
15 Helper class for accessing the information about the environment.
16 """
17
18 def __init__(self):
19 """
20 Get the variables from the environment variables.
21 """
22
24
26
27 self.option = ""
28
29 self.architecture = ""
30
31 self.release = ""
32
34
36
37 @property
38 def revision_number(self):
39 """
40 Get the cached revision number from SVN or get it from SVN directly.
41 """
42 if not self._cached_revision:
44
45 return self._cached_revision
46
47 def __str__(self):
48 """
49 A nice representation.
50 """
51 result = ""
52 result += "externals version: " + self.externals_version + "\n"
53 result += "externals option: " + self.externals_option + "\n"
54 result += "option: " + self.option + "\n"
55 result += "architecture: " + self.architecture + "\n"
56 result += "release: " + self.release + "\n"
57 result += "release folder: " + self.release_folder + "\n"
58 result += "revision number: " + self.revision_number + "\n"
59 result += "date: " + datetime.now().strftime("%Y-%m-%d") + "\n"
60 return result
61
62 def __repr__(self):
63 """
64 Also for ipython.
65 """
66 return self.__str__()
67
69 """
70 Try to download the current revision number from SVN.
71 """
72 try:
73 return check_output(["git", "log", "-1", "--format='%H'"], cwd=self.release_folder).decode()
74 except BaseException:
75 return ""
_cached_revision
Revision number (cached, the real getter is the property)
Definition: information.py:35