ScriptCollection 3.5.83__py3-none-any.whl → 3.5.85__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/ScriptCollectionCore.py +85 -58
- {ScriptCollection-3.5.83.dist-info → scriptcollection-3.5.85.dist-info}/METADATA +2 -2
- {ScriptCollection-3.5.83.dist-info → scriptcollection-3.5.85.dist-info}/RECORD +6 -6
- {ScriptCollection-3.5.83.dist-info → scriptcollection-3.5.85.dist-info}/WHEEL +1 -1
- {ScriptCollection-3.5.83.dist-info → scriptcollection-3.5.85.dist-info}/entry_points.txt +0 -0
- {ScriptCollection-3.5.83.dist-info → scriptcollection-3.5.85.dist-info}/top_level.txt +0 -0
@@ -32,7 +32,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
|
|
32
32
|
from .ProgramRunnerPopen import ProgramRunnerPopen
|
33
33
|
from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
|
34
34
|
|
35
|
-
version = "3.5.
|
35
|
+
version = "3.5.85"
|
36
36
|
__version__ = version
|
37
37
|
|
38
38
|
|
@@ -192,7 +192,7 @@ class ScriptCollectionCore:
|
|
192
192
|
until_as_string = self.__datetime_to_string_for_git(until)
|
193
193
|
result = filter(lambda line: not GeneralUtilities.string_is_none_or_whitespace(line), self.run_program("git", f'log --since "{since_as_string}" --until "{until_as_string}" --pretty=format:"%H" --no-patch', repository_folder, throw_exception_if_exitcode_is_not_zero=True)[1].split("\n").replace("\r", ""))
|
194
194
|
if ignore_commits_which_are_not_in_history_of_head:
|
195
|
-
result = [commit_id for commit_id in result if self.git_commit_is_ancestor(
|
195
|
+
result = [commit_id for commit_id in result if self.git_commit_is_ancestor(repository_folder, commit_id)]
|
196
196
|
return result
|
197
197
|
|
198
198
|
@GeneralUtilities.check_arguments
|
@@ -273,14 +273,17 @@ class ScriptCollectionCore:
|
|
273
273
|
|
274
274
|
@GeneralUtilities.check_arguments
|
275
275
|
def git_fetch(self, folder: str, remotename: str = "--all") -> None:
|
276
|
+
self.assert_is_git_repository(folder)
|
276
277
|
self.run_program_argsasarray("git", ["fetch", remotename, "--tags", "--prune"], folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
277
278
|
|
278
279
|
@GeneralUtilities.check_arguments
|
279
280
|
def git_fetch_in_bare_repository(self, folder: str, remotename, localbranch: str, remotebranch: str) -> None:
|
281
|
+
self.assert_is_git_repository(folder)
|
280
282
|
self.run_program_argsasarray("git", ["fetch", remotename, f"{remotebranch}:{localbranch}"], folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
281
283
|
|
282
284
|
@GeneralUtilities.check_arguments
|
283
285
|
def git_remove_branch(self, folder: str, branchname: str) -> None:
|
286
|
+
self.assert_is_git_repository(folder)
|
284
287
|
self.run_program("git", f"branch -D {branchname}", folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
285
288
|
|
286
289
|
@GeneralUtilities.check_arguments
|
@@ -289,6 +292,7 @@ class ScriptCollectionCore:
|
|
289
292
|
|
290
293
|
@GeneralUtilities.check_arguments
|
291
294
|
def git_push(self, folder: str, remotename: str, localbranchname: str, remotebranchname: str, forcepush: bool = False, pushalltags: bool = True, verbosity: int = 0) -> None:
|
295
|
+
self.assert_is_git_repository(folder)
|
292
296
|
argument = ["push", "--recurse-submodules=on-demand", remotename, f"{localbranchname}:{remotebranchname}"]
|
293
297
|
if (forcepush):
|
294
298
|
argument.append("--force")
|
@@ -299,10 +303,11 @@ class ScriptCollectionCore:
|
|
299
303
|
|
300
304
|
@GeneralUtilities.check_arguments
|
301
305
|
def git_pull_with_retry(self, folder: str, remote: str, localbranchname: str, remotebranchname: str, force: bool = False, amount_of_attempts: int = 5) -> None:
|
302
|
-
GeneralUtilities.retry_action(lambda: self.git_pull_with_retry(folder, remote,localbranchname,remotebranchname), amount_of_attempts)
|
306
|
+
GeneralUtilities.retry_action(lambda: self.git_pull_with_retry(folder, remote, localbranchname, remotebranchname), amount_of_attempts)
|
303
307
|
|
304
308
|
@GeneralUtilities.check_arguments
|
305
309
|
def git_pull(self, folder: str, remote: str, localbranchname: str, remotebranchname: str, force: bool = False) -> None:
|
310
|
+
self.assert_is_git_repository(folder)
|
306
311
|
argument = f"pull {remote} {remotebranchname}:{localbranchname}"
|
307
312
|
if force:
|
308
313
|
argument = f"{argument} --force"
|
@@ -310,6 +315,7 @@ class ScriptCollectionCore:
|
|
310
315
|
|
311
316
|
@GeneralUtilities.check_arguments
|
312
317
|
def git_list_remote_branches(self, folder: str, remote: str, fetch: bool) -> list[str]:
|
318
|
+
self.assert_is_git_repository(folder)
|
313
319
|
if fetch:
|
314
320
|
self.git_fetch(folder, remote)
|
315
321
|
run_program_result = self.run_program("git", f"branch -rl {remote}/*", folder, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
@@ -343,20 +349,24 @@ class ScriptCollectionCore:
|
|
343
349
|
|
344
350
|
@GeneralUtilities.check_arguments
|
345
351
|
def git_get_all_remote_names(self, directory: str) -> list[str]:
|
352
|
+
self.assert_is_git_repository(directory)
|
346
353
|
result = GeneralUtilities.string_to_lines(self.run_program_argsasarray("git", ["remote"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)[1], False)
|
347
354
|
return result
|
348
355
|
|
349
356
|
@GeneralUtilities.check_arguments
|
350
357
|
def git_get_remote_url(self, directory: str, remote_name: str) -> str:
|
358
|
+
self.assert_is_git_repository(directory)
|
351
359
|
result = GeneralUtilities.string_to_lines(self.run_program_argsasarray("git", ["remote", "get-url", remote_name], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)[1], False)
|
352
360
|
return result[0].replace('\n', '')
|
353
361
|
|
354
362
|
@GeneralUtilities.check_arguments
|
355
363
|
def repository_has_remote_with_specific_name(self, directory: str, remote_name: str) -> bool:
|
364
|
+
self.assert_is_git_repository(directory)
|
356
365
|
return remote_name in self.git_get_all_remote_names(directory)
|
357
366
|
|
358
367
|
@GeneralUtilities.check_arguments
|
359
368
|
def git_add_or_set_remote_address(self, directory: str, remote_name: str, remote_address: str) -> None:
|
369
|
+
self.assert_is_git_repository(directory)
|
360
370
|
if (self.repository_has_remote_with_specific_name(directory, remote_name)):
|
361
371
|
self.run_program_argsasarray("git", ['remote', 'set-url', 'remote_name', remote_address], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
362
372
|
else:
|
@@ -364,34 +374,43 @@ class ScriptCollectionCore:
|
|
364
374
|
|
365
375
|
@GeneralUtilities.check_arguments
|
366
376
|
def git_stage_all_changes(self, directory: str) -> None:
|
377
|
+
self.assert_is_git_repository(directory)
|
367
378
|
self.run_program_argsasarray("git", ["add", "-A"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
368
379
|
|
369
380
|
@GeneralUtilities.check_arguments
|
370
381
|
def git_unstage_all_changes(self, directory: str) -> None:
|
382
|
+
self.assert_is_git_repository(directory)
|
371
383
|
self.run_program_argsasarray("git", ["reset"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
384
|
+
# TODO check if this will also be done for submodules
|
372
385
|
|
373
386
|
@GeneralUtilities.check_arguments
|
374
387
|
def git_stage_file(self, directory: str, file: str) -> None:
|
388
|
+
self.assert_is_git_repository(directory)
|
375
389
|
self.run_program_argsasarray("git", ['stage', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
376
390
|
|
377
391
|
@GeneralUtilities.check_arguments
|
378
392
|
def git_unstage_file(self, directory: str, file: str) -> None:
|
393
|
+
self.assert_is_git_repository(directory)
|
379
394
|
self.run_program_argsasarray("git", ['reset', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
380
395
|
|
381
396
|
@GeneralUtilities.check_arguments
|
382
397
|
def git_discard_unstaged_changes_of_file(self, directory: str, file: str) -> None:
|
383
398
|
"""Caution: This method works really only for 'changed' files yet. So this method does not work properly for new or renamed files."""
|
399
|
+
self.assert_is_git_repository(directory)
|
384
400
|
self.run_program_argsasarray("git", ['checkout', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
385
401
|
|
386
402
|
@GeneralUtilities.check_arguments
|
387
403
|
def git_discard_all_unstaged_changes(self, directory: str) -> None:
|
388
404
|
"""Caution: This function executes 'git clean -df'. This can delete files which maybe should not be deleted. Be aware of that."""
|
405
|
+
self.assert_is_git_repository(directory)
|
389
406
|
self.run_program_argsasarray("git", ['clean', '-df'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
390
407
|
self.run_program_argsasarray("git", ['checkout', '.'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
408
|
+
# TODO check if this will also be done for submodules
|
391
409
|
|
392
410
|
@GeneralUtilities.check_arguments
|
393
|
-
def git_commit(self, directory: str, message: str="Saved changes.", author_name: str = None, author_email: str = None, stage_all_changes: bool = True, no_changes_behavior: int = 0) -> str:
|
411
|
+
def git_commit(self, directory: str, message: str = "Saved changes.", author_name: str = None, author_email: str = None, stage_all_changes: bool = True, no_changes_behavior: int = 0) -> str:
|
394
412
|
"""no_changes_behavior=0 => No commit; no_changes_behavior=1 => Commit anyway; no_changes_behavior=2 => Exception"""
|
413
|
+
self.assert_is_git_repository(directory)
|
395
414
|
author_name = GeneralUtilities.str_none_safe(author_name).strip()
|
396
415
|
author_email = GeneralUtilities.str_none_safe(author_email).strip()
|
397
416
|
argument = ['commit', '--quiet', '--allow-empty', '--message', message]
|
@@ -423,29 +442,35 @@ class ScriptCollectionCore:
|
|
423
442
|
|
424
443
|
@GeneralUtilities.check_arguments
|
425
444
|
def git_create_tag(self, directory: str, target_for_tag: str, tag: str, sign: bool = False, message: str = None) -> None:
|
445
|
+
self.assert_is_git_repository(directory)
|
426
446
|
argument = ["tag", tag, target_for_tag]
|
427
447
|
if sign:
|
428
448
|
if message is None:
|
429
449
|
message = f"Created {target_for_tag}"
|
430
450
|
argument.extend(["-s", '-m', message])
|
431
|
-
self.run_program_argsasarray(
|
432
|
-
"git", argument, directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
451
|
+
self.run_program_argsasarray("git", argument, directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
433
452
|
|
434
453
|
@GeneralUtilities.check_arguments
|
435
454
|
def git_delete_tag(self, directory: str, tag: str) -> None:
|
455
|
+
self.assert_is_git_repository(directory)
|
436
456
|
self.run_program_argsasarray("git", ["tag", "--delete", tag], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
437
457
|
|
438
458
|
@GeneralUtilities.check_arguments
|
439
|
-
def git_checkout(self, directory: str, branch: str) -> None:
|
459
|
+
def git_checkout(self, directory: str, branch: str, undo_all_changes_after_checkout: bool = True) -> None:
|
460
|
+
self.assert_is_git_repository(directory)
|
440
461
|
self.run_program_argsasarray("git", ["checkout", branch], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
441
462
|
self.run_program_argsasarray("git", ["submodule", "update", "--recursive"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
463
|
+
if undo_all_changes_after_checkout:
|
464
|
+
self.git_undo_all_changes(directory)
|
442
465
|
|
443
466
|
@GeneralUtilities.check_arguments
|
444
467
|
def git_merge_abort(self, directory: str) -> None:
|
468
|
+
self.assert_is_git_repository(directory)
|
445
469
|
self.run_program_argsasarray("git", ["merge", "--abort"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
446
470
|
|
447
471
|
@GeneralUtilities.check_arguments
|
448
472
|
def git_merge(self, directory: str, sourcebranch: str, targetbranch: str, fastforward: bool = True, commit: bool = True, commit_message: str = None) -> str:
|
473
|
+
self.assert_is_git_repository(directory)
|
449
474
|
self.git_checkout(directory, targetbranch)
|
450
475
|
args = ["merge"]
|
451
476
|
if not commit:
|
@@ -463,6 +488,7 @@ class ScriptCollectionCore:
|
|
463
488
|
@GeneralUtilities.check_arguments
|
464
489
|
def git_undo_all_changes(self, directory: str) -> None:
|
465
490
|
"""Caution: This function executes 'git clean -df'. This can delete files which maybe should not be deleted. Be aware of that."""
|
491
|
+
self.assert_is_git_repository(directory)
|
466
492
|
self.git_unstage_all_changes(directory)
|
467
493
|
self.git_discard_all_unstaged_changes(directory)
|
468
494
|
|
@@ -480,8 +506,9 @@ class ScriptCollectionCore:
|
|
480
506
|
# clone
|
481
507
|
self.git_clone(target_repository, source_repository, include_submodules=True, mirror=True)
|
482
508
|
|
483
|
-
def get_git_submodules(self,
|
484
|
-
|
509
|
+
def get_git_submodules(self, directory: str) -> list[str]:
|
510
|
+
self.assert_is_git_repository(directory)
|
511
|
+
e = self.run_program("git", "submodule status", directory)
|
485
512
|
result = []
|
486
513
|
for submodule_line in GeneralUtilities.string_to_lines(e[1], False, True):
|
487
514
|
result.append(submodule_line.split(' ')[1])
|
@@ -489,6 +516,7 @@ class ScriptCollectionCore:
|
|
489
516
|
|
490
517
|
@GeneralUtilities.check_arguments
|
491
518
|
def file_is_git_ignored(self, file_in_repository: str, repositorybasefolder: str) -> None:
|
519
|
+
self.assert_is_git_repository(repositorybasefolder)
|
492
520
|
exit_code = self.run_program_argsasarray("git", ['check-ignore', file_in_repository], repositorybasefolder, throw_exception_if_exitcode_is_not_zero=False, verbosity=0)[0]
|
493
521
|
if (exit_code == 0):
|
494
522
|
return True
|
@@ -498,28 +526,33 @@ class ScriptCollectionCore:
|
|
498
526
|
|
499
527
|
@GeneralUtilities.check_arguments
|
500
528
|
def git_discard_all_changes(self, repository: str) -> None:
|
529
|
+
self.assert_is_git_repository(repository)
|
501
530
|
self.run_program_argsasarray("git", ["reset", "HEAD", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
502
531
|
self.run_program_argsasarray("git", ["checkout", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
503
532
|
|
504
533
|
@GeneralUtilities.check_arguments
|
505
534
|
def git_get_current_branch_name(self, repository: str) -> str:
|
535
|
+
self.assert_is_git_repository(repository)
|
506
536
|
result = self.run_program_argsasarray("git", ["rev-parse", "--abbrev-ref", "HEAD"], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
|
507
537
|
return result[1].replace("\r", "").replace("\n", "")
|
508
538
|
|
509
539
|
@GeneralUtilities.check_arguments
|
510
540
|
def git_get_commitid_of_tag(self, repository: str, tag: str) -> str:
|
541
|
+
self.assert_is_git_repository(repository)
|
511
542
|
stdout = self.run_program_argsasarray("git", ["rev-list", "-n", "1", tag], repository, verbosity=0)
|
512
543
|
result = stdout[1].replace("\r", "").replace("\n", "")
|
513
544
|
return result
|
514
545
|
|
515
546
|
@GeneralUtilities.check_arguments
|
516
547
|
def git_get_tags(self, repository: str) -> list[str]:
|
548
|
+
self.assert_is_git_repository(repository)
|
517
549
|
tags = [line.replace("\r", "") for line in self.run_program_argsasarray(
|
518
550
|
"git", ["tag"], repository)[1].split("\n") if len(line) > 0]
|
519
551
|
return tags
|
520
552
|
|
521
553
|
@GeneralUtilities.check_arguments
|
522
554
|
def git_move_tags_to_another_branch(self, repository: str, tag_source_branch: str, tag_target_branch: str, sign: bool = False, message: str = None) -> None:
|
555
|
+
self.assert_is_git_repository(repository)
|
523
556
|
tags = self.git_get_tags(repository)
|
524
557
|
tags_count = len(tags)
|
525
558
|
counter = 0
|
@@ -628,28 +661,28 @@ class ScriptCollectionCore:
|
|
628
661
|
GeneralUtilities.assert_condition(self.is_git_repository(folder), f"'{folder}' is not a git-repository.")
|
629
662
|
|
630
663
|
@GeneralUtilities.check_arguments
|
631
|
-
def list_content(self, path: str,include_files:bool,include_folder:bool,printonlynamewithoutpath:bool) -> list[str]:
|
664
|
+
def list_content(self, path: str, include_files: bool, include_folder: bool, printonlynamewithoutpath: bool) -> list[str]:
|
632
665
|
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
633
666
|
if self.program_runner.will_be_executed_locally():
|
634
|
-
result=[]
|
667
|
+
result = []
|
635
668
|
if include_files:
|
636
|
-
result=result + GeneralUtilities.get_direct_files_of_folder(path)
|
669
|
+
result = result + GeneralUtilities.get_direct_files_of_folder(path)
|
637
670
|
if include_folder:
|
638
|
-
result=result + GeneralUtilities.get_direct_folders_of_folder(path)
|
671
|
+
result = result + GeneralUtilities.get_direct_folders_of_folder(path)
|
639
672
|
return result
|
640
673
|
else:
|
641
|
-
arguments=["--path", path]
|
674
|
+
arguments = ["--path", path]
|
642
675
|
if not include_files:
|
643
|
-
arguments=arguments+["--excludefiles"]
|
676
|
+
arguments = arguments+["--excludefiles"]
|
644
677
|
if not include_folder:
|
645
|
-
arguments=arguments+["--excludedirectories"]
|
678
|
+
arguments = arguments+["--excludedirectories"]
|
646
679
|
if printonlynamewithoutpath:
|
647
|
-
arguments=arguments+["--printonlynamewithoutpath"]
|
680
|
+
arguments = arguments+["--printonlynamewithoutpath"]
|
648
681
|
exit_code, stdout, stderr, _ = self.run_program_argsasarray("sclistfoldercontent", arguments)
|
649
682
|
if exit_code == 0:
|
650
|
-
result:list[str]=[]
|
683
|
+
result: list[str] = []
|
651
684
|
for line in stdout.split("\n"):
|
652
|
-
normalized_line=line.replace("\r","")
|
685
|
+
normalized_line = line.replace("\r", "")
|
653
686
|
result.append(normalized_line)
|
654
687
|
return result
|
655
688
|
else:
|
@@ -686,7 +719,7 @@ class ScriptCollectionCore:
|
|
686
719
|
raise ValueError(f"Fatal error occurrs while checking whether folder '{path}' exists. StdErr: '{stderr}'")
|
687
720
|
|
688
721
|
@GeneralUtilities.check_arguments
|
689
|
-
def remove(self, path: str) ->None:
|
722
|
+
def remove(self, path: str) -> None:
|
690
723
|
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
691
724
|
if self.program_runner.will_be_executed_locally(): # works only locally, but much more performant than always running an external program
|
692
725
|
if os.path.isdir(path):
|
@@ -704,17 +737,17 @@ class ScriptCollectionCore:
|
|
704
737
|
raise ValueError(f"Fatal error occurrs while removing folder '{path}'. StdErr: '{stderr}'")
|
705
738
|
|
706
739
|
@GeneralUtilities.check_arguments
|
707
|
-
def rename(self, source:str,target:str) ->None:
|
740
|
+
def rename(self, source: str, target: str) -> None:
|
708
741
|
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
709
742
|
if self.program_runner.will_be_executed_locally(): # works only locally, but much more performant than always running an external program
|
710
743
|
os.rename(source, target)
|
711
744
|
else:
|
712
|
-
exit_code, _, stderr, _ = self.run_program_argsasarray("screname", ["--source", source,"--target",target], throw_exception_if_exitcode_is_not_zero=False) # works platform-indepent
|
745
|
+
exit_code, _, stderr, _ = self.run_program_argsasarray("screname", ["--source", source, "--target", target], throw_exception_if_exitcode_is_not_zero=False) # works platform-indepent
|
713
746
|
if exit_code != 0:
|
714
747
|
raise ValueError(f"Fatal error occurrs while renaming '{source}' to '{target}'. StdErr: '{stderr}'")
|
715
748
|
|
716
749
|
@GeneralUtilities.check_arguments
|
717
|
-
def copy(self, source:str,target:str) ->None:
|
750
|
+
def copy(self, source: str, target: str) -> None:
|
718
751
|
"""This function works platform-independent also for non-local-executions if the ScriptCollection commandline-commands are available as global command on the target-system."""
|
719
752
|
if self.program_runner.will_be_executed_locally(): # works only locally, but much more performant than always running an external program
|
720
753
|
if os.path.isfile(target) or os.path.isdir(target):
|
@@ -723,11 +756,11 @@ class ScriptCollectionCore:
|
|
723
756
|
shutil.copyfile(source, target)
|
724
757
|
elif os.path.isdir(source):
|
725
758
|
GeneralUtilities.ensure_directory_exists(target)
|
726
|
-
GeneralUtilities.copy_content_of_folder(source,target)
|
759
|
+
GeneralUtilities.copy_content_of_folder(source, target)
|
727
760
|
else:
|
728
761
|
raise ValueError(f"'{source}' can not be copied because the path does not exist.")
|
729
762
|
else:
|
730
|
-
exit_code, _, stderr, _ = self.run_program_argsasarray("sccopy", ["--source", source,"--target", target], throw_exception_if_exitcode_is_not_zero=False) # works platform-indepent
|
763
|
+
exit_code, _, stderr, _ = self.run_program_argsasarray("sccopy", ["--source", source, "--target", target], throw_exception_if_exitcode_is_not_zero=False) # works platform-indepent
|
731
764
|
if exit_code != 0:
|
732
765
|
raise ValueError(f"Fatal error occurrs while copying '{source}' to '{target}'. StdErr: '{stderr}'")
|
733
766
|
|
@@ -1052,14 +1085,11 @@ class ScriptCollectionCore:
|
|
1052
1085
|
|
1053
1086
|
@GeneralUtilities.check_arguments
|
1054
1087
|
def SCShow2FAAsQRCode(self, csvfile: str) -> None:
|
1055
|
-
separator_line = "--------------------------------------------------------"
|
1056
1088
|
lines = GeneralUtilities.read_csv_file(csvfile, True)
|
1057
1089
|
lines.sort(key=lambda items: ''.join(items).lower())
|
1058
1090
|
for line in lines:
|
1059
|
-
|
1060
|
-
|
1061
|
-
line[0], line[1], line[2], line[3], line[4])
|
1062
|
-
GeneralUtilities.write_message_to_stdout(separator_line)
|
1091
|
+
self.__print_qr_code_by_csv_line(line[0], line[1], line[2], line[3], line[4])
|
1092
|
+
GeneralUtilities.write_message_to_stdout(GeneralUtilities.get_longline())
|
1063
1093
|
|
1064
1094
|
@GeneralUtilities.check_arguments
|
1065
1095
|
def SCCalculateBitcoinBlockHash(self, block_version_number: str, previousblockhash: str, transactionsmerkleroot: str, timestamp: str, target: str, nonce: str) -> str:
|
@@ -1347,7 +1377,7 @@ class ScriptCollectionCore:
|
|
1347
1377
|
return popen
|
1348
1378
|
|
1349
1379
|
@staticmethod
|
1350
|
-
def __enqueue_output(file:IO, queue:Queue):
|
1380
|
+
def __enqueue_output(file: IO, queue: Queue):
|
1351
1381
|
for line in iter(file.readline, ''):
|
1352
1382
|
queue.put(line)
|
1353
1383
|
file.close()
|
@@ -1369,7 +1399,7 @@ class ScriptCollectionCore:
|
|
1369
1399
|
return False
|
1370
1400
|
|
1371
1401
|
@staticmethod
|
1372
|
-
def __read_popen_pipes(p: Popen,print_live_output:bool,print_errors_as_information:bool) -> tuple[list[str], list[str]]:
|
1402
|
+
def __read_popen_pipes(p: Popen, print_live_output: bool, print_errors_as_information: bool) -> tuple[list[str], list[str]]:
|
1373
1403
|
p_id = p.pid
|
1374
1404
|
with ThreadPoolExecutor(2) as pool:
|
1375
1405
|
q_stdout = Queue()
|
@@ -1386,8 +1416,8 @@ class ScriptCollectionCore:
|
|
1386
1416
|
while (ScriptCollectionCore.__continue_process_reading(p_id, p, q_stdout, q_stderr, reading_stdout_last_time_resulted_in_exception, reading_stderr_last_time_resulted_in_exception)):
|
1387
1417
|
try:
|
1388
1418
|
while not q_stdout.empty():
|
1389
|
-
out_line:str=q_stdout.get_nowait()
|
1390
|
-
out_line=out_line.replace("\r","").replace("\n","")
|
1419
|
+
out_line: str = q_stdout.get_nowait()
|
1420
|
+
out_line = out_line.replace("\r", "").replace("\n", "")
|
1391
1421
|
if GeneralUtilities.string_has_content(out_line):
|
1392
1422
|
stdout_result.append(out_line)
|
1393
1423
|
reading_stdout_last_time_resulted_in_exception = False
|
@@ -1400,8 +1430,8 @@ class ScriptCollectionCore:
|
|
1400
1430
|
|
1401
1431
|
try:
|
1402
1432
|
while not q_stderr.empty():
|
1403
|
-
err_line:str=q_stderr.get_nowait()
|
1404
|
-
err_line=err_line.replace("\r","").replace("\n","")
|
1433
|
+
err_line: str = q_stderr.get_nowait()
|
1434
|
+
err_line = err_line.replace("\r", "").replace("\n", "")
|
1405
1435
|
if GeneralUtilities.string_has_content(err_line):
|
1406
1436
|
stderr_result.append(err_line)
|
1407
1437
|
reading_stderr_last_time_resulted_in_exception = False
|
@@ -1459,7 +1489,7 @@ class ScriptCollectionCore:
|
|
1459
1489
|
GeneralUtilities.ensure_file_exists(log_file)
|
1460
1490
|
pid = process.pid
|
1461
1491
|
|
1462
|
-
outputs: tuple[list[str], list[str]] = ScriptCollectionCore.__read_popen_pipes(process,print_live_output,print_errors_as_information)
|
1492
|
+
outputs: tuple[list[str], list[str]] = ScriptCollectionCore.__read_popen_pipes(process, print_live_output, print_errors_as_information)
|
1463
1493
|
|
1464
1494
|
for out_line_plain in outputs[0]:
|
1465
1495
|
if out_line_plain is not None:
|
@@ -1516,8 +1546,8 @@ class ScriptCollectionCore:
|
|
1516
1546
|
|
1517
1547
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
1518
1548
|
@GeneralUtilities.check_arguments
|
1519
|
-
def run_program_with_retry(self, program: str, arguments: str = "", working_directory: str = None, verbosity: int = 1, print_errors_as_information: bool = False, log_file: str = None, timeoutInSeconds: int = 600, addLogOverhead: bool = False, title: str = None, log_namespace: str = "", arguments_for_log: list[str] = None, throw_exception_if_exitcode_is_not_zero: bool = True, custom_argument: object = None, interactive: bool = False, print_live_output: bool = False,amount_of_attempts:int=5) -> tuple[int, str, str, int]:
|
1520
|
-
return GeneralUtilities.retry_action(lambda: self.run_program(program, arguments,working_directory,verbosity,print_errors_as_information,log_file,timeoutInSeconds,addLogOverhead,title,log_namespace,arguments_for_log,throw_exception_if_exitcode_is_not_zero,custom_argument,interactive,print_live_output), amount_of_attempts)
|
1549
|
+
def run_program_with_retry(self, program: str, arguments: str = "", working_directory: str = None, verbosity: int = 1, print_errors_as_information: bool = False, log_file: str = None, timeoutInSeconds: int = 600, addLogOverhead: bool = False, title: str = None, log_namespace: str = "", arguments_for_log: list[str] = None, throw_exception_if_exitcode_is_not_zero: bool = True, custom_argument: object = None, interactive: bool = False, print_live_output: bool = False, amount_of_attempts: int = 5) -> tuple[int, str, str, int]:
|
1550
|
+
return GeneralUtilities.retry_action(lambda: self.run_program(program, arguments, working_directory, verbosity, print_errors_as_information, log_file, timeoutInSeconds, addLogOverhead, title, log_namespace, arguments_for_log, throw_exception_if_exitcode_is_not_zero, custom_argument, interactive, print_live_output), amount_of_attempts)
|
1521
1551
|
|
1522
1552
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
1523
1553
|
@GeneralUtilities.check_arguments
|
@@ -1817,50 +1847,47 @@ DNS = {domain}
|
|
1817
1847
|
folder = os.path.dirname(csproj_file)
|
1818
1848
|
csproj_filename = os.path.basename(csproj_file)
|
1819
1849
|
GeneralUtilities.write_message_to_stdout(f"Check for updates in {csproj_filename}")
|
1820
|
-
result = self.run_program_with_retry("dotnet", f"list {csproj_filename} package --outdated", folder,print_errors_as_information=True)
|
1850
|
+
result = self.run_program_with_retry("dotnet", f"list {csproj_filename} package --outdated", folder, print_errors_as_information=True)
|
1821
1851
|
for line in result[1].replace("\r", "").split("\n"):
|
1822
1852
|
# Relevant output-lines are something like " > NJsonSchema 10.7.0 10.7.0 10.9.0"
|
1823
1853
|
if ">" in line:
|
1824
1854
|
package_name = line.replace(">", "").strip().split(" ")[0]
|
1825
1855
|
if not (package_name in ignored_dependencies):
|
1826
1856
|
GeneralUtilities.write_message_to_stdout(f"Update package {package_name}...")
|
1827
|
-
self.run_program("dotnet", f"add {csproj_filename} package {package_name}", folder,print_errors_as_information=True)
|
1828
|
-
|
1857
|
+
self.run_program("dotnet", f"add {csproj_filename} package {package_name}", folder, print_errors_as_information=True)
|
1829
1858
|
|
1830
1859
|
@GeneralUtilities.check_arguments
|
1831
|
-
def dotnet_package_is_available(self,package_name:str,package_version:str,source:str):
|
1832
|
-
default_source_address="nuget.org"
|
1833
|
-
if source==default_source_address:
|
1860
|
+
def dotnet_package_is_available(self, package_name: str, package_version: str, source: str):
|
1861
|
+
default_source_address = "nuget.org"
|
1862
|
+
if source == default_source_address:
|
1834
1863
|
GeneralUtilities.write_message_to_stdout(f"Wait until package {package_name} v{package_version} is available on {source}.")
|
1835
1864
|
headers = {'Cache-Control': 'no-cache'}
|
1836
|
-
r=requests.get(f"https://api.{default_source_address}/v3-flatcontainer/{package_name.lower()}/{package_version}/{package_name.lower()}.nuspec", timeout=5,headers=headers)
|
1837
|
-
return r.status_code==200
|
1865
|
+
r = requests.get(f"https://api.{default_source_address}/v3-flatcontainer/{package_name.lower()}/{package_version}/{package_name.lower()}.nuspec", timeout=5, headers=headers)
|
1866
|
+
return r.status_code == 200
|
1838
1867
|
else:
|
1839
1868
|
raise ValueError(f"dotnet_package_is_available is not implemented yet for other sources than {default_source_address}.")
|
1840
1869
|
|
1841
1870
|
@GeneralUtilities.check_arguments
|
1842
|
-
def wait_until_dotnet_package_is_available(self,package_name:str,package_version:str,source:str):
|
1843
|
-
while not self.dotnet_package_is_available(package_name,package_version,source):
|
1871
|
+
def wait_until_dotnet_package_is_available(self, package_name: str, package_version: str, source: str):
|
1872
|
+
while not self.dotnet_package_is_available(package_name, package_version, source):
|
1844
1873
|
time.sleep(5)
|
1845
1874
|
|
1846
|
-
|
1847
1875
|
@GeneralUtilities.check_arguments
|
1848
|
-
def python_package_is_available(self,package_name:str,package_version:str,source:str):
|
1849
|
-
default_source_address="pypi.org"
|
1850
|
-
if source==default_source_address:
|
1876
|
+
def python_package_is_available(self, package_name: str, package_version: str, source: str):
|
1877
|
+
default_source_address = "pypi.org"
|
1878
|
+
if source == default_source_address:
|
1851
1879
|
GeneralUtilities.write_message_to_stdout(f"Wait until package {package_name} v{package_version} is available on {source}.")
|
1852
1880
|
headers = {'Cache-Control': 'no-cache'}
|
1853
|
-
r=requests.get(f"https://{default_source_address}/pypi/{package_name}/{package_version}/json", timeout=5,headers=headers)
|
1854
|
-
return r.status_code==200
|
1881
|
+
r = requests.get(f"https://{default_source_address}/pypi/{package_name}/{package_version}/json", timeout=5, headers=headers)
|
1882
|
+
return r.status_code == 200
|
1855
1883
|
else:
|
1856
1884
|
raise ValueError(f"python_package_is_available is not implemented yet for other sources than {default_source_address}.")
|
1857
1885
|
|
1858
1886
|
@GeneralUtilities.check_arguments
|
1859
|
-
def
|
1860
|
-
while not self.python_package_is_available(package_name,package_version,source):
|
1887
|
+
def wait_until_python_package_is_available(self, package_name: str, package_version: str, source: str):
|
1888
|
+
while not self.python_package_is_available(package_name, package_version, source):
|
1861
1889
|
time.sleep(5)
|
1862
1890
|
|
1863
|
-
|
1864
1891
|
@GeneralUtilities.check_arguments
|
1865
1892
|
def create_deb_package(self, toolname: str, binary_folder: str, control_file_content: str, deb_output_folder: str, verbosity: int, permission_of_executable_file_as_octet_triple: int) -> None:
|
1866
1893
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ScriptCollection
|
3
|
-
Version: 3.5.
|
3
|
+
Version: 3.5.85
|
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
|
@@ -24,7 +24,7 @@ Requires-Python: >=3.10
|
|
24
24
|
Description-Content-Type: text/markdown
|
25
25
|
Requires-Dist: build>=1.2.2.post1
|
26
26
|
Requires-Dist: coverage>=7.6.12
|
27
|
-
Requires-Dist: cyclonedx-bom>=5.
|
27
|
+
Requires-Dist: cyclonedx-bom>=5.3.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
|
@@ -5,12 +5,12 @@ ScriptCollection/ProgramRunnerBase.py,sha256=2kMIAqdc65UjBAddOZkzy_aFx9h5roZ5a4b
|
|
5
5
|
ScriptCollection/ProgramRunnerEpew.py,sha256=4pjEd0r9Fcz3TTDv0MdTSd5KkigYXcWUVI1X43regfU,6477
|
6
6
|
ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
|
7
7
|
ScriptCollection/RPStream.py,sha256=NRRHL3YSP3D9MuAV2jB_--0KUKCsvJGxeKnxgrRZ9kY,1545
|
8
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=
|
8
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=5xL3OyzIfLB56lvIwMSjSxIwG30bEuDlWhicMIvobK8,122886
|
9
9
|
ScriptCollection/TasksForCommonProjectStructure.py,sha256=n6og3gADK7oBd5_9F-XNKVlQ0bO9EL7irdOSJAh-Vtc,215940
|
10
10
|
ScriptCollection/UpdateCertificates.py,sha256=Eynbgu7k9jLxApP2D_8Il77B6BFjJap6K7oTeEAZYbk,7790
|
11
11
|
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
scriptcollection-3.5.85.dist-info/METADATA,sha256=IINDRHU-BtfrXLP1MFNrA4TMfjtEJYcYj4BUlSdzS8k,7664
|
13
|
+
scriptcollection-3.5.85.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
14
|
+
scriptcollection-3.5.85.dist-info/entry_points.txt,sha256=1jAL5AuB8mvdw2v-6E7wCZFThurQxchiQynL8DCi-Yg,3545
|
15
|
+
scriptcollection-3.5.85.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
16
|
+
scriptcollection-3.5.85.dist-info/RECORD,,
|
File without changes
|
File without changes
|