ScriptCollection 3.5.121__py3-none-any.whl → 3.5.122__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.
- ScriptCollection/GeneralUtilities.py +30 -14
- ScriptCollection/SCLog.py +17 -10
- ScriptCollection/ScriptCollectionCore.py +1 -1
- {scriptcollection-3.5.121.dist-info → scriptcollection-3.5.122.dist-info}/METADATA +1 -1
- {scriptcollection-3.5.121.dist-info → scriptcollection-3.5.122.dist-info}/RECORD +8 -8
- {scriptcollection-3.5.121.dist-info → scriptcollection-3.5.122.dist-info}/WHEEL +0 -0
- {scriptcollection-3.5.121.dist-info → scriptcollection-3.5.122.dist-info}/entry_points.txt +0 -0
- {scriptcollection-3.5.121.dist-info → scriptcollection-3.5.122.dist-info}/top_level.txt +0 -0
@@ -22,6 +22,7 @@ from os.path import isfile, join, isdir
|
|
22
22
|
from pathlib import Path
|
23
23
|
from shutil import copyfile
|
24
24
|
import typing
|
25
|
+
from typing import TextIO
|
25
26
|
import psutil
|
26
27
|
from defusedxml.minidom import parse
|
27
28
|
from OpenSSL import crypto
|
@@ -211,6 +212,7 @@ class GeneralUtilities:
|
|
211
212
|
@staticmethod
|
212
213
|
@check_arguments
|
213
214
|
def replace_xmltag_in_file(file: str, tag: str, new_value: str, encoding="utf-8") -> None:
|
215
|
+
GeneralUtilities.assert_condition(tag.isalnum(tag), f"Invalid tag: \"{tag}\"")
|
214
216
|
GeneralUtilities.replace_regex_in_file(file, f"<{tag}>.*</{tag}>", f"<{tag}>{new_value}</{tag}>", encoding)
|
215
217
|
|
216
218
|
@staticmethod
|
@@ -241,30 +243,43 @@ class GeneralUtilities:
|
|
241
243
|
GeneralUtilities.write_text_to_file(file, text, encoding)
|
242
244
|
|
243
245
|
@staticmethod
|
246
|
+
@check_arguments
|
244
247
|
def print_text(text: str, print_to_stdout: bool = True):
|
245
248
|
GeneralUtilities.__print_text_to_console(text, print_to_stdout)
|
246
249
|
|
247
250
|
@staticmethod
|
248
|
-
|
249
|
-
|
251
|
+
@check_arguments
|
252
|
+
def print_text_in_green(text: str, print_to_stdout: bool = True, print_as_color: bool = True):
|
253
|
+
GeneralUtilities.print_text_in_color(text, 32, print_to_stdout, print_as_color)
|
250
254
|
|
251
255
|
@staticmethod
|
252
|
-
|
253
|
-
|
256
|
+
@check_arguments
|
257
|
+
def print_text_in_yellow(text: str, print_to_stdout: bool = True, print_as_color: bool = True):
|
258
|
+
GeneralUtilities.print_text_in_color(text, 33, print_to_stdout, print_as_color)
|
254
259
|
|
255
260
|
@staticmethod
|
256
|
-
|
257
|
-
|
261
|
+
@check_arguments
|
262
|
+
def print_text_in_red(text: str, print_to_stdout: bool = True, print_as_color: bool = True):
|
263
|
+
GeneralUtilities.print_text_in_color(text, 31, print_to_stdout, print_as_color)
|
258
264
|
|
259
265
|
@staticmethod
|
260
|
-
|
261
|
-
|
266
|
+
@check_arguments
|
267
|
+
def print_text_in_cyan(text: str, print_to_stdout: bool = True, print_as_color: bool = True):
|
268
|
+
GeneralUtilities.print_text_in_color(text, 36, print_to_stdout, print_as_color)
|
262
269
|
|
263
270
|
@staticmethod
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
271
|
+
@check_arguments
|
272
|
+
def print_text_in_color(text: str, colorcode: int, print_to_stdout: bool = True, print_as_color: bool = True):
|
273
|
+
stream: TextIO = sys.stdout if print_to_stdout else sys.stderr
|
274
|
+
if print_as_color:
|
275
|
+
text = f"\033[{colorcode}m{text}\033[0m"
|
276
|
+
GeneralUtilities.__print_text_to_console(text, stream, print_to_stdout)
|
277
|
+
|
278
|
+
@staticmethod
|
279
|
+
@check_arguments
|
280
|
+
def __print_text_to_console(text: str, stream: TextIO, print_to_stdout: bool = True):
|
281
|
+
stream.write(text)
|
282
|
+
stream.flush()
|
268
283
|
|
269
284
|
@staticmethod
|
270
285
|
@check_arguments
|
@@ -276,7 +291,7 @@ class GeneralUtilities:
|
|
276
291
|
@staticmethod
|
277
292
|
@check_arguments
|
278
293
|
def write_message_to_stdout_advanced(message: str, add_empty_lines: bool = True, adapt_lines: bool = True, append_linebreak: bool = True):
|
279
|
-
new_line_character: str = "\n" if append_linebreak else
|
294
|
+
new_line_character: str = "\n" if append_linebreak else GeneralUtilities.empty_string
|
280
295
|
for line in GeneralUtilities.string_to_lines(message, add_empty_lines, adapt_lines):
|
281
296
|
sys.stdout.write(GeneralUtilities.str_none_safe(line)+new_line_character)
|
282
297
|
sys.stdout.flush()
|
@@ -289,7 +304,7 @@ class GeneralUtilities:
|
|
289
304
|
@staticmethod
|
290
305
|
@check_arguments
|
291
306
|
def write_message_to_stderr_advanced(message: str, add_empty_lines: bool = True, adapt_lines: bool = True, append_linebreak: bool = True):
|
292
|
-
new_line_character: str = "\n" if append_linebreak else
|
307
|
+
new_line_character: str = "\n" if append_linebreak else GeneralUtilities.empty_string
|
293
308
|
for line in GeneralUtilities.string_to_lines(message, add_empty_lines, adapt_lines):
|
294
309
|
sys.stderr.write(GeneralUtilities.str_none_safe(line)+new_line_character)
|
295
310
|
sys.stderr.flush()
|
@@ -532,6 +547,7 @@ class GeneralUtilities:
|
|
532
547
|
@staticmethod
|
533
548
|
@check_arguments
|
534
549
|
def get_clusters_and_sectors_of_disk(diskpath: str) -> None:
|
550
|
+
GeneralUtilities.assert_condition(GeneralUtilities.current_system_is_windows(), "get_clusters_and_sectors_of_disk(diskpath) is only available on windows.")
|
535
551
|
sectorsPerCluster = ctypes.c_ulonglong(0)
|
536
552
|
bytesPerSector = ctypes.c_ulonglong(0)
|
537
553
|
rootPathName = ctypes.c_wchar_p(diskpath)
|
ScriptCollection/SCLog.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
from enum import Enum
|
3
|
-
from datetime import datetime
|
3
|
+
from datetime import datetime, timezone
|
4
4
|
from .GeneralUtilities import GeneralUtilities
|
5
5
|
|
6
6
|
|
@@ -19,11 +19,14 @@ class SCLog:
|
|
19
19
|
loglevel: LogLevel
|
20
20
|
log_file: str
|
21
21
|
add_overhead: bool
|
22
|
+
print_as_color: bool
|
23
|
+
zone_of_time: timezone = None
|
22
24
|
|
23
|
-
def __init__(self, log_file: str = None, loglevel: LogLevel = None, add_overhead: bool = False):
|
25
|
+
def __init__(self, log_file: str = None, loglevel: LogLevel = None, add_overhead: bool = False, print_as_color: bool = True):
|
24
26
|
self.log_file = log_file
|
25
27
|
self.loglevel = loglevel
|
26
28
|
self.add_overhead = add_overhead
|
29
|
+
self.print_as_color = print_as_color
|
27
30
|
|
28
31
|
@GeneralUtilities.check_arguments
|
29
32
|
def log_exception(self, message: str, ex: Exception, current_traceback):
|
@@ -42,8 +45,8 @@ class SCLog:
|
|
42
45
|
if int(loglevel) > int(self.loglevel):
|
43
46
|
return
|
44
47
|
|
45
|
-
part1: str =
|
46
|
-
part2: str =
|
48
|
+
part1: str = GeneralUtilities.empty_string
|
49
|
+
part2: str = GeneralUtilities.empty_string
|
47
50
|
part3: str = message
|
48
51
|
|
49
52
|
if loglevel == LogLevel.Warning:
|
@@ -51,7 +54,12 @@ class SCLog:
|
|
51
54
|
if loglevel == LogLevel.Debug:
|
52
55
|
part3 = f"Debug: {message}"
|
53
56
|
if self.add_overhead:
|
54
|
-
|
57
|
+
moment: datetime = None
|
58
|
+
if self.zone_of_time is None:
|
59
|
+
moment = datetime.now()
|
60
|
+
else:
|
61
|
+
moment = datetime.now(self.zone_of_time)
|
62
|
+
part1 = f"[{GeneralUtilities.datetime_to_string_for_logfile_entry(moment)}] ["
|
55
63
|
if loglevel == LogLevel.Information:
|
56
64
|
part2 = f"Information"
|
57
65
|
elif loglevel == LogLevel.Error:
|
@@ -66,15 +74,14 @@ class SCLog:
|
|
66
74
|
|
67
75
|
print_to_std_out: bool = loglevel in (LogLevel.Debug, LogLevel.Information)
|
68
76
|
GeneralUtilities.print_text(part1, print_to_std_out)
|
69
|
-
# if the control-characters for colors cause problems then maybe it can be checked with sys.stdout.isatty() if colors should be printed
|
70
77
|
if loglevel == LogLevel.Information:
|
71
|
-
GeneralUtilities.print_text_in_green(part2, print_to_std_out)
|
78
|
+
GeneralUtilities.print_text_in_green(part2, print_to_std_out, self.print_as_color)
|
72
79
|
elif loglevel == LogLevel.Error:
|
73
|
-
GeneralUtilities.print_text_in_red(part2, print_to_std_out)
|
80
|
+
GeneralUtilities.print_text_in_red(part2, print_to_std_out, self.print_as_color)
|
74
81
|
elif loglevel == LogLevel.Warning:
|
75
|
-
GeneralUtilities.print_text_in_yellow(part2, print_to_std_out)
|
82
|
+
GeneralUtilities.print_text_in_yellow(part2, print_to_std_out, self.print_as_color)
|
76
83
|
elif loglevel == LogLevel.Debug:
|
77
|
-
GeneralUtilities.print_text_in_cyan(part2, print_to_std_out)
|
84
|
+
GeneralUtilities.print_text_in_cyan(part2, print_to_std_out, self.print_as_color)
|
78
85
|
else:
|
79
86
|
raise ValueError("Unknown loglevel.")
|
80
87
|
GeneralUtilities.print_text(part3+"\n", print_to_std_out)
|
@@ -1,17 +1,17 @@
|
|
1
1
|
ScriptCollection/CertificateUpdater.py,sha256=OAxrG21k_o3W3niOOGNSZzUPJlvolOWc1lRB2dMhc3g,9212
|
2
2
|
ScriptCollection/Executables.py,sha256=ht-RZFu4g34Sr09b_L0c2QpKcjLWX-wFtKSMDMZYqsw,32266
|
3
|
-
ScriptCollection/GeneralUtilities.py,sha256=
|
3
|
+
ScriptCollection/GeneralUtilities.py,sha256=j-8AgY-aK4MFgEg5vl2VcuahW-vCeHm3rcGbru117pM,47319
|
4
4
|
ScriptCollection/ImageUpdater.py,sha256=lel1nevTN7fgdoCDE6Xg8YY6XPsZaOQiCIyWXbmVnh0,20882
|
5
5
|
ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
|
6
6
|
ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4bQNM6RV6Y,2480
|
7
7
|
ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
|
8
8
|
ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
|
9
|
-
ScriptCollection/SCLog.py,sha256=
|
10
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=
|
9
|
+
ScriptCollection/SCLog.py,sha256=6AIeza7KJ-9q13cNnbNTXgVlJqW6EAexowyni0hKTnQ,3450
|
10
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=LKmQ3Yh6SKW_Z_BVFICbisdEkxaPCiTLOEhDEFxk0p0,127859
|
11
11
|
ScriptCollection/TasksForCommonProjectStructure.py,sha256=4aEuIf89jbgKE4uMYm4DlPDe9Iu1Zujo8wPOzDld09w,234867
|
12
12
|
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
scriptcollection-3.5.
|
14
|
-
scriptcollection-3.5.
|
15
|
-
scriptcollection-3.5.
|
16
|
-
scriptcollection-3.5.
|
17
|
-
scriptcollection-3.5.
|
13
|
+
scriptcollection-3.5.122.dist-info/METADATA,sha256=k388tO8xs4bpHohNp39DFKsTYg45SaFzOzLtYrkdd6Q,7694
|
14
|
+
scriptcollection-3.5.122.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
15
|
+
scriptcollection-3.5.122.dist-info/entry_points.txt,sha256=3qMbfZEMhc_VTJj-bcLwB8AWcn9iXSB3l0AWpuu52Bs,3689
|
16
|
+
scriptcollection-3.5.122.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
17
|
+
scriptcollection-3.5.122.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|