logger-36 2024.1__py3-none-any.whl → 2025.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- logger_36/__init__.py +64 -42
- logger_36/api/logger.py +53 -0
- logger_36/api/storage.py +53 -0
- logger_36/catalog/config/console_rich.py +76 -0
- logger_36/catalog/handler/console.py +117 -0
- logger_36/catalog/handler/console_rich.py +235 -0
- logger_36/catalog/handler/file.py +128 -0
- logger_36/catalog/handler/generic.py +228 -0
- logger_36/catalog/logger/chronos.py +61 -0
- logger_36/catalog/logger/gpu.py +90 -0
- logger_36/catalog/logger/memory.py +129 -0
- logger_36/catalog/logger/system.py +84 -0
- logger_36/config/issue.py +56 -0
- logger_36/config/logger.py +103 -0
- logger_36/config/memory.py +54 -0
- logger_36/config/message.py +66 -0
- logger_36/config/system.py +70 -0
- logger_36/constant/error.py +70 -0
- logger_36/constant/generic.py +58 -0
- logger_36/constant/handler.py +58 -0
- logger_36/constant/issue.py +58 -0
- logger_36/constant/logger.py +67 -0
- logger_36/constant/memory.py +58 -0
- logger_36/constant/message.py +72 -0
- logger_36/constant/record.py +55 -0
- logger_36/constant/system.py +60 -0
- logger_36/content.py +55 -0
- logger_36/exception.py +105 -0
- logger_36/gpu.py +53 -0
- logger_36/handler.py +209 -0
- logger_36/instance/logger.py +55 -0
- logger_36/instance/loggers.py +56 -0
- logger_36/memory.py +60 -0
- logger_36/storage.py +53 -0
- logger_36/system.py +53 -0
- logger_36/task/format/memory.py +132 -0
- logger_36/task/format/message.py +111 -0
- logger_36/task/format/rule.py +74 -0
- logger_36/task/inspection.py +70 -48
- logger_36/task/measure/chronos.py +84 -0
- logger_36/task/measure/memory.py +72 -0
- logger_36/task/storage.py +127 -46
- logger_36/time.py +54 -0
- logger_36/type/handler.py +184 -0
- logger_36/type/issue.py +91 -0
- logger_36/type/logger.py +542 -0
- logger_36/type/loggers.py +78 -0
- logger_36/version.py +53 -32
- logger_36-2025.3.dist-info/METADATA +154 -0
- logger_36-2025.3.dist-info/RECORD +52 -0
- {logger_36-2024.1.dist-info → logger_36-2025.3.dist-info}/WHEEL +1 -1
- logger_36/catalog/gpu.py +0 -56
- logger_36/catalog/memory.py +0 -109
- logger_36/catalog/system.py +0 -84
- logger_36/config.py +0 -48
- logger_36/constant.py +0 -52
- logger_36/instance.py +0 -34
- logger_36/main.py +0 -96
- logger_36/measure/chronos.py +0 -55
- logger_36/measure/memory.py +0 -50
- logger_36/type/console.py +0 -122
- logger_36/type/extension.py +0 -122
- logger_36/type/file.py +0 -52
- logger_36/type/generic.py +0 -115
- logger_36-2024.1.dist-info/METADATA +0 -106
- logger_36-2024.1.dist-info/RECORD +0 -21
- {logger_36-2024.1.dist-info → logger_36-2025.3.dist-info}/top_level.txt +0 -0
logger_36/handler.py
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
import logging as lggg
|
8
|
+
import sys as sstm
|
9
|
+
from pathlib import Path as path_t
|
10
|
+
|
11
|
+
from logger_36.catalog.handler.console import console_handler_t
|
12
|
+
from logger_36.catalog.handler.file import file_handler_t
|
13
|
+
from logger_36.catalog.handler.generic import generic_handler_t, show_message_p
|
14
|
+
from logger_36.constant.error import MISSING_RICH_ERROR
|
15
|
+
from logger_36.instance.logger import LOGGER
|
16
|
+
|
17
|
+
try:
|
18
|
+
from logger_36.catalog.handler.console_rich import console_rich_handler_t
|
19
|
+
|
20
|
+
_MISSING_RICH_ERROR = None
|
21
|
+
except ModuleNotFoundError:
|
22
|
+
from logger_36.catalog.handler.console import (
|
23
|
+
console_handler_t as console_rich_handler_t,
|
24
|
+
)
|
25
|
+
|
26
|
+
_MISSING_RICH_ERROR = MISSING_RICH_ERROR
|
27
|
+
|
28
|
+
|
29
|
+
def AddGenericHandler(
|
30
|
+
ShowMessage: show_message_p,
|
31
|
+
/,
|
32
|
+
*,
|
33
|
+
logger: lggg.Logger | None = None,
|
34
|
+
name: str | None = None,
|
35
|
+
level: int = lggg.INFO,
|
36
|
+
should_store_memory_usage: bool = False,
|
37
|
+
message_width: int = -1,
|
38
|
+
formatter: lggg.Formatter | None = None,
|
39
|
+
supports_html: bool = False,
|
40
|
+
alternating_lines: int = 2,
|
41
|
+
should_record: bool = False,
|
42
|
+
should_hold_messages: bool = False,
|
43
|
+
**kwargs,
|
44
|
+
) -> None:
|
45
|
+
""""""
|
46
|
+
if logger is None:
|
47
|
+
logger = LOGGER
|
48
|
+
|
49
|
+
handler = generic_handler_t(
|
50
|
+
name=name,
|
51
|
+
level=level,
|
52
|
+
should_store_memory_usage=should_store_memory_usage,
|
53
|
+
message_width=message_width,
|
54
|
+
formatter=formatter,
|
55
|
+
supports_html=supports_html,
|
56
|
+
alternating_lines=alternating_lines,
|
57
|
+
should_record=should_record,
|
58
|
+
rich_kwargs=kwargs,
|
59
|
+
ShowMessage=ShowMessage,
|
60
|
+
)
|
61
|
+
logger.AddHandler(handler, should_hold_messages)
|
62
|
+
|
63
|
+
|
64
|
+
def AddConsoleHandler(
|
65
|
+
*,
|
66
|
+
logger: lggg.Logger | None = None,
|
67
|
+
name: str | None = None,
|
68
|
+
level: int = lggg.INFO,
|
69
|
+
should_store_memory_usage: bool = False,
|
70
|
+
message_width: int = -1,
|
71
|
+
formatter: lggg.Formatter | None = None,
|
72
|
+
should_hold_messages: bool = False,
|
73
|
+
) -> None:
|
74
|
+
""""""
|
75
|
+
if logger is None:
|
76
|
+
logger = LOGGER
|
77
|
+
|
78
|
+
handler = console_handler_t(
|
79
|
+
name=name,
|
80
|
+
level=level,
|
81
|
+
should_store_memory_usage=should_store_memory_usage,
|
82
|
+
message_width=message_width,
|
83
|
+
formatter=formatter,
|
84
|
+
)
|
85
|
+
logger.AddHandler(handler, should_hold_messages)
|
86
|
+
|
87
|
+
|
88
|
+
def AddRichConsoleHandler(
|
89
|
+
*,
|
90
|
+
logger: lggg.Logger | None = None,
|
91
|
+
name: str | None = None,
|
92
|
+
level: int = lggg.INFO,
|
93
|
+
should_store_memory_usage: bool = False,
|
94
|
+
message_width: int = -1,
|
95
|
+
formatter: lggg.Formatter | None = None,
|
96
|
+
alternating_lines: int = 2,
|
97
|
+
should_hold_messages: bool = False,
|
98
|
+
should_install_traceback: bool = False,
|
99
|
+
should_record: bool = False,
|
100
|
+
**kwargs,
|
101
|
+
) -> None:
|
102
|
+
""""""
|
103
|
+
global _MISSING_RICH_ERROR
|
104
|
+
if _MISSING_RICH_ERROR is not None:
|
105
|
+
print(_MISSING_RICH_ERROR, file=sstm.stderr)
|
106
|
+
_MISSING_RICH_ERROR = None
|
107
|
+
|
108
|
+
if logger is None:
|
109
|
+
logger = LOGGER
|
110
|
+
|
111
|
+
if console_rich_handler_t is console_handler_t:
|
112
|
+
additional_s = {}
|
113
|
+
else:
|
114
|
+
additional_s = {
|
115
|
+
"alternating_lines": alternating_lines,
|
116
|
+
"should_install_traceback": should_install_traceback,
|
117
|
+
"should_record": should_record,
|
118
|
+
"rich_kwargs": kwargs,
|
119
|
+
}
|
120
|
+
handler = console_rich_handler_t(
|
121
|
+
name=name,
|
122
|
+
level=level,
|
123
|
+
should_store_memory_usage=should_store_memory_usage,
|
124
|
+
message_width=message_width,
|
125
|
+
formatter=formatter,
|
126
|
+
**additional_s,
|
127
|
+
)
|
128
|
+
logger.AddHandler(handler, should_hold_messages)
|
129
|
+
|
130
|
+
|
131
|
+
def AddFileHandler(
|
132
|
+
path: str | path_t,
|
133
|
+
/,
|
134
|
+
*args,
|
135
|
+
logger: lggg.Logger | None = None,
|
136
|
+
name: str | None = None,
|
137
|
+
level: int = lggg.INFO,
|
138
|
+
should_store_memory_usage: bool = False,
|
139
|
+
message_width: int = -1,
|
140
|
+
formatter: lggg.Formatter | None = None,
|
141
|
+
should_hold_messages: bool = False,
|
142
|
+
**kwargs,
|
143
|
+
) -> None:
|
144
|
+
""""""
|
145
|
+
if isinstance(path, str):
|
146
|
+
path = path_t(path)
|
147
|
+
if path.exists():
|
148
|
+
raise ValueError(f"File or folder already exists: {path}.")
|
149
|
+
if logger is None:
|
150
|
+
logger = LOGGER
|
151
|
+
|
152
|
+
handler = file_handler_t(
|
153
|
+
name=name,
|
154
|
+
level=level,
|
155
|
+
should_store_memory_usage=should_store_memory_usage,
|
156
|
+
message_width=message_width,
|
157
|
+
formatter=formatter,
|
158
|
+
path=path,
|
159
|
+
handler_args=args,
|
160
|
+
handler_kwargs=kwargs,
|
161
|
+
)
|
162
|
+
logger.AddHandler(handler, should_hold_messages)
|
163
|
+
|
164
|
+
|
165
|
+
"""
|
166
|
+
COPYRIGHT NOTICE
|
167
|
+
|
168
|
+
This software is governed by the CeCILL license under French law and
|
169
|
+
abiding by the rules of distribution of free software. You can use,
|
170
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
171
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
172
|
+
"http://www.cecill.info".
|
173
|
+
|
174
|
+
As a counterpart to the access to the source code and rights to copy,
|
175
|
+
modify and redistribute granted by the license, users are provided only
|
176
|
+
with a limited warranty and the software's author, the holder of the
|
177
|
+
economic rights, and the successive licensors have only limited
|
178
|
+
liability.
|
179
|
+
|
180
|
+
In this respect, the user's attention is drawn to the risks associated
|
181
|
+
with loading, using, modifying and/or developing or reproducing the
|
182
|
+
software by the user in light of its specific status of free software,
|
183
|
+
that may mean that it is complicated to manipulate, and that also
|
184
|
+
therefore means that it is reserved for developers and experienced
|
185
|
+
professionals having in-depth computer knowledge. Users are therefore
|
186
|
+
encouraged to load and test the software's suitability as regards their
|
187
|
+
requirements in conditions enabling the security of their systems and/or
|
188
|
+
data to be ensured and, more generally, to use and operate it in the
|
189
|
+
same conditions as regards security.
|
190
|
+
|
191
|
+
The fact that you are presently reading this means that you have had
|
192
|
+
knowledge of the CeCILL license and that you accept its terms.
|
193
|
+
|
194
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
195
|
+
|
196
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
197
|
+
member of team Morpheme.
|
198
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
199
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
200
|
+
I3S, and Laboratory iBV.
|
201
|
+
|
202
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
203
|
+
Inria: https://www.inria.fr/en/
|
204
|
+
UniCA: https://univ-cotedazur.eu/
|
205
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
206
|
+
I3S: https://www.i3s.unice.fr/en/
|
207
|
+
iBV: http://ibv.unice.fr/
|
208
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
209
|
+
"""
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
from logger_36.type.logger import logger_t
|
8
|
+
|
9
|
+
LOGGER = logger_t()
|
10
|
+
|
11
|
+
"""
|
12
|
+
COPYRIGHT NOTICE
|
13
|
+
|
14
|
+
This software is governed by the CeCILL license under French law and
|
15
|
+
abiding by the rules of distribution of free software. You can use,
|
16
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
17
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
18
|
+
"http://www.cecill.info".
|
19
|
+
|
20
|
+
As a counterpart to the access to the source code and rights to copy,
|
21
|
+
modify and redistribute granted by the license, users are provided only
|
22
|
+
with a limited warranty and the software's author, the holder of the
|
23
|
+
economic rights, and the successive licensors have only limited
|
24
|
+
liability.
|
25
|
+
|
26
|
+
In this respect, the user's attention is drawn to the risks associated
|
27
|
+
with loading, using, modifying and/or developing or reproducing the
|
28
|
+
software by the user in light of its specific status of free software,
|
29
|
+
that may mean that it is complicated to manipulate, and that also
|
30
|
+
therefore means that it is reserved for developers and experienced
|
31
|
+
professionals having in-depth computer knowledge. Users are therefore
|
32
|
+
encouraged to load and test the software's suitability as regards their
|
33
|
+
requirements in conditions enabling the security of their systems and/or
|
34
|
+
data to be ensured and, more generally, to use and operate it in the
|
35
|
+
same conditions as regards security.
|
36
|
+
|
37
|
+
The fact that you are presently reading this means that you have had
|
38
|
+
knowledge of the CeCILL license and that you accept its terms.
|
39
|
+
|
40
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
41
|
+
|
42
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
43
|
+
member of team Morpheme.
|
44
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
45
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
46
|
+
I3S, and Laboratory iBV.
|
47
|
+
|
48
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
49
|
+
Inria: https://www.inria.fr/en/
|
50
|
+
UniCA: https://univ-cotedazur.eu/
|
51
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
52
|
+
I3S: https://www.i3s.unice.fr/en/
|
53
|
+
iBV: http://ibv.unice.fr/
|
54
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
55
|
+
"""
|
@@ -0,0 +1,56 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
from logger_36.type.loggers import loggers_t
|
8
|
+
|
9
|
+
LOGGERS = loggers_t()
|
10
|
+
|
11
|
+
|
12
|
+
"""
|
13
|
+
COPYRIGHT NOTICE
|
14
|
+
|
15
|
+
This software is governed by the CeCILL license under French law and
|
16
|
+
abiding by the rules of distribution of free software. You can use,
|
17
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
18
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
19
|
+
"http://www.cecill.info".
|
20
|
+
|
21
|
+
As a counterpart to the access to the source code and rights to copy,
|
22
|
+
modify and redistribute granted by the license, users are provided only
|
23
|
+
with a limited warranty and the software's author, the holder of the
|
24
|
+
economic rights, and the successive licensors have only limited
|
25
|
+
liability.
|
26
|
+
|
27
|
+
In this respect, the user's attention is drawn to the risks associated
|
28
|
+
with loading, using, modifying and/or developing or reproducing the
|
29
|
+
software by the user in light of its specific status of free software,
|
30
|
+
that may mean that it is complicated to manipulate, and that also
|
31
|
+
therefore means that it is reserved for developers and experienced
|
32
|
+
professionals having in-depth computer knowledge. Users are therefore
|
33
|
+
encouraged to load and test the software's suitability as regards their
|
34
|
+
requirements in conditions enabling the security of their systems and/or
|
35
|
+
data to be ensured and, more generally, to use and operate it in the
|
36
|
+
same conditions as regards security.
|
37
|
+
|
38
|
+
The fact that you are presently reading this means that you have had
|
39
|
+
knowledge of the CeCILL license and that you accept its terms.
|
40
|
+
|
41
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
42
|
+
|
43
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
44
|
+
member of team Morpheme.
|
45
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
46
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
47
|
+
I3S, and Laboratory iBV.
|
48
|
+
|
49
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
50
|
+
Inria: https://www.inria.fr/en/
|
51
|
+
UniCA: https://univ-cotedazur.eu/
|
52
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
53
|
+
I3S: https://www.i3s.unice.fr/en/
|
54
|
+
iBV: http://ibv.unice.fr/
|
55
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
56
|
+
"""
|
logger_36/memory.py
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
from logger_36.catalog.logger.memory import LogMaximumMemoryUsage, LogMemoryUsages
|
8
|
+
from logger_36.task.format.memory import FormattedUsage as FormattedMemoryUsage
|
9
|
+
from logger_36.task.format.memory import (
|
10
|
+
FormattedUsageWithAutoUnit as FormattedMemoryUsageWithAutoUnit,
|
11
|
+
)
|
12
|
+
from logger_36.task.format.memory import UsageBar as MemoryUsageBar
|
13
|
+
from logger_36.task.measure.memory import CanCheckUsage as CanCheckMemoryUsage
|
14
|
+
from logger_36.task.measure.memory import CurrentUsage as CurrentMemoryUsage
|
15
|
+
|
16
|
+
"""
|
17
|
+
COPYRIGHT NOTICE
|
18
|
+
|
19
|
+
This software is governed by the CeCILL license under French law and
|
20
|
+
abiding by the rules of distribution of free software. You can use,
|
21
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
22
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
23
|
+
"http://www.cecill.info".
|
24
|
+
|
25
|
+
As a counterpart to the access to the source code and rights to copy,
|
26
|
+
modify and redistribute granted by the license, users are provided only
|
27
|
+
with a limited warranty and the software's author, the holder of the
|
28
|
+
economic rights, and the successive licensors have only limited
|
29
|
+
liability.
|
30
|
+
|
31
|
+
In this respect, the user's attention is drawn to the risks associated
|
32
|
+
with loading, using, modifying and/or developing or reproducing the
|
33
|
+
software by the user in light of its specific status of free software,
|
34
|
+
that may mean that it is complicated to manipulate, and that also
|
35
|
+
therefore means that it is reserved for developers and experienced
|
36
|
+
professionals having in-depth computer knowledge. Users are therefore
|
37
|
+
encouraged to load and test the software's suitability as regards their
|
38
|
+
requirements in conditions enabling the security of their systems and/or
|
39
|
+
data to be ensured and, more generally, to use and operate it in the
|
40
|
+
same conditions as regards security.
|
41
|
+
|
42
|
+
The fact that you are presently reading this means that you have had
|
43
|
+
knowledge of the CeCILL license and that you accept its terms.
|
44
|
+
|
45
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
46
|
+
|
47
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
48
|
+
member of team Morpheme.
|
49
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
50
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
51
|
+
I3S, and Laboratory iBV.
|
52
|
+
|
53
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
54
|
+
Inria: https://www.inria.fr/en/
|
55
|
+
UniCA: https://univ-cotedazur.eu/
|
56
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
57
|
+
I3S: https://www.i3s.unice.fr/en/
|
58
|
+
iBV: http://ibv.unice.fr/
|
59
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
60
|
+
"""
|
logger_36/storage.py
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
from logger_36.task.storage import SaveLOGasHTML
|
8
|
+
|
9
|
+
"""
|
10
|
+
COPYRIGHT NOTICE
|
11
|
+
|
12
|
+
This software is governed by the CeCILL license under French law and
|
13
|
+
abiding by the rules of distribution of free software. You can use,
|
14
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
15
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
16
|
+
"http://www.cecill.info".
|
17
|
+
|
18
|
+
As a counterpart to the access to the source code and rights to copy,
|
19
|
+
modify and redistribute granted by the license, users are provided only
|
20
|
+
with a limited warranty and the software's author, the holder of the
|
21
|
+
economic rights, and the successive licensors have only limited
|
22
|
+
liability.
|
23
|
+
|
24
|
+
In this respect, the user's attention is drawn to the risks associated
|
25
|
+
with loading, using, modifying and/or developing or reproducing the
|
26
|
+
software by the user in light of its specific status of free software,
|
27
|
+
that may mean that it is complicated to manipulate, and that also
|
28
|
+
therefore means that it is reserved for developers and experienced
|
29
|
+
professionals having in-depth computer knowledge. Users are therefore
|
30
|
+
encouraged to load and test the software's suitability as regards their
|
31
|
+
requirements in conditions enabling the security of their systems and/or
|
32
|
+
data to be ensured and, more generally, to use and operate it in the
|
33
|
+
same conditions as regards security.
|
34
|
+
|
35
|
+
The fact that you are presently reading this means that you have had
|
36
|
+
knowledge of the CeCILL license and that you accept its terms.
|
37
|
+
|
38
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
39
|
+
|
40
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
41
|
+
member of team Morpheme.
|
42
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
43
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
44
|
+
I3S, and Laboratory iBV.
|
45
|
+
|
46
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
47
|
+
Inria: https://www.inria.fr/en/
|
48
|
+
UniCA: https://univ-cotedazur.eu/
|
49
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
50
|
+
I3S: https://www.i3s.unice.fr/en/
|
51
|
+
iBV: http://ibv.unice.fr/
|
52
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
53
|
+
"""
|
logger_36/system.py
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
from logger_36.catalog.logger.system import LogSystemDetails
|
8
|
+
|
9
|
+
"""
|
10
|
+
COPYRIGHT NOTICE
|
11
|
+
|
12
|
+
This software is governed by the CeCILL license under French law and
|
13
|
+
abiding by the rules of distribution of free software. You can use,
|
14
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
15
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
16
|
+
"http://www.cecill.info".
|
17
|
+
|
18
|
+
As a counterpart to the access to the source code and rights to copy,
|
19
|
+
modify and redistribute granted by the license, users are provided only
|
20
|
+
with a limited warranty and the software's author, the holder of the
|
21
|
+
economic rights, and the successive licensors have only limited
|
22
|
+
liability.
|
23
|
+
|
24
|
+
In this respect, the user's attention is drawn to the risks associated
|
25
|
+
with loading, using, modifying and/or developing or reproducing the
|
26
|
+
software by the user in light of its specific status of free software,
|
27
|
+
that may mean that it is complicated to manipulate, and that also
|
28
|
+
therefore means that it is reserved for developers and experienced
|
29
|
+
professionals having in-depth computer knowledge. Users are therefore
|
30
|
+
encouraged to load and test the software's suitability as regards their
|
31
|
+
requirements in conditions enabling the security of their systems and/or
|
32
|
+
data to be ensured and, more generally, to use and operate it in the
|
33
|
+
same conditions as regards security.
|
34
|
+
|
35
|
+
The fact that you are presently reading this means that you have had
|
36
|
+
knowledge of the CeCILL license and that you accept its terms.
|
37
|
+
|
38
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
39
|
+
|
40
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
41
|
+
member of team Morpheme.
|
42
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
43
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
44
|
+
I3S, and Laboratory iBV.
|
45
|
+
|
46
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
47
|
+
Inria: https://www.inria.fr/en/
|
48
|
+
UniCA: https://univ-cotedazur.eu/
|
49
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
50
|
+
I3S: https://www.i3s.unice.fr/en/
|
51
|
+
iBV: http://ibv.unice.fr/
|
52
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
53
|
+
"""
|
@@ -0,0 +1,132 @@
|
|
1
|
+
"""
|
2
|
+
Copyright CNRS/Inria/UniCA
|
3
|
+
Contributor(s): Eric Debreuve (eric.debreuve@cnrs.fr) since 2023
|
4
|
+
SEE COPYRIGHT NOTICE BELOW
|
5
|
+
"""
|
6
|
+
|
7
|
+
from logger_36.constant.memory import STORAGE_UNITS, storage_units_h
|
8
|
+
from logger_36.task.format.message import MessageWithActualExpected
|
9
|
+
|
10
|
+
_KILO_UNIT = 1000.0
|
11
|
+
_MEGA_UNIT = _KILO_UNIT * 1000.0
|
12
|
+
_GIGA_UNIT = _MEGA_UNIT * 1000.0
|
13
|
+
|
14
|
+
_BLOCKS_PARTIAL = ("", "▏", "▎", "▍", "▌", "▋", "▊")
|
15
|
+
_BLOCK_FULL = "▉"
|
16
|
+
|
17
|
+
|
18
|
+
def FormattedUsage(
|
19
|
+
usage: int,
|
20
|
+
/,
|
21
|
+
*,
|
22
|
+
unit: storage_units_h | None = "a",
|
23
|
+
decimals: int | None = None,
|
24
|
+
) -> tuple[int | float, str]:
|
25
|
+
"""
|
26
|
+
unit: b or None=bytes, k=kilo, m=mega, g=giga, a=auto
|
27
|
+
"""
|
28
|
+
if (unit is None) or (unit == "b"):
|
29
|
+
value = usage
|
30
|
+
unit = "B"
|
31
|
+
elif unit == "k":
|
32
|
+
value = _Rounded(usage / _KILO_UNIT, decimals)
|
33
|
+
unit = "KB"
|
34
|
+
elif unit == "m":
|
35
|
+
value = _Rounded(usage / _MEGA_UNIT, decimals)
|
36
|
+
unit = "MB"
|
37
|
+
elif unit == "g":
|
38
|
+
value = _Rounded(usage / _GIGA_UNIT, decimals)
|
39
|
+
unit = "GB"
|
40
|
+
elif unit == "a":
|
41
|
+
value, unit = FormattedUsageWithAutoUnit(usage, decimals)
|
42
|
+
else:
|
43
|
+
raise ValueError(
|
44
|
+
MessageWithActualExpected(
|
45
|
+
"Invalid unit", actual=unit, expected=str(STORAGE_UNITS)[1:-1]
|
46
|
+
)
|
47
|
+
)
|
48
|
+
|
49
|
+
return value, unit
|
50
|
+
|
51
|
+
|
52
|
+
def FormattedUsageWithAutoUnit(
|
53
|
+
usage: int, decimals: int | None, /
|
54
|
+
) -> tuple[int | float, str]:
|
55
|
+
""""""
|
56
|
+
if usage > _GIGA_UNIT:
|
57
|
+
return _Rounded(usage / _GIGA_UNIT, decimals), "GB"
|
58
|
+
|
59
|
+
if usage > _MEGA_UNIT:
|
60
|
+
return _Rounded(usage / _MEGA_UNIT, decimals), "MB"
|
61
|
+
|
62
|
+
if usage > _KILO_UNIT:
|
63
|
+
return _Rounded(usage / _KILO_UNIT, decimals), "KB"
|
64
|
+
|
65
|
+
return usage, "B"
|
66
|
+
|
67
|
+
|
68
|
+
def UsageBar(
|
69
|
+
usage: int | float, max_usage: int | float, /, *, length_100: int = 10
|
70
|
+
) -> str:
|
71
|
+
""""""
|
72
|
+
length = (usage / max_usage) * length_100
|
73
|
+
n_full_s = int(length)
|
74
|
+
return (
|
75
|
+
n_full_s * _BLOCK_FULL
|
76
|
+
+ _BLOCKS_PARTIAL[int((2.0 / 3.0) * int(10 * (length - n_full_s)))]
|
77
|
+
)
|
78
|
+
|
79
|
+
|
80
|
+
def _Rounded(value: float, decimals: int | None, /) -> int | float:
|
81
|
+
""""""
|
82
|
+
if decimals == 0:
|
83
|
+
decimals = None
|
84
|
+
|
85
|
+
return round(value, ndigits=decimals)
|
86
|
+
|
87
|
+
|
88
|
+
"""
|
89
|
+
COPYRIGHT NOTICE
|
90
|
+
|
91
|
+
This software is governed by the CeCILL license under French law and
|
92
|
+
abiding by the rules of distribution of free software. You can use,
|
93
|
+
modify and/ or redistribute the software under the terms of the CeCILL
|
94
|
+
license as circulated by CEA, CNRS and INRIA at the following URL
|
95
|
+
"http://www.cecill.info".
|
96
|
+
|
97
|
+
As a counterpart to the access to the source code and rights to copy,
|
98
|
+
modify and redistribute granted by the license, users are provided only
|
99
|
+
with a limited warranty and the software's author, the holder of the
|
100
|
+
economic rights, and the successive licensors have only limited
|
101
|
+
liability.
|
102
|
+
|
103
|
+
In this respect, the user's attention is drawn to the risks associated
|
104
|
+
with loading, using, modifying and/or developing or reproducing the
|
105
|
+
software by the user in light of its specific status of free software,
|
106
|
+
that may mean that it is complicated to manipulate, and that also
|
107
|
+
therefore means that it is reserved for developers and experienced
|
108
|
+
professionals having in-depth computer knowledge. Users are therefore
|
109
|
+
encouraged to load and test the software's suitability as regards their
|
110
|
+
requirements in conditions enabling the security of their systems and/or
|
111
|
+
data to be ensured and, more generally, to use and operate it in the
|
112
|
+
same conditions as regards security.
|
113
|
+
|
114
|
+
The fact that you are presently reading this means that you have had
|
115
|
+
knowledge of the CeCILL license and that you accept its terms.
|
116
|
+
|
117
|
+
SEE LICENCE NOTICE: file README-LICENCE-utf8.txt at project source root.
|
118
|
+
|
119
|
+
This software is being developed by Eric Debreuve, a CNRS employee and
|
120
|
+
member of team Morpheme.
|
121
|
+
Team Morpheme is a joint team between Inria, CNRS, and UniCA.
|
122
|
+
It is hosted by the Centre Inria d'Université Côte d'Azur, Laboratory
|
123
|
+
I3S, and Laboratory iBV.
|
124
|
+
|
125
|
+
CNRS: https://www.cnrs.fr/index.php/en
|
126
|
+
Inria: https://www.inria.fr/en/
|
127
|
+
UniCA: https://univ-cotedazur.eu/
|
128
|
+
Centre Inria d'Université Côte d'Azur: https://www.inria.fr/en/centre/sophia/
|
129
|
+
I3S: https://www.i3s.unice.fr/en/
|
130
|
+
iBV: http://ibv.unice.fr/
|
131
|
+
Team Morpheme: https://team.inria.fr/morpheme/
|
132
|
+
"""
|