Belle II Software
release-05-01-25
information.py
1
import
re
2
from
datetime
import
datetime
3
from
subprocess
import
check_output
4
5
6
class
EnvironmentInformation
:
7
8
"""
9
Helper class for accessing the information about the environment.
10
"""
11
12
def
__init__
(self):
13
"""
14
Get the variables from the environment variables.
15
"""
16
17
self.
externals_version
=
""
18
19
self.
externals_option
=
""
20
21
self.
option
=
""
22
23
self.
architecture
=
""
24
25
self.
release
=
""
26
27
self.
release_folder
=
""
28
29
self.
_cached_revision
=
""
30
31
@property
32
def
revision_number
(self):
33
"""
34
Get the cached revision number from SVN or get it from SVN directly.
35
"""
36
if
not
self.
_cached_revision
:
37
self.
_cached_revision
= self.
get_current_revision_number
()
38
39
return
self.
_cached_revision
40
41
def
__str__
(self):
42
"""
43
A nice representation.
44
"""
45
result =
""
46
result +=
"externals version: "
+ self.
externals_version
+
"\n"
47
result +=
"externals option: "
+ self.
externals_option
+
"\n"
48
result +=
"option: "
+ self.
option
+
"\n"
49
result +=
"architecture: "
+ self.
architecture
+
"\n"
50
result +=
"release: "
+ self.
release
+
"\n"
51
result +=
"release folder: "
+ self.
release_folder
+
"\n"
52
result +=
"revision number: "
+ self.
revision_number
+
"\n"
53
result +=
"date: "
+ datetime.now().strftime(
"%Y-%m-%d"
) +
"\n"
54
return
result
55
56
def
__repr__
(self):
57
"""
58
Also for ipython.
59
"""
60
return
self.
__str__
()
61
62
def
get_current_revision_number
(self):
63
"""
64
Try to download the current revision number from SVN.
65
"""
66
try
:
67
return
check_output([
"git"
,
"log"
,
"-1"
,
"--format='%H'"
], cwd=self.
release_folder
).decode()
68
except
:
69
return
""
hep_ipython_tools.information.EnvironmentInformation.get_current_revision_number
def get_current_revision_number(self)
Definition:
information.py:62
hep_ipython_tools.information.EnvironmentInformation.release
release
Release version.
Definition:
information.py:25
hep_ipython_tools.information.EnvironmentInformation
Definition:
information.py:6
hep_ipython_tools.information.EnvironmentInformation.externals_version
externals_version
Externals version.
Definition:
information.py:17
hep_ipython_tools.information.EnvironmentInformation.architecture
architecture
OS.
Definition:
information.py:23
hep_ipython_tools.information.EnvironmentInformation.__repr__
def __repr__(self)
Definition:
information.py:56
hep_ipython_tools.information.EnvironmentInformation.externals_option
externals_option
Compile options of externals.
Definition:
information.py:19
hep_ipython_tools.information.EnvironmentInformation.release_folder
release_folder
Release folder.
Definition:
information.py:27
hep_ipython_tools.information.EnvironmentInformation._cached_revision
_cached_revision
Revision number (cached, the real getter is the property)
Definition:
information.py:29
hep_ipython_tools.information.EnvironmentInformation.__init__
def __init__(self)
Definition:
information.py:12
hep_ipython_tools.information.EnvironmentInformation.__str__
def __str__(self)
Definition:
information.py:41
hep_ipython_tools.information.EnvironmentInformation.revision_number
def revision_number(self)
Definition:
information.py:32
hep_ipython_tools.information.EnvironmentInformation.option
option
Compile options.
Definition:
information.py:21
framework
scripts
hep_ipython_tools
information.py
Generated on Fri Nov 5 2021 03:52:49 for Belle II Software by
1.8.17