linuxfabrik-lib 7.0.0__tar.gz → 7.1.0__tar.gz
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.
- {linuxfabrik_lib-7.0.0/linuxfabrik_lib.egg-info → linuxfabrik_lib-7.1.0}/PKG-INFO +1 -1
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/base.py +33 -8
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0/linuxfabrik_lib.egg-info}/PKG-INFO +1 -1
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/pyproject.toml +1 -1
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/LICENSE +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/README.md +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/__init__.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/args.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/bexio.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/cache.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/db_mysql.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/db_sqlite.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/disk.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/distro.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/dmidecode.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/endoflifedate.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/feedparser.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/globals.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/grassfish.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/huawei_dorado.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/huawei_pacific.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/human.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/icinga.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/infomaniak.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/jitsi.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/keycloak.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/lftest.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/librenms.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/linuxfabrik_lib.egg-info/SOURCES.txt +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/linuxfabrik_lib.egg-info/dependency_links.txt +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/linuxfabrik_lib.egg-info/requires.txt +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/linuxfabrik_lib.egg-info/top_level.txt +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/mail.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/net.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/nextcloud.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/nodebb.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/openmetrics.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/powershell.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/psutil.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/qts.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/redfish.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/rocket.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/setup.cfg +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/shell.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/smb.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/ssh.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/time.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/txt.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/uptimerobot.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/url.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/veeam.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/version.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/wildfly.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/winrm.py +0 -0
- {linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/wordpress.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: linuxfabrik-lib
|
|
3
|
-
Version: 7.
|
|
3
|
+
Version: 7.1.0
|
|
4
4
|
Summary: Python libraries used in various Linuxfabrik projects, including the 'Linuxfabrik Monitoring Plugins' project.
|
|
5
5
|
Author-email: "Linuxfabrik GmbH, Zurich, Switzerland" <info@linuxfabrik.ch>
|
|
6
6
|
License: This is free and unencumbered software released into the public domain.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"""Provides very common every-day functions."""
|
|
12
12
|
|
|
13
13
|
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
|
|
14
|
-
__version__ = '
|
|
14
|
+
__version__ = '2026081401'
|
|
15
15
|
|
|
16
16
|
import numbers
|
|
17
17
|
import operator
|
|
@@ -95,7 +95,7 @@ def coe(result, state=STATE_UNKNOWN):
|
|
|
95
95
|
sys.exit(state)
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
def cu(msg=None):
|
|
98
|
+
def cu(msg=None, traceback=True):
|
|
99
99
|
"""
|
|
100
100
|
See you (cu)
|
|
101
101
|
|
|
@@ -108,6 +108,12 @@ def cu(msg=None):
|
|
|
108
108
|
### Parameters
|
|
109
109
|
- **msg** (`str`, optional): An optional message to print before exiting.
|
|
110
110
|
If provided, it will be stripped, sanitized, and printed.
|
|
111
|
+
- **traceback** (`bool`, optional):
|
|
112
|
+
Whether to attach the stack trace of the exception being handled. Defaults to
|
|
113
|
+
`True`. Pass `False` where the exception is the expected answer rather than a
|
|
114
|
+
defect: a socket that is not there because the service is not installed, a
|
|
115
|
+
command that is absent on this platform. The admin gets the sentence that says
|
|
116
|
+
so, and no Python stack trace for a situation nobody needs to debug.
|
|
111
117
|
|
|
112
118
|
### Returns
|
|
113
119
|
- **None**: This function does not return; it always exits the script with `STATE_UNKNOWN`.
|
|
@@ -121,8 +127,10 @@ def cu(msg=None):
|
|
|
121
127
|
>>> cu('Unable to connect to server')
|
|
122
128
|
|
|
123
129
|
>>> cu()
|
|
130
|
+
|
|
131
|
+
>>> cu('strongSwan is not running here.', traceback=False)
|
|
124
132
|
"""
|
|
125
|
-
has_traceback = sys.exc_info()[0] is not None
|
|
133
|
+
has_traceback = traceback and sys.exc_info()[0] is not None
|
|
126
134
|
tb = format_exc() if has_traceback else None
|
|
127
135
|
|
|
128
136
|
if msg is not None:
|
|
@@ -253,6 +261,19 @@ def _is_empty_cell(value):
|
|
|
253
261
|
return str(value).strip().strip('-') == ''
|
|
254
262
|
|
|
255
263
|
|
|
264
|
+
def _escape_tag_start(text):
|
|
265
|
+
"""Replace a `<` that a web interface would read as the start of an HTML tag by
|
|
266
|
+
`<`. See `TAG_START` for which `<` that is.
|
|
267
|
+
|
|
268
|
+
Both `oao()` and `get_table()` apply this. A table has to do it before it measures
|
|
269
|
+
its columns: the replacement is three characters longer than what it replaces, so a
|
|
270
|
+
cell escaped afterwards pushes the delimiters of its row out of line, and a value
|
|
271
|
+
such as `<unknown>` bends the whole table. Escaping the cell first also leaves
|
|
272
|
+
nothing for `oao()` to escape a second time.
|
|
273
|
+
"""
|
|
274
|
+
return TAG_START.sub('<', text)
|
|
275
|
+
|
|
276
|
+
|
|
256
277
|
def get_table(
|
|
257
278
|
data,
|
|
258
279
|
cols,
|
|
@@ -327,6 +348,10 @@ def get_table(
|
|
|
327
348
|
full `data` it passed in, which the truncated table says nothing about.
|
|
328
349
|
- Rows are cut after sorting, so `max_rows` together with `sort_by_key` keeps the
|
|
329
350
|
rows that sort first rather than an arbitrary selection.
|
|
351
|
+
- A cell carrying a `<` that a web interface would read as the start of an HTML tag,
|
|
352
|
+
`<unknown>` for example, is escaped here rather than in `oao()`, so the column
|
|
353
|
+
widths are measured on the text that is actually printed and the table keeps its
|
|
354
|
+
shape. See `TAG_START`.
|
|
330
355
|
- Column widths come from the rows that are actually printed. A long value in a row
|
|
331
356
|
that was cut does not widen the table it no longer appears in.
|
|
332
357
|
|
|
@@ -403,12 +428,14 @@ def get_table(
|
|
|
403
428
|
if col not in row:
|
|
404
429
|
if missing is None:
|
|
405
430
|
return f'Unknown column "{col}"'
|
|
406
|
-
|
|
407
|
-
|
|
431
|
+
value = _escape_tag_start(missing)
|
|
432
|
+
processed_row[col] = value
|
|
433
|
+
column_widths[col] = max(column_widths.get(col, 0), len(value))
|
|
408
434
|
continue
|
|
409
435
|
value = str(row[col])
|
|
410
436
|
if strip:
|
|
411
437
|
value = value.strip()
|
|
438
|
+
value = _escape_tag_start(value)
|
|
412
439
|
processed_row[col] = value
|
|
413
440
|
column_widths[col] = max(column_widths.get(col, 0), len(value))
|
|
414
441
|
processed_rows.append(processed_row)
|
|
@@ -775,9 +802,7 @@ def oao(msg, state=STATE_OK, perfdata='', always_ok=False, no_perfdata=False):
|
|
|
775
802
|
# file or HTTP response) can carry CRLF or stray CR, which a web UI showing
|
|
776
803
|
# the output with `white-space: pre-wrap` would render as an extra line break.
|
|
777
804
|
msg = msg.replace('\r\n', '\n').replace('\r', '\n')
|
|
778
|
-
msg =
|
|
779
|
-
'|', '!'
|
|
780
|
-
)
|
|
805
|
+
msg = _escape_tag_start(txt.sanitize_sensitive_data(msg.strip())).replace('|', '!')
|
|
781
806
|
if always_ok and msg:
|
|
782
807
|
# Instead of splitlines(), we just split('\n', 1), so only first line is touched.
|
|
783
808
|
parts = msg.split('\n', 1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: linuxfabrik-lib
|
|
3
|
-
Version: 7.
|
|
3
|
+
Version: 7.1.0
|
|
4
4
|
Summary: Python libraries used in various Linuxfabrik projects, including the 'Linuxfabrik Monitoring Plugins' project.
|
|
5
5
|
Author-email: "Linuxfabrik GmbH, Zurich, Switzerland" <info@linuxfabrik.ch>
|
|
6
6
|
License: This is free and unencumbered software released into the public domain.
|
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "linuxfabrik-lib"
|
|
9
|
-
version = "7.
|
|
9
|
+
version = "7.1.0"
|
|
10
10
|
description = "Python libraries used in various Linuxfabrik projects, including the 'Linuxfabrik Monitoring Plugins' project."
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
authors = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{linuxfabrik_lib-7.0.0 → linuxfabrik_lib-7.1.0}/linuxfabrik_lib.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|