ScriptCollection 3.5.2__py3-none-any.whl → 3.5.4__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.
@@ -19,6 +19,7 @@ import tempfile
19
19
  import io
20
20
  import requests
21
21
  import ntplib
22
+ import yaml
22
23
  import qrcode
23
24
  import pycdlib
24
25
  import send2trash
@@ -28,8 +29,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
28
29
  from .ProgramRunnerPopen import ProgramRunnerPopen
29
30
  from .ProgramRunnerEpew import ProgramRunnerEpew, CustomEpewArgument
30
31
 
31
-
32
- version = "3.5.2"
32
+ version = "3.5.4"
33
33
  __version__ = version
34
34
 
35
35
 
@@ -184,7 +184,7 @@ class ScriptCollectionCore:
184
184
  since_as_string = self.__datetime_to_string_for_git(since)
185
185
  until_as_string = self.__datetime_to_string_for_git(until)
186
186
  result = filter(lambda line: not GeneralUtilities.string_is_none_or_whitespace(line), self.run_program(
187
- "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", ""))
187
+ "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", ""))
188
188
  if ignore_commits_which_are_not_in_history_of_head:
189
189
  result = [commit_id for commit_id in result if self.git_commit_is_ancestor(
190
190
  repository_folder, commit_id)]
@@ -317,45 +317,36 @@ class ScriptCollectionCore:
317
317
  @GeneralUtilities.check_arguments
318
318
  def git_add_or_set_remote_address(self, directory: str, remote_name: str, remote_address: str) -> None:
319
319
  if (self.repository_has_remote_with_specific_name(directory, remote_name)):
320
- self.run_program_argsasarray("git", ['remote', 'set-url', 'remote_name', remote_address],
321
- directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
320
+ self.run_program_argsasarray("git", ['remote', 'set-url', 'remote_name', remote_address], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
322
321
  else:
323
- self.run_program_argsasarray("git", ['remote', 'add', remote_name, remote_address],
324
- directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
322
+ self.run_program_argsasarray("git", ['remote', 'add', remote_name, remote_address], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
325
323
 
326
324
  @GeneralUtilities.check_arguments
327
325
  def git_stage_all_changes(self, directory: str) -> None:
328
- self.run_program_argsasarray("git", [
329
- "add", "-A"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
326
+ self.run_program_argsasarray("git", ["add", "-A"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
330
327
 
331
328
  @GeneralUtilities.check_arguments
332
329
  def git_unstage_all_changes(self, directory: str) -> None:
333
- self.run_program_argsasarray("git", [
334
- "reset"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
330
+ self.run_program_argsasarray("git", ["reset"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
335
331
 
336
332
  @GeneralUtilities.check_arguments
337
333
  def git_stage_file(self, directory: str, file: str) -> None:
338
- self.run_program_argsasarray("git", [
339
- 'stage', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
334
+ self.run_program_argsasarray("git", ['stage', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
340
335
 
341
336
  @GeneralUtilities.check_arguments
342
337
  def git_unstage_file(self, directory: str, file: str) -> None:
343
- self.run_program_argsasarray("git", [
344
- 'reset', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
338
+ self.run_program_argsasarray("git", ['reset', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
345
339
 
346
340
  @GeneralUtilities.check_arguments
347
341
  def git_discard_unstaged_changes_of_file(self, directory: str, file: str) -> None:
348
342
  """Caution: This method works really only for 'changed' files yet. So this method does not work properly for new or renamed files."""
349
- self.run_program_argsasarray("git", [
350
- 'checkout', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
343
+ self.run_program_argsasarray("git", ['checkout', file], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
351
344
 
352
345
  @GeneralUtilities.check_arguments
353
346
  def git_discard_all_unstaged_changes(self, directory: str) -> None:
354
347
  """Caution: This function executes 'git clean -df'. This can delete files which maybe should not be deleted. Be aware of that."""
355
- self.run_program_argsasarray("git", [
356
- 'clean', '-df'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
357
- self.run_program_argsasarray("git", [
358
- 'checkout', '.'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
348
+ self.run_program_argsasarray("git", ['clean', '-df'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
349
+ self.run_program_argsasarray("git", ['checkout', '.'], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
359
350
 
360
351
  @GeneralUtilities.check_arguments
361
352
  def git_commit(self, directory: str, message: str, author_name: str = None, author_email: str = None, stage_all_changes: bool = True,
@@ -368,8 +359,7 @@ class ScriptCollectionCore:
368
359
  argument = ['commit', '--quiet', '--allow-empty', '--message', message]
369
360
  if (GeneralUtilities.string_has_content(author_name)):
370
361
  argument.append(f'--author="{author_name} <{author_email}>"')
371
- git_repository_has_uncommitted_changes = self.git_repository_has_uncommitted_changes(
372
- directory)
362
+ git_repository_has_uncommitted_changes = self.git_repository_has_uncommitted_changes(directory)
373
363
 
374
364
  if git_repository_has_uncommitted_changes:
375
365
  do_commit = True
@@ -377,22 +367,19 @@ class ScriptCollectionCore:
377
367
  self.git_stage_all_changes(directory)
378
368
  else:
379
369
  if no_changes_behavior == 0:
380
- GeneralUtilities.write_message_to_stdout(
381
- f"Commit '{message}' will not be done because there are no changes to commit in repository '{directory}'")
370
+ GeneralUtilities.write_message_to_stdout(f"Commit '{message}' will not be done because there are no changes to commit in repository '{directory}'")
382
371
  do_commit = False
383
- if no_changes_behavior == 1:
384
- GeneralUtilities.write_message_to_stdout(
385
- f"There are no changes to commit in repository '{directory}'. Commit '{message}' will be done anyway.")
372
+ elif no_changes_behavior == 1:
373
+ GeneralUtilities.write_message_to_stdout(f"There are no changes to commit in repository '{directory}'. Commit '{message}' will be done anyway.")
386
374
  do_commit = True
387
- if no_changes_behavior == 2:
388
- raise RuntimeError(
389
- f"There are no changes to commit in repository '{directory}'. Commit '{message}' will not be done.")
375
+ elif no_changes_behavior == 2:
376
+ raise RuntimeError(f"There are no changes to commit in repository '{directory}'. Commit '{message}' will not be done.")
377
+ else:
378
+ raise ValueError(f"Unknown value for no_changes_behavior: {GeneralUtilities.str_none_safe(no_changes_behavior)}")
390
379
 
391
380
  if do_commit:
392
- GeneralUtilities.write_message_to_stdout(
393
- f"Commit changes in '{directory}'")
394
- self.run_program_argsasarray(
395
- "git", argument, directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
381
+ GeneralUtilities.write_message_to_stdout(f"Commit changes in '{directory}'")
382
+ self.run_program_argsasarray("git", argument, directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
396
383
 
397
384
  return self.git_get_commit_id(directory)
398
385
 
@@ -408,20 +395,16 @@ class ScriptCollectionCore:
408
395
 
409
396
  @GeneralUtilities.check_arguments
410
397
  def git_delete_tag(self, directory: str, tag: str) -> None:
411
- self.run_program_argsasarray("git", [
412
- "tag", "--delete", tag], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
398
+ self.run_program_argsasarray("git", ["tag", "--delete", tag], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
413
399
 
414
400
  @GeneralUtilities.check_arguments
415
401
  def git_checkout(self, directory: str, branch: str) -> None:
416
- self.run_program_argsasarray("git", [
417
- "checkout", branch], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
418
- self.run_program_argsasarray("git", ["submodule", "update", "--recursive"],
419
- directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
402
+ self.run_program_argsasarray("git", ["checkout", branch], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
403
+ self.run_program_argsasarray("git", ["submodule", "update", "--recursive"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
420
404
 
421
405
  @GeneralUtilities.check_arguments
422
406
  def git_merge_abort(self, directory: str) -> None:
423
- self.run_program_argsasarray("git", [
424
- "merge", "--abort"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
407
+ self.run_program_argsasarray("git", ["merge", "--abort"], directory, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
425
408
 
426
409
  @GeneralUtilities.check_arguments
427
410
  def git_merge(self, directory: str, sourcebranch: str, targetbranch: str, fastforward: bool = True, commit: bool = True, commit_message: str = None) -> str:
@@ -457,8 +440,7 @@ class ScriptCollectionCore:
457
440
  self.git_fetch(target_directory)
458
441
  else:
459
442
  # clone
460
- self.git_clone(target_repository, source_repository,
461
- include_submodules=True, mirror=True)
443
+ self.git_clone(target_repository, source_repository, include_submodules=True, mirror=True)
462
444
 
463
445
  def get_git_submodules(self, folder: str) -> list[str]:
464
446
  e = self.run_program("git", "submodule status", folder)
@@ -475,8 +457,7 @@ class ScriptCollectionCore:
475
457
 
476
458
  @GeneralUtilities.check_arguments
477
459
  def file_is_git_ignored(self, file_in_repository: str, repositorybasefolder: str) -> None:
478
- exit_code = self.run_program_argsasarray(
479
- "git", ['check-ignore', file_in_repository], repositorybasefolder, throw_exception_if_exitcode_is_not_zero=False, verbosity=0)[0]
460
+ exit_code = self.run_program_argsasarray("git", ['check-ignore', file_in_repository], repositorybasefolder, throw_exception_if_exitcode_is_not_zero=False, verbosity=0)[0]
480
461
  if (exit_code == 0):
481
462
  return True
482
463
  if (exit_code == 1):
@@ -486,21 +467,17 @@ class ScriptCollectionCore:
486
467
 
487
468
  @GeneralUtilities.check_arguments
488
469
  def git_discard_all_changes(self, repository: str) -> None:
489
- self.run_program_argsasarray("git", [
490
- "reset", "HEAD", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
491
- self.run_program_argsasarray("git", [
492
- "checkout", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
470
+ self.run_program_argsasarray("git", ["reset", "HEAD", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
471
+ self.run_program_argsasarray("git", ["checkout", "."], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
493
472
 
494
473
  @GeneralUtilities.check_arguments
495
474
  def git_get_current_branch_name(self, repository: str) -> str:
496
- result = self.run_program_argsasarray(
497
- "git", ["rev-parse", "--abbrev-ref", "HEAD"], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
475
+ result = self.run_program_argsasarray("git", ["rev-parse", "--abbrev-ref", "HEAD"], repository, throw_exception_if_exitcode_is_not_zero=True, verbosity=0)
498
476
  return result[1].replace("\r", "").replace("\n", "")
499
477
 
500
478
  @GeneralUtilities.check_arguments
501
479
  def git_get_commitid_of_tag(self, repository: str, tag: str) -> str:
502
- stdout = self.run_program_argsasarray(
503
- "git", ["rev-list", "-n", "1", tag], repository, verbosity=0)
480
+ stdout = self.run_program_argsasarray("git", ["rev-list", "-n", "1", tag], repository, verbosity=0)
504
481
  result = stdout[1].replace("\r", "").replace("\n", "")
505
482
  return result
506
483
 
@@ -517,28 +494,22 @@ class ScriptCollectionCore:
517
494
  counter = 0
518
495
  for tag in tags:
519
496
  counter = counter+1
520
- GeneralUtilities.write_message_to_stdout(
521
- f"Process tag {counter}/{tags_count}.")
497
+ GeneralUtilities.write_message_to_stdout(f"Process tag {counter}/{tags_count}.")
522
498
  # tag is on source-branch
523
499
  if self.git_commit_is_ancestor(repository, tag, tag_source_branch):
524
500
  commit_id_old = self.git_get_commitid_of_tag(repository, tag)
525
- commit_date: datetime = self.git_get_commit_date(
526
- repository, commit_id_old)
501
+ commit_date: datetime = self.git_get_commit_date(repository, commit_id_old)
527
502
  date_as_string = self.__datetime_to_string_for_git(commit_date)
528
- search_commit_result = self.run_program_argsasarray("git", ["log", f'--after="{date_as_string}"', f'--before="{date_as_string}"',
529
- "--pretty=format:%H", tag_target_branch], repository, throw_exception_if_exitcode_is_not_zero=False)
503
+ search_commit_result = self.run_program_argsasarray("git", ["log", f'--after="{date_as_string}"', f'--before="{date_as_string}"', "--pretty=format:%H", tag_target_branch], repository, throw_exception_if_exitcode_is_not_zero=False)
530
504
  if search_commit_result[0] != 0 or not GeneralUtilities.string_has_nonwhitespace_content(search_commit_result[1]):
531
- raise ValueError(
532
- f"Can not calculate corresponding commit for tag '{tag}'.")
505
+ raise ValueError(f"Can not calculate corresponding commit for tag '{tag}'.")
533
506
  commit_id_new = search_commit_result[1]
534
507
  self.git_delete_tag(repository, tag)
535
- self.git_create_tag(
536
- repository, commit_id_new, tag, sign, message)
508
+ self.git_create_tag(repository, commit_id_new, tag, sign, message)
537
509
 
538
510
  @GeneralUtilities.check_arguments
539
511
  def get_current_git_branch_has_tag(self, repository_folder: str) -> bool:
540
- result = self.run_program_argsasarray(
541
- "git", ["describe", "--tags", "--abbrev=0"], repository_folder, verbosity=0, throw_exception_if_exitcode_is_not_zero=False)
512
+ result = self.run_program_argsasarray("git", ["describe", "--tags", "--abbrev=0"], repository_folder, verbosity=0, throw_exception_if_exitcode_is_not_zero=False)
542
513
  return result[0] == 0
543
514
 
544
515
  @GeneralUtilities.check_arguments
@@ -550,8 +521,7 @@ class ScriptCollectionCore:
550
521
 
551
522
  @GeneralUtilities.check_arguments
552
523
  def get_staged_or_committed_git_ignored_files(self, repository_folder: str) -> list[str]:
553
- tresult = self.run_program_argsasarray(
554
- "git", ["ls-files", "-i", "-c", "--exclude-standard"], repository_folder, verbosity=0)
524
+ tresult = self.run_program_argsasarray("git", ["ls-files", "-i", "-c", "--exclude-standard"], repository_folder, verbosity=0)
555
525
  tresult = tresult[1].replace("\r", "")
556
526
  result = [line for line in tresult.split("\n") if len(line) > 0]
557
527
  return result
@@ -562,8 +532,7 @@ class ScriptCollectionCore:
562
532
 
563
533
  @GeneralUtilities.check_arguments
564
534
  def export_filemetadata(self, folder: str, target_file: str, encoding: str = "utf-8", filter_function=None) -> None:
565
- folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(
566
- folder)
535
+ folder = GeneralUtilities.resolve_relative_path_from_current_working_directory(folder)
567
536
  lines = list()
568
537
  path_prefix = len(folder)+1
569
538
  items = dict()
@@ -578,8 +547,7 @@ class ScriptCollectionCore:
578
547
  file_or_folder)
579
548
  user = owner_and_permisssion[0]
580
549
  permissions = owner_and_permisssion[1]
581
- lines.append(
582
- f"{truncated_file};{item_type};{user};{permissions}")
550
+ lines.append(f"{truncated_file};{item_type};{user};{permissions}")
583
551
  lines = sorted(lines, key=str.casefold)
584
552
  with open(target_file, "w", encoding=encoding) as file_object:
585
553
  file_object.write("\n".join(lines))
@@ -605,8 +573,7 @@ class ScriptCollectionCore:
605
573
  renamed_items[subfolder2] = subfolder
606
574
  else:
607
575
  subfolder2 = subfolder
608
- self.__escape_git_repositories_in_folder_internal(
609
- subfolder2, renamed_items)
576
+ self.__escape_git_repositories_in_folder_internal(subfolder2, renamed_items)
610
577
  return renamed_items
611
578
 
612
579
  def deescape_git_repositories_in_folder(self, renamed_items: dict[str, str]):
@@ -628,48 +595,43 @@ class ScriptCollectionCore:
628
595
  lines.sort(key=self.__sort_fmd)
629
596
  for line in lines:
630
597
  splitted: list = line.split(";")
631
- full_path_of_file_or_folder: str = os.path.join(
632
- folder, splitted[0])
598
+ full_path_of_file_or_folder: str = os.path.join(folder, splitted[0])
633
599
  filetype: str = splitted[1]
634
600
  user: str = splitted[2]
635
601
  permissions: str = splitted[3]
636
602
  if filetype == "d" and create_folder_is_not_exist and not os.path.isdir(full_path_of_file_or_folder):
637
- GeneralUtilities.ensure_directory_exists(
638
- full_path_of_file_or_folder)
603
+ GeneralUtilities.ensure_directory_exists(full_path_of_file_or_folder)
639
604
  if (filetype == "f" and os.path.isfile(full_path_of_file_or_folder)) or (filetype == "d" and os.path.isdir(full_path_of_file_or_folder)):
640
- self.set_owner(full_path_of_file_or_folder,
641
- user, os.name != 'nt')
605
+ self.set_owner(full_path_of_file_or_folder, user, os.name != 'nt')
642
606
  self.set_permission(full_path_of_file_or_folder, permissions)
643
607
  else:
644
608
  if strict:
645
609
  if filetype == "f":
646
610
  filetype_full = "File"
647
- if filetype == "d":
611
+ elif filetype == "d":
648
612
  filetype_full = "Directory"
649
- raise ValueError(
650
- f"{filetype_full} '{full_path_of_file_or_folder}' does not exist")
613
+ else:
614
+ raise ValueError(f"Unknown filetype: {GeneralUtilities.str_none_safe(filetype)}")
615
+ raise ValueError(f"{filetype_full} '{full_path_of_file_or_folder}' does not exist")
651
616
 
652
617
  @GeneralUtilities.check_arguments
653
618
  def __calculate_lengh_in_seconds(self, filename: str, folder: str) -> float:
654
619
  argument = ['-v', 'error', '-show_entries', 'format=duration',
655
620
  '-of', 'default=noprint_wrappers=1:nokey=1', filename]
656
- result = self.run_program_argsasarray(
657
- "ffprobe", argument, folder, throw_exception_if_exitcode_is_not_zero=True)
621
+ result = self.run_program_argsasarray("ffprobe", argument, folder, throw_exception_if_exitcode_is_not_zero=True)
658
622
  return float(result[1].replace('\n', ''))
659
623
 
660
624
  @GeneralUtilities.check_arguments
661
625
  def __create_thumbnails(self, filename: str, fps: str, folder: str, tempname_for_thumbnails: str) -> None:
662
626
  argument = ['-i', filename, '-r', str(fps), '-vf', 'scale=-1:120',
663
627
  '-vcodec', 'png', f'{tempname_for_thumbnails}-%002d.png']
664
- self.run_program_argsasarray(
665
- "ffmpeg", argument, folder, throw_exception_if_exitcode_is_not_zero=True)
628
+ self.run_program_argsasarray("ffmpeg", argument, folder, throw_exception_if_exitcode_is_not_zero=True)
666
629
 
667
630
  @GeneralUtilities.check_arguments
668
631
  def __create_thumbnail(self, outputfilename: str, folder: str, length_in_seconds: float, tempname_for_thumbnails: str, amount_of_images: int) -> None:
669
632
  duration = timedelta(seconds=length_in_seconds)
670
633
  info = GeneralUtilities.timedelta_to_simple_string(duration)
671
- next_square_number = str(
672
- int(math.sqrt(GeneralUtilities.get_next_square_number(amount_of_images))))
634
+ next_square_number = str(int(math.sqrt(GeneralUtilities.get_next_square_number(amount_of_images))))
673
635
  argument = ['-title', f'"{outputfilename} ({info})"', '-tile', f'{next_square_number}x{next_square_number}',
674
636
  f'{tempname_for_thumbnails}*.png', f'{outputfilename}.png']
675
637
  self.run_program_argsasarray(
@@ -688,15 +650,13 @@ class ScriptCollectionCore:
688
650
  if tempname_for_thumbnails is None:
689
651
  tempname_for_thumbnails = "t"+str(uuid.uuid4())
690
652
 
691
- file = GeneralUtilities.resolve_relative_path_from_current_working_directory(
692
- file)
653
+ file = GeneralUtilities.resolve_relative_path_from_current_working_directory(file)
693
654
  filename = os.path.basename(file)
694
655
  folder = os.path.dirname(file)
695
656
  filename_without_extension = Path(file).stem
696
657
 
697
658
  try:
698
- length_in_seconds = self.__calculate_lengh_in_seconds(
699
- filename, folder)
659
+ length_in_seconds = self.__calculate_lengh_in_seconds(filename, folder)
700
660
  if (frames_per_second.endswith("fps")):
701
661
  # frames per second, example: frames_per_second="20fps" => 20 frames per second
702
662
  x = self.roundup(float(frames_per_second[:-3]), 2)
@@ -707,10 +667,8 @@ class ScriptCollectionCore:
707
667
  amounf_of_previewframes = int(float(frames_per_second))
708
668
  # self.roundup((amounf_of_previewframes-2)/length_in_seconds, 2)
709
669
  frames_per_secondx = f"{amounf_of_previewframes-2}/{length_in_seconds}"
710
- self.__create_thumbnails(
711
- filename, frames_per_secondx, folder, tempname_for_thumbnails)
712
- self.__create_thumbnail(filename_without_extension, folder,
713
- length_in_seconds, tempname_for_thumbnails, amounf_of_previewframes)
670
+ self.__create_thumbnails(filename, frames_per_secondx, folder, tempname_for_thumbnails)
671
+ self.__create_thumbnail(filename_without_extension, folder, length_in_seconds, tempname_for_thumbnails, amounf_of_previewframes)
714
672
  finally:
715
673
  for thumbnail_to_delete in Path(folder).rglob(tempname_for_thumbnails+"-*"):
716
674
  file = str(thumbnail_to_delete)
@@ -774,6 +732,7 @@ class ScriptCollectionCore:
774
732
  size = int(size_string[:-3]) * pow(2, 30)
775
733
  else:
776
734
  GeneralUtilities.write_message_to_stderr("Wrong format")
735
+ return 1
777
736
  else:
778
737
  GeneralUtilities.write_message_to_stderr("Wrong format")
779
738
  return 1
@@ -790,16 +749,13 @@ class ScriptCollectionCore:
790
749
 
791
750
  @GeneralUtilities.check_arguments
792
751
  def SCCreateSimpleMergeWithoutRelease(self, repository: str, sourcebranch: str, targetbranch: str, remotename: str, remove_source_branch: bool) -> None:
793
- commitid = self.git_merge(
794
- repository, sourcebranch, targetbranch, False, True)
752
+ commitid = self.git_merge(repository, sourcebranch, targetbranch, False, True)
795
753
  self.git_merge(repository, targetbranch, sourcebranch, True, True)
796
754
  created_version = self.get_semver_version_from_gitversion(repository)
797
755
  self.git_create_tag(repository, commitid, f"v{created_version}", True)
798
- self.git_push(repository, remotename, targetbranch,
799
- targetbranch, False, True)
756
+ self.git_push(repository, remotename, targetbranch, targetbranch, False, True)
800
757
  if (GeneralUtilities.string_has_nonwhitespace_content(remotename)):
801
- self.git_push(repository, remotename, sourcebranch,
802
- sourcebranch, False, True)
758
+ self.git_push(repository, remotename, sourcebranch, sourcebranch, False, True)
803
759
  if (remove_source_branch):
804
760
  self.git_remove_branch(repository, sourcebranch)
805
761
 
@@ -831,8 +787,7 @@ class ScriptCollectionCore:
831
787
 
832
788
  # sort lines if desired
833
789
  if sort:
834
- lines = sorted(lines, key=lambda singleline: self.__adapt_line_for_sorting(
835
- singleline, ignored_start_character))
790
+ lines = sorted(lines, key=lambda singleline: self.__adapt_line_for_sorting(singleline, ignored_start_character))
836
791
 
837
792
  # reinsert first line
838
793
  if ignore_first_line:
@@ -843,8 +798,7 @@ class ScriptCollectionCore:
843
798
 
844
799
  return 0
845
800
  else:
846
- GeneralUtilities.write_message_to_stdout(
847
- f"File '{file}' does not exist")
801
+ GeneralUtilities.write_message_to_stdout(f"File '{file}' does not exist")
848
802
  return 1
849
803
 
850
804
  @GeneralUtilities.check_arguments
@@ -873,8 +827,7 @@ class ScriptCollectionCore:
873
827
 
874
828
  @GeneralUtilities.check_arguments
875
829
  def __process_file(self, file: str, substringInFilename: str, newSubstringInFilename: str, conflictResolveMode: str) -> None:
876
- new_filename = os.path.join(os.path.dirname(file), os.path.basename(
877
- file).replace(substringInFilename, newSubstringInFilename))
830
+ new_filename = os.path.join(os.path.dirname(file), os.path.basename(file).replace(substringInFilename, newSubstringInFilename))
878
831
  if file != new_filename:
879
832
  if os.path.isfile(new_filename):
880
833
  if filecmp.cmp(file, new_filename):
@@ -899,8 +852,7 @@ class ScriptCollectionCore:
899
852
  @GeneralUtilities.check_arguments
900
853
  def SCReplaceSubstringsInFilenames(self, folder: str, substringInFilename: str, newSubstringInFilename: str, conflictResolveMode: str) -> None:
901
854
  for file in GeneralUtilities.absolute_file_paths(folder):
902
- self.__process_file(file, substringInFilename,
903
- newSubstringInFilename, conflictResolveMode)
855
+ self.__process_file(file, substringInFilename, newSubstringInFilename, conflictResolveMode)
904
856
 
905
857
  @GeneralUtilities.check_arguments
906
858
  def __check_file(self, file: str, searchstring: str) -> None:
@@ -953,24 +905,20 @@ class ScriptCollectionCore:
953
905
  self.upload_file_to_file_host(file, host))
954
906
  return 0
955
907
  except Exception as exception:
956
- GeneralUtilities.write_exception_to_stderr_with_traceback(
957
- exception, traceback)
908
+ GeneralUtilities.write_exception_to_stderr_with_traceback(exception, traceback)
958
909
  return 1
959
910
 
960
911
  @GeneralUtilities.check_arguments
961
912
  def SCFileIsAvailableOnFileHost(self, file: str) -> int:
962
913
  try:
963
914
  if self.file_is_available_on_file_host(file):
964
- GeneralUtilities.write_message_to_stdout(
965
- f"'{file}' is available")
915
+ GeneralUtilities.write_message_to_stdout(f"'{file}' is available")
966
916
  return 0
967
917
  else:
968
- GeneralUtilities.write_message_to_stdout(
969
- f"'{file}' is not available")
918
+ GeneralUtilities.write_message_to_stdout(f"'{file}' is not available")
970
919
  return 1
971
920
  except Exception as exception:
972
- GeneralUtilities.write_exception_to_stderr_with_traceback(
973
- exception, traceback)
921
+ GeneralUtilities.write_exception_to_stderr_with_traceback(exception, traceback)
974
922
  return 2
975
923
 
976
924
  @GeneralUtilities.check_arguments
@@ -982,8 +930,7 @@ class ScriptCollectionCore:
982
930
  # timestamp: "51eb505a"
983
931
  # target: "c1910018"
984
932
  # nonce: "de19b302"
985
- header = str(block_version_number + previousblockhash +
986
- transactionsmerkleroot + timestamp + target + nonce)
933
+ header = str(block_version_number + previousblockhash + transactionsmerkleroot + timestamp + target + nonce)
987
934
  return binascii.hexlify(hashlib.sha256(hashlib.sha256(binascii.unhexlify(header)).digest()).digest()[::-1]).decode('utf-8')
988
935
 
989
936
  @GeneralUtilities.check_arguments
@@ -1053,9 +1000,10 @@ class ScriptCollectionCore:
1053
1000
  @GeneralUtilities.check_arguments
1054
1001
  def SCFilenameObfuscator(self, inputfolder: str, printtableheadline, namemappingfile: str, extensions: str) -> None:
1055
1002
  obfuscate_all_files = extensions == "*"
1056
- if (not obfuscate_all_files):
1003
+ if (obfuscate_all_files):
1004
+ obfuscate_file_extensions = None
1005
+ else:
1057
1006
  obfuscate_file_extensions = extensions.split(",")
1058
-
1059
1007
  if (os.path.isdir(inputfolder)):
1060
1008
  printtableheadline = GeneralUtilities.string_to_boolean(
1061
1009
  printtableheadline)
@@ -1109,7 +1057,9 @@ class ScriptCollectionCore:
1109
1057
  @GeneralUtilities.check_arguments
1110
1058
  def SCObfuscateFilesFolder(self, inputfolder: str, printtableheadline, namemappingfile: str, extensions: str) -> None:
1111
1059
  obfuscate_all_files = extensions == "*"
1112
- if (not obfuscate_all_files):
1060
+ if (obfuscate_all_files):
1061
+ obfuscate_file_extensions = None
1062
+ else:
1113
1063
  if "," in extensions:
1114
1064
  obfuscate_file_extensions = extensions.split(",")
1115
1065
  else:
@@ -1123,11 +1073,22 @@ class ScriptCollectionCore:
1123
1073
  self.SCChangeHashOfProgram(file)
1124
1074
  os.remove(file)
1125
1075
  os.rename(file + ".modified", file)
1126
- self.SCFilenameObfuscator(
1127
- inputfolder, printtableheadline, namemappingfile, extensions)
1076
+ self.SCFilenameObfuscator(inputfolder, printtableheadline, namemappingfile, extensions)
1128
1077
  else:
1129
1078
  raise ValueError(f"Directory not found: '{inputfolder}'")
1130
1079
 
1080
+ @GeneralUtilities.check_arguments
1081
+ def get_services_from_yaml_file(self, yaml_file: str) -> list[str]:
1082
+ with open(yaml_file, encoding="utf-8") as stream:
1083
+ loaded = yaml.safe_load(stream)
1084
+ services = loaded["services"]
1085
+ result = list(services.keys())
1086
+ return result
1087
+
1088
+ @GeneralUtilities.check_arguments
1089
+ def kill_docker_container(self, container_name: str) -> None:
1090
+ self.run_program("docker", f"container rm -f {container_name}")
1091
+
1131
1092
  @GeneralUtilities.check_arguments
1132
1093
  def get_docker_debian_version(self, image_tag: str) -> str:
1133
1094
  result = ScriptCollectionCore().run_program_argsasarray(
@@ -1140,13 +1101,10 @@ class ScriptCollectionCore:
1140
1101
  package_url: str = f"https://deb.torproject.org/torproject.org/dists/{debian_version}/main/binary-amd64/Packages"
1141
1102
  r = requests.get(package_url, timeout=5)
1142
1103
  if r.status_code != 200:
1143
- raise ValueError(
1144
- f"Checking for latest tor package resulted in HTTP-response-code {r.status_code}.")
1145
- lines = GeneralUtilities.string_to_lines(
1146
- GeneralUtilities.bytes_to_string(r.content))
1104
+ raise ValueError(f"Checking for latest tor package resulted in HTTP-response-code {r.status_code}.")
1105
+ lines = GeneralUtilities.string_to_lines(GeneralUtilities.bytes_to_string(r.content))
1147
1106
  version_line_prefix = "Version: "
1148
- version_content_line = [
1149
- line for line in lines if line.startswith(version_line_prefix)][1]
1107
+ version_content_line = [line for line in lines if line.startswith(version_line_prefix)][1]
1150
1108
  version_with_overhead = version_content_line[len(version_line_prefix):]
1151
1109
  tor_version = version_with_overhead.split("~")[0]
1152
1110
  return tor_version
@@ -1192,13 +1150,10 @@ class ScriptCollectionCore:
1192
1150
  def run_testcases_for_python_project(self, repository_folder: str):
1193
1151
  self.run_program("coverage", "run -m pytest", repository_folder)
1194
1152
  self.run_program("coverage", "xml", repository_folder)
1195
- GeneralUtilities.ensure_directory_exists(
1196
- os.path.join(repository_folder, "Other/TestCoverage"))
1197
- coveragefile = os.path.join(
1198
- repository_folder, "Other/TestCoverage/TestCoverage.xml")
1153
+ GeneralUtilities.ensure_directory_exists(os.path.join(repository_folder, "Other/TestCoverage"))
1154
+ coveragefile = os.path.join(repository_folder, "Other/TestCoverage/TestCoverage.xml")
1199
1155
  GeneralUtilities.ensure_file_does_not_exist(coveragefile)
1200
- os.rename(os.path.join(repository_folder,
1201
- "coverage.xml"), coveragefile)
1156
+ os.rename(os.path.join(repository_folder, "coverage.xml"), coveragefile)
1202
1157
 
1203
1158
  @GeneralUtilities.check_arguments
1204
1159
  def get_file_permission(self, file: str) -> str:
@@ -1248,8 +1203,7 @@ class ScriptCollectionCore:
1248
1203
  GeneralUtilities.assert_condition(os.path.isfile(file) or os.path.isdir(
1249
1204
  file), f"Can not execute 'ls' because '{file}' does not exist")
1250
1205
  result = self.run_program_argsasarray("ls", ["-ld", file])
1251
- GeneralUtilities.assert_condition(
1252
- result[0] == 0, f"'ls -ld {file}' resulted in exitcode {str(result[0])}. StdErr: {result[2]}")
1206
+ GeneralUtilities.assert_condition(result[0] == 0, f"'ls -ld {file}' resulted in exitcode {str(result[0])}. StdErr: {result[2]}")
1253
1207
  GeneralUtilities.assert_condition(not GeneralUtilities.string_is_none_or_whitespace(
1254
1208
  result[1]), f"'ls' of '{file}' had an empty output. StdErr: '{result[2]}'")
1255
1209
  return result[1]
@@ -1302,8 +1256,7 @@ class ScriptCollectionCore:
1302
1256
  GeneralUtilities.write_message_to_stdout(f"Run '{info_for_log}'.")
1303
1257
 
1304
1258
  if isinstance(self.program_runner, ProgramRunnerEpew):
1305
- custom_argument = CustomEpewArgument(
1306
- print_errors_as_information, log_file, timeoutInSeconds, addLogOverhead, title, log_namespace, verbosity, arguments_for_log)
1259
+ custom_argument = CustomEpewArgument(print_errors_as_information, log_file, timeoutInSeconds, addLogOverhead, title, log_namespace, verbosity, arguments_for_log)
1307
1260
  popen: Popen = self.program_runner.run_program_argsasarray_async_helper(
1308
1261
  program, arguments_as_array, working_directory, custom_argument, interactive)
1309
1262
  return popen
@@ -1318,8 +1271,7 @@ class ScriptCollectionCore:
1318
1271
  # verbosity 4: Same as loglevel 3 but with some more overhead-information.
1319
1272
  try:
1320
1273
  arguments_as_str = ' '.join(arguments_as_array)
1321
- mock_loader_result = self.__try_load_mock(
1322
- program, arguments_as_str, working_directory)
1274
+ mock_loader_result = self.__try_load_mock(program, arguments_as_str, working_directory)
1323
1275
  if mock_loader_result[0]:
1324
1276
  return mock_loader_result[1]
1325
1277
 
@@ -1364,17 +1316,14 @@ class ScriptCollectionCore:
1364
1316
  stdoutresultb: bytes = stdoutreader.read()
1365
1317
  stdoutresult = GeneralUtilities.bytes_to_string(
1366
1318
  stdoutresultb)
1367
- stdoutlines = GeneralUtilities.string_to_lines(
1368
- stdoutresult)
1319
+ stdoutlines = GeneralUtilities.string_to_lines(stdoutresult)
1369
1320
  for line in stdoutlines:
1370
- line_stripped = line.replace(
1371
- "\r", "").strip()
1321
+ line_stripped = line.replace("\r", "").strip()
1372
1322
  if len(line_stripped) > 0:
1373
1323
  line_str = line_stripped
1374
1324
  stdout_lines.append(line_str)
1375
1325
  if live_console_output_printing:
1376
- GeneralUtilities.write_message_to_stdout(
1377
- line_str)
1326
+ GeneralUtilities.write_message_to_stdout(line_str)
1378
1327
  if log_to_file:
1379
1328
  GeneralUtilities.append_line_to_file(
1380
1329
  log_file, line_str)
@@ -1382,26 +1331,20 @@ class ScriptCollectionCore:
1382
1331
  stderrreader: BufferedReader = process.stderr
1383
1332
  if stderrreader.readable():
1384
1333
  stderrresultb: bytes = stderrreader.read()
1385
- stderrresult = GeneralUtilities.bytes_to_string(
1386
- stderrresultb)
1387
- stderrlines = GeneralUtilities.string_to_lines(
1388
- stderrresult)
1334
+ stderrresult = GeneralUtilities.bytes_to_string(stderrresultb)
1335
+ stderrlines = GeneralUtilities.string_to_lines(stderrresult)
1389
1336
  for line in stderrlines:
1390
- line_stripped = line.replace(
1391
- "\r", "").strip()
1337
+ line_stripped = line.replace("\r", "").strip()
1392
1338
  if len(line_stripped) > 0:
1393
1339
  line_str = line_stripped
1394
1340
  stderr_lines.append(line_str)
1395
1341
  if live_console_output_printing:
1396
1342
  if print_errors_as_information:
1397
- GeneralUtilities.write_message_to_stdout(
1398
- line_str)
1343
+ GeneralUtilities.write_message_to_stdout(line_str)
1399
1344
  else:
1400
- GeneralUtilities.write_message_to_stderr(
1401
- line_str)
1345
+ GeneralUtilities.write_message_to_stderr(line_str)
1402
1346
  if log_to_file:
1403
- GeneralUtilities.append_line_to_file(
1404
- log_file, line_str)
1347
+ GeneralUtilities.append_line_to_file(log_file, line_str)
1405
1348
 
1406
1349
  return go
1407
1350
  except Exception:
@@ -1416,23 +1359,17 @@ class ScriptCollectionCore:
1416
1359
  else:
1417
1360
  stdout, stderr = process.communicate()
1418
1361
  exit_code = process.wait()
1419
- stdout = GeneralUtilities.bytes_to_string(
1420
- stdout).replace('\r', '')
1421
- stderr = GeneralUtilities.bytes_to_string(
1422
- stderr).replace('\r', '')
1362
+ stdout = GeneralUtilities.bytes_to_string(stdout).replace('\r', '')
1363
+ stderr = GeneralUtilities.bytes_to_string(stderr).replace('\r', '')
1423
1364
 
1424
1365
  if arguments_for_exception_as_string is None:
1425
- arguments_for_exception_as_string = ' '.join(
1426
- arguments_as_array)
1366
+ arguments_for_exception_as_string = ' '.join(arguments_as_array)
1427
1367
  else:
1428
- arguments_for_exception_as_string = ' '.join(
1429
- arguments_for_log)
1368
+ arguments_for_exception_as_string = ' '.join(arguments_for_log)
1430
1369
 
1431
1370
  if throw_exception_if_exitcode_is_not_zero and exit_code != 0:
1432
- arguments_for_exception_as_string = ' '.join(
1433
- arguments_for_log)
1434
- raise ValueError(
1435
- f"Program '{working_directory}>{program} {arguments_for_exception_as_string}' resulted in exitcode {exit_code}. (StdOut: '{stdout}', StdErr: '{stderr}')")
1371
+ arguments_for_exception_as_string = ' '.join(arguments_for_log)
1372
+ raise ValueError(f"Program '{working_directory}>{program} {arguments_for_exception_as_string}' resulted in exitcode {exit_code}. (StdOut: '{stdout}', StdErr: '{stderr}')")
1436
1373
 
1437
1374
  result = (exit_code, stdout, stderr, pid)
1438
1375
  return result
@@ -1447,12 +1384,10 @@ class ScriptCollectionCore:
1447
1384
  # Return-values program_runner: Pid
1448
1385
  @GeneralUtilities.check_arguments
1449
1386
  def run_program_argsasarray_async(self, program: str, arguments_as_array: list[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, custom_argument: object = None, interactive: bool = False) -> int:
1450
- mock_loader_result = self.__try_load_mock(
1451
- program, ' '.join(arguments_as_array), working_directory)
1387
+ mock_loader_result = self.__try_load_mock(program, ' '.join(arguments_as_array), working_directory)
1452
1388
  if mock_loader_result[0]:
1453
1389
  return mock_loader_result[1]
1454
- process: Popen = self.__run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, verbosity, print_errors_as_information,
1455
- log_file, timeoutInSeconds, addLogOverhead, title, log_namespace, arguments_for_log, custom_argument, interactive)
1390
+ process: Popen = self.__run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, verbosity, print_errors_as_information, log_file, timeoutInSeconds, addLogOverhead, title, log_namespace, arguments_for_log, custom_argument, interactive)
1456
1391
  return process.pid
1457
1392
 
1458
1393
  # Return-values program_runner: Pid
@@ -1576,8 +1511,7 @@ class ScriptCollectionCore:
1576
1511
  @GeneralUtilities.check_arguments
1577
1512
  def increment_version(self, input_version: str, increment_major: bool, increment_minor: bool, increment_patch: bool) -> str:
1578
1513
  splitted = input_version.split(".")
1579
- GeneralUtilities.assert_condition(len(
1580
- splitted) == 3, f"Version '{input_version}' does not have the 'major.minor.patch'-pattern.")
1514
+ GeneralUtilities.assert_condition(len(splitted) == 3, f"Version '{input_version}' does not have the 'major.minor.patch'-pattern.")
1581
1515
  major = int(splitted[0])
1582
1516
  minor = int(splitted[1])
1583
1517
  patch = int(splitted[2])
@@ -1592,8 +1526,7 @@ class ScriptCollectionCore:
1592
1526
  @GeneralUtilities.check_arguments
1593
1527
  def get_semver_version_from_gitversion(self, repository_folder: str) -> str:
1594
1528
  if (self.git_repository_has_commits(repository_folder)):
1595
- result = self.get_version_from_gitversion(
1596
- repository_folder, "MajorMinorPatch")
1529
+ result = self.get_version_from_gitversion(repository_folder, "MajorMinorPatch")
1597
1530
  if self.git_repository_has_uncommitted_changes(repository_folder):
1598
1531
  if self.get_current_git_branch_has_tag(repository_folder):
1599
1532
  id_of_latest_tag = self.git_get_commitid_of_tag(
@@ -1615,17 +1548,14 @@ class ScriptCollectionCore:
1615
1548
  @GeneralUtilities.check_arguments
1616
1549
  def get_version_from_gitversion(self, folder: str, variable: str) -> str:
1617
1550
  # called twice as workaround for issue 1877 in gitversion ( https://github.com/GitTools/GitVersion/issues/1877 )
1618
- result = self.run_program_argsasarray(
1619
- "gitversion", ["/showVariable", variable], folder, verbosity=0)
1620
- result = self.run_program_argsasarray(
1621
- "gitversion", ["/showVariable", variable], folder, verbosity=0)
1551
+ result = self.run_program_argsasarray("gitversion", ["/showVariable", variable], folder, verbosity=0)
1552
+ result = self.run_program_argsasarray("gitversion", ["/showVariable", variable], folder, verbosity=0)
1622
1553
  result = GeneralUtilities.strip_new_line_character(result[1])
1623
1554
 
1624
1555
  return result
1625
1556
 
1626
1557
  @GeneralUtilities.check_arguments
1627
- def generate_certificate_authority(self, folder: str, name: str, subj_c: str, subj_st: str, subj_l: str, subj_o: str, subj_ou: str,
1628
- days_until_expire: int = None, password: str = None) -> None:
1558
+ def generate_certificate_authority(self, folder: str, name: str, subj_c: str, subj_st: str, subj_l: str, subj_o: str, subj_ou: str, days_until_expire: int = None, password: str = None) -> None:
1629
1559
  if days_until_expire is None:
1630
1560
  days_until_expire = 1825
1631
1561
  if password is None:
@@ -1640,12 +1570,9 @@ class ScriptCollectionCore:
1640
1570
  if password is None:
1641
1571
  password = GeneralUtilities.generate_password()
1642
1572
  rsa_key_length = 4096
1643
- self.run_program(
1644
- "openssl", f'genrsa -out {filename}.key {rsa_key_length}', folder)
1645
- self.run_program(
1646
- "openssl", f'req -new -subj /C={subj_c}/ST={subj_st}/L={subj_l}/O={subj_o}/CN={domain}/OU={subj_ou} -x509 -key {filename}.key -out {filename}.unsigned.crt -days {days_until_expire}', folder)
1647
- self.run_program(
1648
- "openssl", f'pkcs12 -export -out {filename}.selfsigned.pfx -password pass:{password} -inkey {filename}.key -in {filename}.unsigned.crt', folder)
1573
+ self.run_program("openssl", f'genrsa -out {filename}.key {rsa_key_length}', folder)
1574
+ self.run_program("openssl", f'req -new -subj /C={subj_c}/ST={subj_st}/L={subj_l}/O={subj_o}/CN={domain}/OU={subj_ou} -x509 -key {filename}.key -out {filename}.unsigned.crt -days {days_until_expire}', folder)
1575
+ self.run_program("openssl", f'pkcs12 -export -out {filename}.selfsigned.pfx -password pass:{password} -inkey {filename}.key -in {filename}.unsigned.crt', folder)
1649
1576
  GeneralUtilities.write_text_to_file(
1650
1577
  os.path.join(folder, f"{filename}.password"), password)
1651
1578
  GeneralUtilities.write_text_to_file(os.path.join(folder, f"{filename}.san.conf"), f"""[ req ]
@@ -1693,8 +1620,7 @@ DNS = {domain}
1693
1620
  lines = GeneralUtilities.read_lines_from_file(file)
1694
1621
  new_lines = []
1695
1622
  for line in lines:
1696
- new_lines.append(
1697
- self.__get_updated_line_for_python_requirements(line.strip()))
1623
+ new_lines.append(self.__get_updated_line_for_python_requirements(line.strip()))
1698
1624
  GeneralUtilities.write_lines_to_file(file, new_lines)
1699
1625
 
1700
1626
  @GeneralUtilities.check_arguments
@@ -1707,8 +1633,7 @@ DNS = {domain}
1707
1633
  # (something like "cyclonedx-bom>=3.11.0" for example)
1708
1634
  package = line.split(">")[0]
1709
1635
  operator = ">=" if ">=" in line else ">"
1710
- response = requests.get(
1711
- f'https://pypi.org/pypi/{package}/json', timeout=5)
1636
+ response = requests.get(f'https://pypi.org/pypi/{package}/json', timeout=5)
1712
1637
  latest_version = response.json()['info']['version']
1713
1638
  return package+operator+latest_version
1714
1639
  except:
@@ -1739,22 +1664,18 @@ DNS = {domain}
1739
1664
  def update_dependencies_of_dotnet_project(self, csproj_file: str, verbosity: int):
1740
1665
  folder = os.path.dirname(csproj_file)
1741
1666
  csproj_filename = os.path.basename(csproj_file)
1742
- GeneralUtilities.write_message_to_stderr(
1743
- f"Check for updates in {csproj_filename}")
1744
- result = self.run_program(
1745
- "dotnet", f"list {csproj_filename} package --outdated", folder)
1667
+ GeneralUtilities.write_message_to_stderr(f"Check for updates in {csproj_filename}")
1668
+ result = self.run_program("dotnet", f"list {csproj_filename} package --outdated", folder)
1746
1669
  for line in result[1].replace("\r", "").split("\n"):
1747
1670
  # Relevant output-lines are something like " > NJsonSchema 10.7.0 10.7.0 10.9.0"
1748
1671
  if ">" in line:
1749
1672
  package_name = line.replace(">", "").strip().split(" ")[0]
1750
- GeneralUtilities.write_message_to_stderr(
1751
- f"Update package {package_name}")
1673
+ GeneralUtilities.write_message_to_stderr(f"Update package {package_name}")
1752
1674
  self.run_program(
1753
1675
  "dotnet", f"add {csproj_filename} package {package_name}", folder)
1754
1676
 
1755
1677
  @GeneralUtilities.check_arguments
1756
- def create_deb_package(self, toolname: str, binary_folder: str, control_file_content: str,
1757
- deb_output_folder: str, verbosity: int, permission_of_executable_file_as_octet_triple: int) -> None:
1678
+ 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:
1758
1679
 
1759
1680
  # prepare
1760
1681
  GeneralUtilities.ensure_directory_exists(deb_output_folder)
@@ -1766,18 +1687,14 @@ DNS = {domain}
1766
1687
  # create folder
1767
1688
  GeneralUtilities.ensure_directory_exists(temp_folder)
1768
1689
  control_content_folder_name = "controlcontent"
1769
- packagecontent_control_folder = os.path.join(
1770
- temp_folder, control_content_folder_name)
1690
+ packagecontent_control_folder = os.path.join(temp_folder, control_content_folder_name)
1771
1691
  GeneralUtilities.ensure_directory_exists(packagecontent_control_folder)
1772
1692
  data_content_folder_name = "datacontent"
1773
- packagecontent_data_folder = os.path.join(
1774
- temp_folder, data_content_folder_name)
1693
+ packagecontent_data_folder = os.path.join(temp_folder, data_content_folder_name)
1775
1694
  GeneralUtilities.ensure_directory_exists(packagecontent_data_folder)
1776
1695
  entireresult_content_folder_name = "entireresultcontent"
1777
- packagecontent_entireresult_folder = os.path.join(
1778
- temp_folder, entireresult_content_folder_name)
1779
- GeneralUtilities.ensure_directory_exists(
1780
- packagecontent_entireresult_folder)
1696
+ packagecontent_entireresult_folder = os.path.join(temp_folder, entireresult_content_folder_name)
1697
+ GeneralUtilities.ensure_directory_exists(packagecontent_entireresult_folder)
1781
1698
 
1782
1699
  # create "debian-binary"-file
1783
1700
  debianbinary_file = os.path.join(
@@ -1788,8 +1705,7 @@ DNS = {domain}
1788
1705
  # create control-content
1789
1706
 
1790
1707
  # conffiles
1791
- conffiles_file = os.path.join(
1792
- packagecontent_control_folder, "conffiles")
1708
+ conffiles_file = os.path.join(packagecontent_control_folder, "conffiles")
1793
1709
  GeneralUtilities.ensure_file_exists(conffiles_file)
1794
1710
 
1795
1711
  # postinst-script
@@ -1820,19 +1736,15 @@ DNS = {domain}
1820
1736
  GeneralUtilities.ensure_directory_exists(usr_bin_folder)
1821
1737
  usr_bin_content_folder = os.path.join(
1822
1738
  usr_bin_folder, tool_content_folder_name)
1823
- GeneralUtilities.copy_content_of_folder(
1824
- bin_folder, usr_bin_content_folder)
1739
+ GeneralUtilities.copy_content_of_folder(bin_folder, usr_bin_content_folder)
1825
1740
 
1826
1741
  # create debfile
1827
1742
  deb_filename = f"{toolname}.deb"
1828
- self.run_program_argsasarray("tar", [
1829
- "czf", f"../{entireresult_content_folder_name}/control.tar.gz", "*"], packagecontent_control_folder, verbosity=verbosity)
1830
- self.run_program_argsasarray("tar", [
1831
- "czf", f"../{entireresult_content_folder_name}/data.tar.gz", "*"], packagecontent_data_folder, verbosity=verbosity)
1743
+ self.run_program_argsasarray("tar", ["czf", f"../{entireresult_content_folder_name}/control.tar.gz", "*"], packagecontent_control_folder, verbosity=verbosity)
1744
+ self.run_program_argsasarray("tar", ["czf", f"../{entireresult_content_folder_name}/data.tar.gz", "*"], packagecontent_data_folder, verbosity=verbosity)
1832
1745
  self.run_program_argsasarray("ar", ["r", deb_filename, "debian-binary", "control.tar.gz",
1833
1746
  "data.tar.gz"], packagecontent_entireresult_folder, verbosity=verbosity)
1834
- result_file = os.path.join(
1835
- packagecontent_entireresult_folder, deb_filename)
1747
+ result_file = os.path.join(packagecontent_entireresult_folder, deb_filename)
1836
1748
  shutil.copy(result_file, os.path.join(deb_output_folder, deb_filename))
1837
1749
 
1838
1750
  # cleanup