ScriptCollection 3.5.147__py3-none-any.whl → 3.5.149__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/Executables.py +28 -6
- ScriptCollection/SCLog.py +4 -5
- ScriptCollection/ScriptCollectionCore.py +24 -2
- ScriptCollection/TasksForCommonProjectStructure.py +60 -57
- {scriptcollection-3.5.147.dist-info → scriptcollection-3.5.149.dist-info}/METADATA +7 -7
- {scriptcollection-3.5.147.dist-info → scriptcollection-3.5.149.dist-info}/RECORD +9 -9
- {scriptcollection-3.5.147.dist-info → scriptcollection-3.5.149.dist-info}/entry_points.txt +2 -1
- {scriptcollection-3.5.147.dist-info → scriptcollection-3.5.149.dist-info}/WHEEL +0 -0
- {scriptcollection-3.5.147.dist-info → scriptcollection-3.5.149.dist-info}/top_level.txt +0 -0
ScriptCollection/Executables.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import base64
|
1
2
|
import os
|
2
3
|
import argparse
|
3
4
|
import time
|
@@ -412,12 +413,6 @@ def FolderExists() -> int:
|
|
412
413
|
return 2
|
413
414
|
|
414
415
|
|
415
|
-
def SetContentOfFile() -> int:
|
416
|
-
GeneralUtilities.write_message_to_stderr("This function is not implemented yet.")
|
417
|
-
# TODO implement function
|
418
|
-
return 1
|
419
|
-
|
420
|
-
|
421
416
|
def PrintFileContent() -> int:
|
422
417
|
parser = argparse.ArgumentParser(description="This function prints the size of a file")
|
423
418
|
parser.add_argument('-p', '--path', required=True)
|
@@ -726,3 +721,30 @@ def UpdateImagesInDockerComposeFile() -> int:
|
|
726
721
|
args.file = os.path.join(os.getcwd(), "docker-compose.yml")
|
727
722
|
iu.update_all_services_in_docker_compose_file(args.file, VersionEcholon.LatestPatch, [])
|
728
723
|
return 0
|
724
|
+
|
725
|
+
|
726
|
+
def SetFileContent() -> int:
|
727
|
+
parser = argparse.ArgumentParser(description="This function writes content into a file.")
|
728
|
+
parser.add_argument('-p', '--path', required=True)
|
729
|
+
parser.add_argument('-b', '--argumentisinbase64', action='store_true', required=False, default=False)
|
730
|
+
parser.add_argument('-c', '--content', required=True)
|
731
|
+
parser.add_argument('-e', '--encoding', required=False, default="utf-8")
|
732
|
+
args = parser.parse_args()
|
733
|
+
sc = ScriptCollectionCore()
|
734
|
+
content = args.content
|
735
|
+
if args.argumentisinbase64:
|
736
|
+
base64_string: str = args.content
|
737
|
+
base64_bytes = base64_string.encode('utf-8')
|
738
|
+
original_bytes = base64.b64decode(base64_bytes)
|
739
|
+
content = original_bytes.decode('utf-8')
|
740
|
+
sc.set_file_content(args.path, content, args.encoding)
|
741
|
+
return 0
|
742
|
+
|
743
|
+
|
744
|
+
def GenerateTaskfileFromWorkspacefile() -> int:
|
745
|
+
parser = argparse.ArgumentParser(description="Generates a taskfile.yml-file from a .code-workspace-file")
|
746
|
+
parser.add_argument('-f', '--repositoryfolder', required=True)
|
747
|
+
args = parser.parse_args()
|
748
|
+
t = TasksForCommonProjectStructure()
|
749
|
+
t.generate_tasksfile_from_workspace_file(args.repositoryfolder)
|
750
|
+
return 0
|
ScriptCollection/SCLog.py
CHANGED
@@ -24,7 +24,7 @@ class SCLog:
|
|
24
24
|
print_as_color: bool
|
25
25
|
zone_of_time: timezone = None
|
26
26
|
|
27
|
-
def __init__(self, log_file: str = None, loglevel: LogLevel = None,print_as_color: bool = True):
|
27
|
+
def __init__(self, log_file: str = None, loglevel: LogLevel = None, print_as_color: bool = True):
|
28
28
|
self.log_file = log_file
|
29
29
|
if loglevel is None:
|
30
30
|
self.loglevel = LogLevel.Information
|
@@ -46,8 +46,8 @@ class SCLog:
|
|
46
46
|
@GeneralUtilities.check_arguments
|
47
47
|
def __log_line(self, message: str, loglevel: LogLevel = None):
|
48
48
|
|
49
|
-
print_to_console:bool=True
|
50
|
-
print_to_logfile:bool=self.log_file is not None
|
49
|
+
print_to_console: bool = True
|
50
|
+
print_to_logfile: bool = self.log_file is not None
|
51
51
|
|
52
52
|
if loglevel is None:
|
53
53
|
loglevel = LogLevel.Information
|
@@ -91,8 +91,8 @@ class SCLog:
|
|
91
91
|
part3 = f"] {message}"
|
92
92
|
|
93
93
|
if print_to_console:
|
94
|
+
print_to_std_out: bool = loglevel in (LogLevel.Debug, LogLevel.Information)
|
94
95
|
if self.add_overhead_to_console:
|
95
|
-
print_to_std_out: bool = loglevel in (LogLevel.Debug, LogLevel.Information)
|
96
96
|
GeneralUtilities.print_text(part1, print_to_std_out)
|
97
97
|
if loglevel == LogLevel.Information:
|
98
98
|
GeneralUtilities.print_text_in_green(part2, print_to_std_out, self.print_as_color)
|
@@ -110,7 +110,6 @@ class SCLog:
|
|
110
110
|
else:
|
111
111
|
GeneralUtilities.print_text(message+"\n", print_to_std_out)
|
112
112
|
|
113
|
-
|
114
113
|
if print_to_logfile:
|
115
114
|
GeneralUtilities.ensure_file_exists(self.log_file)
|
116
115
|
if self.add_overhead_to_logfile:
|
@@ -8,6 +8,7 @@ import time
|
|
8
8
|
from io import BytesIO
|
9
9
|
import itertools
|
10
10
|
import math
|
11
|
+
import base64
|
11
12
|
import os
|
12
13
|
from queue import Queue, Empty
|
13
14
|
from concurrent.futures import ThreadPoolExecutor
|
@@ -33,7 +34,7 @@ from .ProgramRunnerPopen import ProgramRunnerPopen
|
|
33
34
|
from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
|
34
35
|
from .SCLog import SCLog, LogLevel
|
35
36
|
|
36
|
-
version = "3.5.
|
37
|
+
version = "3.5.149"
|
37
38
|
__version__ = version
|
38
39
|
|
39
40
|
|
@@ -130,7 +131,8 @@ class ScriptCollectionCore:
|
|
130
131
|
|
131
132
|
@GeneralUtilities.check_arguments
|
132
133
|
def find_file_by_extension(self, folder: str, extension_without_dot: str):
|
133
|
-
|
134
|
+
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
135
|
+
result = [file for file in self.list_content(folder, True, False, False) if file.endswith(f".{extension_without_dot}")]
|
134
136
|
result_length = len(result)
|
135
137
|
if result_length == 0:
|
136
138
|
raise FileNotFoundError(f"No file available in folder '{folder}' with extension '{extension_without_dot}'.")
|
@@ -778,6 +780,26 @@ class ScriptCollectionCore:
|
|
778
780
|
return False
|
779
781
|
raise ValueError(f"Fatal error occurrs while checking whether folder '{path}' exists. StdErr: '{stderr}'")
|
780
782
|
|
783
|
+
@GeneralUtilities.check_arguments
|
784
|
+
def get_file_content(self, path: str, encoding: str = "utf-8") -> str:
|
785
|
+
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
786
|
+
if self.program_runner.will_be_executed_locally():
|
787
|
+
return GeneralUtilities.read_text_from_file(path, encoding)
|
788
|
+
else:
|
789
|
+
result = self.run_program_argsasarray("scprintfilecontent", ["--path", path, "--encofing", encoding]) # works platform-indepent
|
790
|
+
return result[1].replace("\\n", "\n")
|
791
|
+
|
792
|
+
@GeneralUtilities.check_arguments
|
793
|
+
def set_file_content(self, path: str, content: str, encoding: str = "utf-8") -> None:
|
794
|
+
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
795
|
+
if self.program_runner.will_be_executed_locally():
|
796
|
+
GeneralUtilities.write_text_to_file(path, content, encoding)
|
797
|
+
else:
|
798
|
+
content_bytes = content.encode('utf-8')
|
799
|
+
base64_bytes = base64.b64encode(content_bytes)
|
800
|
+
base64_string = base64_bytes.decode('utf-8')
|
801
|
+
self.run_program_argsasarray("scsetfilecontent", ["--path", path, "--argumentisinbase64", "--content", base64_string]) # works platform-indepent
|
802
|
+
|
781
803
|
@GeneralUtilities.check_arguments
|
782
804
|
def remove(self, path: str) -> None:
|
783
805
|
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
@@ -2383,64 +2383,67 @@ class TasksForCommonProjectStructure:
|
|
2383
2383
|
|
2384
2384
|
@GeneralUtilities.check_arguments
|
2385
2385
|
def generate_tasksfile_from_workspace_file(self, repository_folder: str, append_cli_args_at_end: bool = False) -> None:
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
relative_script_file = "."
|
2404
|
-
if "options" in task:
|
2405
|
-
options = task["options"]
|
2406
|
-
if "cwd" in options:
|
2407
|
-
cwd: str = options["cwd"]
|
2408
|
-
cwd = cwd.replace("${workspaceFolder}", ".")
|
2409
|
-
relative_script_file = cwd
|
2410
|
-
if len(relative_script_file) == 0:
|
2411
|
-
relative_script_file = "."
|
2386
|
+
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
2387
|
+
if self.__sc.program_runner.will_be_executed_locally(): # works only locally, but much more performant than always running an external program
|
2388
|
+
self.__sc.assert_is_git_repository(repository_folder)
|
2389
|
+
workspace_file: str = self.__sc.find_file_by_extension(repository_folder, "code-workspace")
|
2390
|
+
task_file: str = repository_folder + "/Taskfile.yml"
|
2391
|
+
lines: list[str] = ["version: '3'", GeneralUtilities.empty_string, "tasks:", GeneralUtilities.empty_string]
|
2392
|
+
workspace_file_content: str = self.__sc.get_file_content(workspace_file)
|
2393
|
+
jsoncontent = json.loads(workspace_file_content)
|
2394
|
+
tasks = jsoncontent["tasks"]["tasks"]
|
2395
|
+
tasks.sort(key=lambda x: x["label"].split("/")[-1], reverse=False) # sort by the label of the task
|
2396
|
+
for task in tasks:
|
2397
|
+
if task["type"] == "shell":
|
2398
|
+
|
2399
|
+
description: str = task["label"]
|
2400
|
+
name: str = GeneralUtilities.to_pascal_case(description)
|
2401
|
+
command = task["command"]
|
2402
|
+
relative_script_file = task["command"]
|
2412
2403
|
|
2413
|
-
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
2404
|
+
relative_script_file = "."
|
2405
|
+
if "options" in task:
|
2406
|
+
options = task["options"]
|
2407
|
+
if "cwd" in options:
|
2408
|
+
cwd: str = options["cwd"]
|
2409
|
+
cwd = cwd.replace("${workspaceFolder}", ".")
|
2410
|
+
relative_script_file = cwd
|
2411
|
+
if len(relative_script_file) == 0:
|
2412
|
+
relative_script_file = "."
|
2413
|
+
|
2414
|
+
command_with_args = command
|
2415
|
+
if "args" in task:
|
2416
|
+
args = task["args"]
|
2417
|
+
if len(args) > 1:
|
2418
|
+
command_with_args = f"{command_with_args} {' '.join(args)}"
|
2419
|
+
|
2420
|
+
if "description" in task:
|
2421
|
+
additional_description = task["description"]
|
2422
|
+
description = f"{description} ({additional_description})"
|
2423
|
+
|
2424
|
+
if append_cli_args_at_end:
|
2425
|
+
command_with_args = f"{command_with_args} {{{{.CLI_ARGS}}}}"
|
2426
|
+
|
2427
|
+
cwd_literal = cwd.replace("\\", "\\\\").replace('"', '\\"') # escape backslashes and double quotes for YAML
|
2428
|
+
description_literal = description.replace("\\", "\\\\").replace('"', '\\"') # escape backslashes and double quotes for YAML
|
2429
|
+
|
2430
|
+
lines.append(f" {name}:")
|
2431
|
+
lines.append(f' desc: "{description_literal}"')
|
2432
|
+
lines.append(' silent: true')
|
2433
|
+
lines.append(f' dir: "{cwd_literal}"')
|
2434
|
+
lines.append(" cmds:")
|
2435
|
+
lines.append(f" - {command_with_args}")
|
2436
|
+
lines.append(' aliases:')
|
2437
|
+
lines.append(f' - {name.lower()}')
|
2438
|
+
if "aliases" in task:
|
2439
|
+
aliases = task["aliases"]
|
2440
|
+
for alias in aliases:
|
2441
|
+
lines.append(f' - {alias}')
|
2442
|
+
lines.append(GeneralUtilities.empty_string)
|
2443
|
+
|
2444
|
+
self.__sc.set_file_content(task_file, "\n".join(lines))
|
2445
|
+
else:
|
2446
|
+
self.__sc.run_program("scgeneratetasksfilefromworkspacefile", f"--repositoryfolder {repository_folder}")
|
2444
2447
|
|
2445
2448
|
@GeneralUtilities.check_arguments
|
2446
2449
|
def start_local_test_service(self, file: str):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ScriptCollection
|
3
|
-
Version: 3.5.
|
3
|
+
Version: 3.5.149
|
4
4
|
Summary: The ScriptCollection is the place for reusable scripts.
|
5
5
|
Home-page: https://github.com/anionDev/ScriptCollection
|
6
6
|
Author: Marius Göcke
|
@@ -22,21 +22,21 @@ Classifier: Topic :: Terminals
|
|
22
22
|
Classifier: Topic :: Utilities
|
23
23
|
Requires-Python: >=3.10
|
24
24
|
Description-Content-Type: text/markdown
|
25
|
-
Requires-Dist: build>=1.
|
26
|
-
Requires-Dist: coverage>=7.
|
27
|
-
Requires-Dist: cyclonedx-bom>=
|
25
|
+
Requires-Dist: build>=1.3.0
|
26
|
+
Requires-Dist: coverage>=7.10.2
|
27
|
+
Requires-Dist: cyclonedx-bom>=7.0.0
|
28
28
|
Requires-Dist: defusedxml>=0.7.1
|
29
29
|
Requires-Dist: keyboard>=0.13.5
|
30
30
|
Requires-Dist: lcov-cobertura>=2.1.1
|
31
|
-
Requires-Dist: lxml>=
|
31
|
+
Requires-Dist: lxml>=6.0.0
|
32
32
|
Requires-Dist: ntplib>=0.4.0
|
33
|
-
Requires-Dist: Pillow>=11.
|
33
|
+
Requires-Dist: Pillow>=11.3.0
|
34
34
|
Requires-Dist: psutil>=7.0.0
|
35
35
|
Requires-Dist: pycdlib>=1.14.0
|
36
36
|
Requires-Dist: Pygments>=2.19.2
|
37
37
|
Requires-Dist: pylint>=3.3.7
|
38
38
|
Requires-Dist: pyOpenSSL>=25.1.0
|
39
|
-
Requires-Dist: PyPDF>=5.
|
39
|
+
Requires-Dist: PyPDF>=5.9.0
|
40
40
|
Requires-Dist: pytest>=8.4.1
|
41
41
|
Requires-Dist: PyYAML>=6.0.2
|
42
42
|
Requires-Dist: qrcode>=8.2
|
@@ -1,17 +1,17 @@
|
|
1
1
|
ScriptCollection/CertificateUpdater.py,sha256=OAxrG21k_o3W3niOOGNSZzUPJlvolOWc1lRB2dMhc3g,9212
|
2
|
-
ScriptCollection/Executables.py,sha256=
|
2
|
+
ScriptCollection/Executables.py,sha256=eX94RLNBarpWoZKeDo02gcP_qzmJDZcIx8XBZFVCFNc,36396
|
3
3
|
ScriptCollection/GeneralUtilities.py,sha256=PKdzq382RYVSWeSG_6z6FiHu-SiTOi2BavJKvP-0slU,47308
|
4
4
|
ScriptCollection/ImageUpdater.py,sha256=3B5pgAMnyne3ZogWz-suqglZGIB9FAKyWn31P9E1ST0,24491
|
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=
|
11
|
-
ScriptCollection/TasksForCommonProjectStructure.py,sha256=
|
9
|
+
ScriptCollection/SCLog.py,sha256=GJ44S6VaBVwX5Dd6MIrdZn6I0dpaaYKVq9w-N0nMXlo,4496
|
10
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=2GF7AUB6QN2o3N3-KPhdHGzxwpZryfWQIPRGLUMRmRo,138093
|
11
|
+
ScriptCollection/TasksForCommonProjectStructure.py,sha256=GoIVDPIGua2ZJIGM4zeJL1nNLwh7X1W8BI-2z-ESgb0,241302
|
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.149.dist-info/METADATA,sha256=Xt22-tDxFlz_5bbY-hDalMAXE7ndoPYu7QeEGLC822g,7689
|
14
|
+
scriptcollection-3.5.149.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
+
scriptcollection-3.5.149.dist-info/entry_points.txt,sha256=UyXXDpgVK6U0rkdbe2g-d3a7JFhLFWTUFSYWhcJE7IA,4214
|
16
|
+
scriptcollection-3.5.149.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
17
|
+
scriptcollection-3.5.149.dist-info/RECORD,,
|
@@ -28,6 +28,7 @@ scgeneratecertificate = ScriptCollection.Executables:GenerateCertificate
|
|
28
28
|
scgeneratecertificateauthority = ScriptCollection.Executables:GenerateCertificateAuthority
|
29
29
|
scgeneratecertificatesignrequest = ScriptCollection.Executables:GenerateCertificateSignRequest
|
30
30
|
scgeneratesnkfiles = ScriptCollection.Executables:GenerateSnkFiles
|
31
|
+
scgeneratetasksfilefromworkspacefile = ScriptCollection.Executables:GenerateTaskfileFromWorkspacefile
|
31
32
|
scgeneratethumbnail = ScriptCollection.Executables:GenerateThumbnail
|
32
33
|
schealthcheck = ScriptCollection.Executables:Healthcheck
|
33
34
|
sckeyboarddiagnosis = ScriptCollection.Executables:KeyboardDiagnosis
|
@@ -50,7 +51,7 @@ scremovefolder = ScriptCollection.Executables:RemoveFolder
|
|
50
51
|
screname = ScriptCollection.Executables:Rename
|
51
52
|
screplacesubstringsinfilenames = ScriptCollection.Executables:ReplaceSubstringsInFilenames
|
52
53
|
scsearchinfiles = ScriptCollection.Executables:SearchInFiles
|
53
|
-
|
54
|
+
scsetfilecontent = ScriptCollection.Executables:SetFileContent
|
54
55
|
scshow2faasqrcode = ScriptCollection.Executables:Show2FAAsQRCode
|
55
56
|
scshowmissingfiles = ScriptCollection.Executables:ShowMissingFiles
|
56
57
|
scsigncertificate = ScriptCollection.Executables:SignCertificate
|
File without changes
|
File without changes
|