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