ScriptCollection 3.5.16__py3-none-any.whl → 4.0.78__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ScriptCollection/AnionBuildPlatform.py +206 -0
- ScriptCollection/{UpdateCertificates.py → CertificateUpdater.py} +69 -46
- ScriptCollection/Executables.py +515 -18
- ScriptCollection/GeneralUtilities.py +1272 -873
- ScriptCollection/ImageUpdater.py +648 -0
- ScriptCollection/ProgramRunnerBase.py +10 -10
- ScriptCollection/ProgramRunnerMock.py +2 -0
- ScriptCollection/ProgramRunnerPopen.py +7 -1
- ScriptCollection/ProgramRunnerSudo.py +108 -0
- ScriptCollection/SCLog.py +115 -0
- ScriptCollection/ScriptCollectionCore.py +942 -266
- ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py +95 -0
- ScriptCollection/TFCPS/Docker/__init__.py +0 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py +8 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py +6 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py +7 -0
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +485 -0
- ScriptCollection/TFCPS/DotNet/__init__.py +0 -0
- ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py +130 -0
- ScriptCollection/TFCPS/Flutter/__init__.py +0 -0
- ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py +74 -0
- ScriptCollection/TFCPS/Go/__init__.py +0 -0
- ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py +131 -0
- ScriptCollection/TFCPS/NodeJS/__init__.py +0 -0
- ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py +227 -0
- ScriptCollection/TFCPS/Python/__init__.py +0 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py +418 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py +128 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +136 -0
- ScriptCollection/TFCPS/TFCPS_CreateRelease.py +95 -0
- ScriptCollection/TFCPS/TFCPS_Generic.py +43 -0
- ScriptCollection/TFCPS/TFCPS_MergeToMain.py +122 -0
- ScriptCollection/TFCPS/TFCPS_MergeToStable.py +350 -0
- ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py +47 -0
- ScriptCollection/TFCPS/TFCPS_Tools_General.py +1356 -0
- ScriptCollection/TFCPS/__init__.py +0 -0
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/METADATA +23 -22
- scriptcollection-4.0.78.dist-info/RECORD +43 -0
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/WHEEL +1 -1
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/entry_points.txt +32 -0
- ScriptCollection/ProgramRunnerEpew.py +0 -122
- ScriptCollection/RPStream.py +0 -42
- ScriptCollection/TasksForCommonProjectStructure.py +0 -2625
- ScriptCollection-3.5.16.dist-info/RECORD +0 -16
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/top_level.txt +0 -0
ScriptCollection/Executables.py
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import base64
|
|
1
2
|
import os
|
|
2
3
|
import argparse
|
|
3
4
|
import time
|
|
4
5
|
import traceback
|
|
5
|
-
import
|
|
6
|
+
import shutil
|
|
6
7
|
import keyboard
|
|
7
|
-
from .TasksForCommonProjectStructure import TasksForCommonProjectStructure
|
|
8
8
|
from .ScriptCollectionCore import ScriptCollectionCore
|
|
9
9
|
from .GeneralUtilities import GeneralUtilities
|
|
10
|
-
|
|
10
|
+
from .SCLog import LogLevel
|
|
11
|
+
from .ImageUpdater import ImageUpdater, VersionEcholon
|
|
12
|
+
from .TFCPS.TFCPS_CodeUnit_BuildCodeUnits import TFCPS_CodeUnit_BuildCodeUnits
|
|
13
|
+
from .TFCPS.TFCPS_Tools_General import TFCPS_Tools_General
|
|
11
14
|
|
|
12
15
|
def FilenameObfuscator() -> int:
|
|
13
16
|
parser = argparse.ArgumentParser(description=''''Obfuscates the names of all files in the given folder.
|
|
14
17
|
Caution: This script can cause harm if you pass a wrong inputfolder-argument.''')
|
|
15
18
|
|
|
16
|
-
parser.add_argument('--printtableheadline', type=GeneralUtilities.string_to_boolean, const=True, default=True, nargs='?',
|
|
19
|
+
parser.add_argument('--printtableheadline', type=GeneralUtilities.string_to_boolean, const=True, default=True, nargs='?', help='Prints column-titles in the name-mapping-csv-file')
|
|
17
20
|
parser.add_argument('--namemappingfile', default="NameMapping.csv", help='Specifies the file where the name-mapping will be written to')
|
|
18
21
|
parser.add_argument('--extensions', default="exe,py,sh",
|
|
19
22
|
help='Comma-separated list of file-extensions of files where this tool should be applied. Use "*" to obfuscate all')
|
|
@@ -256,36 +259,77 @@ def HealthCheck() -> int:
|
|
|
256
259
|
def BuildCodeUnit() -> int:
|
|
257
260
|
parser = argparse.ArgumentParser()
|
|
258
261
|
parser.add_argument('--codeunitfolder', required=False, default=".")
|
|
259
|
-
|
|
260
|
-
parser.add_argument('--
|
|
261
|
-
parser.add_argument('--
|
|
262
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
263
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
264
|
+
parser.add_argument('-e','--targetenvironment', required=False, default="QualityCheck")
|
|
265
|
+
parser.add_argument('-a','--additionalargumentsfile', required=False, default=None)
|
|
262
266
|
parser.add_argument('--assume_dependent_codeunits_are_already_built', type=GeneralUtilities.string_to_boolean, const=True, default=False, nargs='?')
|
|
263
|
-
args = parser.parse_args()
|
|
264
|
-
TasksForCommonProjectStructure(
|
|
265
|
-
|
|
267
|
+
#args = parser.parse_args()
|
|
268
|
+
#t=TasksForCommonProjectStructure(args)
|
|
269
|
+
#t.build_codeunit(args.codeunitfolder, args.targetenvironment, args.additionalargumentsfile, False, None, args.assume_dependent_codeunits_are_already_built, sys.argv)
|
|
270
|
+
#return 0
|
|
271
|
+
return 1#TODO
|
|
266
272
|
|
|
267
273
|
|
|
268
274
|
def BuildCodeUnits() -> int:
|
|
269
275
|
parser = argparse.ArgumentParser()
|
|
276
|
+
|
|
270
277
|
parser.add_argument('--repositoryfolder', required=False, default=".")
|
|
271
|
-
|
|
272
|
-
parser.add_argument('--
|
|
273
|
-
parser.add_argument('--
|
|
278
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
279
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
280
|
+
parser.add_argument('-e','--targetenvironment', required=False, default="QualityCheck")
|
|
281
|
+
parser.add_argument('-a','--additionalargumentsfile', required=False, default=None)
|
|
282
|
+
parser.add_argument("-c",'--nocache', required=False, default=False, action='store_true')
|
|
283
|
+
parser.add_argument('--ispremerge', required=False, default=False, action='store_true')
|
|
284
|
+
|
|
274
285
|
args = parser.parse_args()
|
|
275
|
-
|
|
286
|
+
|
|
287
|
+
verbosity=LogLevel(int(args.verbosity))
|
|
288
|
+
|
|
289
|
+
repo:str=args.repositoryfolder
|
|
290
|
+
if not os.path.isabs(args.repositoryfolder):
|
|
291
|
+
repo=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
|
|
292
|
+
|
|
293
|
+
t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,args.ispremerge)
|
|
294
|
+
t.build_codeunits()
|
|
276
295
|
return 0
|
|
277
296
|
|
|
278
297
|
|
|
279
298
|
def BuildCodeUnitsC() -> int:
|
|
280
299
|
parser = argparse.ArgumentParser()
|
|
281
300
|
parser.add_argument('--repositoryfolder', required=False, default=".")
|
|
282
|
-
|
|
301
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
302
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
283
303
|
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
|
284
304
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
|
285
305
|
parser.add_argument('--image', required=False, default="scbuilder:latest")
|
|
286
|
-
args = parser.parse_args()
|
|
306
|
+
#args = parser.parse_args()
|
|
287
307
|
GeneralUtilities.reconfigure_standrd_input_and_outputs()
|
|
288
|
-
TasksForCommonProjectStructure(
|
|
308
|
+
#t=TasksForCommonProjectStructure(args)
|
|
309
|
+
#t.build_codeunitsC(args.repositoryfolder, args.image, args.targetenvironment, args.additionalargumentsfile, sys.argv)
|
|
310
|
+
#return 0
|
|
311
|
+
return 1#TODO
|
|
312
|
+
|
|
313
|
+
def UpdateDependencies() -> int:
|
|
314
|
+
parser = argparse.ArgumentParser()
|
|
315
|
+
|
|
316
|
+
parser.add_argument('--repositoryfolder', required=False, default=".")
|
|
317
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
318
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
319
|
+
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
|
320
|
+
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
|
321
|
+
parser.add_argument("-c",'--nocache', required=False, default=False, action='store_true')
|
|
322
|
+
|
|
323
|
+
args = parser.parse_args()
|
|
324
|
+
|
|
325
|
+
verbosity=LogLevel(int(args.verbosity))
|
|
326
|
+
|
|
327
|
+
repo:str=args.repositoryfolder
|
|
328
|
+
if not os.path.isabs(args.repositoryfolder):
|
|
329
|
+
repo=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
|
|
330
|
+
|
|
331
|
+
t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,False)
|
|
332
|
+
t.update_dependencies()
|
|
289
333
|
return 0
|
|
290
334
|
|
|
291
335
|
|
|
@@ -362,10 +406,463 @@ def GenerateARC42ReferenceTemplate() -> int:
|
|
|
362
406
|
parser = argparse.ArgumentParser()
|
|
363
407
|
parser.add_argument('-f', '--folder', required=False)
|
|
364
408
|
parser.add_argument('-p', '--productname', required=False)
|
|
409
|
+
parser.add_argument('-s', '--subfolder', required=False)
|
|
365
410
|
args = parser.parse_args()
|
|
366
411
|
|
|
367
412
|
folder = args.folder
|
|
368
413
|
if folder is None:
|
|
369
414
|
folder = os.getcwd()
|
|
370
|
-
ScriptCollectionCore().generate_arc42_reference_template(folder, args.productname)
|
|
415
|
+
ScriptCollectionCore().generate_arc42_reference_template(folder, args.productname, args.subfolder)
|
|
416
|
+
return 0
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def CreateChangelogEntry() -> int:
|
|
420
|
+
parser = argparse.ArgumentParser()
|
|
421
|
+
parser.add_argument('-p', '--repositorypath', required=False, default=".")
|
|
422
|
+
parser.add_argument('-m', '--message', required=False, default="Updates.")
|
|
423
|
+
parser.add_argument('-c', '--commit', action='store_true', required=False, default=False)
|
|
424
|
+
parser.add_argument('-f', '--force', action='store_true', required=False, default=False)
|
|
425
|
+
args = parser.parse_args()
|
|
426
|
+
|
|
427
|
+
folder: str = None
|
|
428
|
+
if os.path.isabs(args.repositorypath):
|
|
429
|
+
folder = args.repositorypath
|
|
430
|
+
else:
|
|
431
|
+
folder = GeneralUtilities.resolve_relative_path(args.repositorypath, os.getcwd())
|
|
432
|
+
t=TFCPS_Tools_General(ScriptCollectionCore())
|
|
433
|
+
t.create_changelog_entry(folder, args.message, args.commit, args.force)
|
|
434
|
+
return 0
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
def FileExists() -> int:
|
|
438
|
+
parser = argparse.ArgumentParser(description="This function returns 0 if the given file exists. Otherwise this function returns 2. If an error occurrs the exitcode is 1.")
|
|
439
|
+
parser.add_argument('-p', '--path', required=True)
|
|
440
|
+
args = parser.parse_args()
|
|
441
|
+
if os.path.isfile(args.path):
|
|
442
|
+
return 0
|
|
443
|
+
else:
|
|
444
|
+
return 2
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
def FolderExists() -> int:
|
|
448
|
+
parser = argparse.ArgumentParser(description="This function returns 0 if the given folder exists. Otherwise this function returns 2. If an error occurrs the exitcode is 1.")
|
|
449
|
+
parser.add_argument('-p', '--path', required=True)
|
|
450
|
+
args = parser.parse_args()
|
|
451
|
+
if os.path.isdir(args.path):
|
|
452
|
+
return 0
|
|
453
|
+
else:
|
|
454
|
+
return 2
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def PrintFileContent() -> int:
|
|
458
|
+
parser = argparse.ArgumentParser(description="This function prints the size of a file")
|
|
459
|
+
parser.add_argument('-p', '--path', required=True)
|
|
460
|
+
parser.add_argument('-e', '--encoding', required=False, default="utf-8")
|
|
461
|
+
args = parser.parse_args()
|
|
462
|
+
file = args.path
|
|
463
|
+
encoding = args.encoding
|
|
464
|
+
if os.path.isfile(file):
|
|
465
|
+
GeneralUtilities.write_message_to_stdout(GeneralUtilities.read_text_from_file(file, encoding))
|
|
466
|
+
return 0
|
|
467
|
+
else:
|
|
468
|
+
GeneralUtilities.write_exception_to_stderr(f"File '{file}' does not exist.")
|
|
469
|
+
return 1
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def CreateFile() -> int:
|
|
473
|
+
parser = argparse.ArgumentParser(description="This function creates an empty file.")
|
|
474
|
+
parser.add_argument('-p', '--path', required=True)
|
|
475
|
+
parser.add_argument('-e', '--errorwhenexists', action='store_true', required=False, default=False)
|
|
476
|
+
parser.add_argument('-c', '--createnecessaryfolder', action='store_true', required=False, default=False)
|
|
477
|
+
args = parser.parse_args()
|
|
478
|
+
sc = ScriptCollectionCore()
|
|
479
|
+
sc.create_file(args.path, args.errorwhenexists, args.createnecessaryfolder)
|
|
480
|
+
return 0
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def CreateFolder() -> int:
|
|
484
|
+
parser = argparse.ArgumentParser(description="This function creates an empty folder.")
|
|
485
|
+
parser.add_argument('-p', '--path', required=True)
|
|
486
|
+
parser.add_argument('-e', '--errorwhenexists', action='store_true', required=False, default=False)
|
|
487
|
+
parser.add_argument('-c', '--createnecessaryfolder', action='store_true', required=False, default=False)
|
|
488
|
+
args = parser.parse_args()
|
|
489
|
+
sc = ScriptCollectionCore()
|
|
490
|
+
sc.create_folder(args.path, args.errorwhenexists, args.createnecessaryfolder)
|
|
491
|
+
return 0
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def AppendLineToFile() -> int:
|
|
495
|
+
GeneralUtilities.write_message_to_stderr("This function is not implemented yet.")
|
|
496
|
+
# TODO implement function
|
|
497
|
+
# TODO add switch to set if adding new line at begin of line should be skipped if the file already ends with a new-line-character
|
|
498
|
+
# TODO add switch to enable/disable appending another new-line-character at the end of the file
|
|
499
|
+
return 1
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
def RegexReplaceInFile() -> int:
|
|
503
|
+
GeneralUtilities.write_message_to_stderr("This function is not implemented yet.")
|
|
504
|
+
# TODO implement function
|
|
505
|
+
return 1
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
def PrintFileSize() -> int:
|
|
509
|
+
parser = argparse.ArgumentParser(description="This function prints the size of a file")
|
|
510
|
+
parser.add_argument('-p', '--path', required=True)
|
|
511
|
+
args = parser.parse_args()
|
|
512
|
+
file = args.path
|
|
513
|
+
if os.path.isfile(file):
|
|
514
|
+
size = os.path.getsize(file)
|
|
515
|
+
GeneralUtilities.write_message_to_stdout(str(size))
|
|
516
|
+
return 0
|
|
517
|
+
else:
|
|
518
|
+
GeneralUtilities.write_exception_to_stderr(f"File '{file}' does not exist.")
|
|
519
|
+
return 1
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
def FileContainsContent() -> int:
|
|
523
|
+
GeneralUtilities.write_message_to_stderr("This function is not implemented yet.")
|
|
524
|
+
# TODO implement function
|
|
525
|
+
# TODO add switch to set if the input pattern should be treated as regex
|
|
526
|
+
return 1
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def RemoveFile() -> int:
|
|
530
|
+
parser = argparse.ArgumentParser(description="This function removes a file.")
|
|
531
|
+
parser.add_argument('-p', '--path', required=True)
|
|
532
|
+
parser.add_argument('-e', '--errorwhennotexists', action='store_true', required=False, default=False)
|
|
533
|
+
args = parser.parse_args()
|
|
534
|
+
file = args.path
|
|
535
|
+
errorwhennotexists = args.errorwhennotexists
|
|
536
|
+
if os.path.isfile(file):
|
|
537
|
+
GeneralUtilities.ensure_file_does_not_exist(file)
|
|
538
|
+
else:
|
|
539
|
+
if errorwhennotexists:
|
|
540
|
+
GeneralUtilities.write_exception_to_stderr(f"File '{file}' does not exist.")
|
|
541
|
+
return 1
|
|
542
|
+
return 0
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
def RemoveFolder() -> int:
|
|
546
|
+
parser = argparse.ArgumentParser(description="This function removes a folder.")
|
|
547
|
+
parser.add_argument('-p', '--path', required=True)
|
|
548
|
+
parser.add_argument('-e', '--errorwhennotexists', action='store_true', required=False, default=False)
|
|
549
|
+
args = parser.parse_args()
|
|
550
|
+
folder = args.path
|
|
551
|
+
errorwhennotexists = args.errorwhennotexists
|
|
552
|
+
if os.path.isdir(folder):
|
|
553
|
+
GeneralUtilities.ensure_directory_does_not_exist(folder)
|
|
554
|
+
else:
|
|
555
|
+
if errorwhennotexists:
|
|
556
|
+
GeneralUtilities.write_exception_to_stderr(f"Folder '{folder}' does not exist.")
|
|
557
|
+
return 1
|
|
558
|
+
return 0
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def Rename() -> int:
|
|
562
|
+
parser = argparse.ArgumentParser(description="This function renames a file or folder.")
|
|
563
|
+
parser.add_argument('-s', '--source', required=True)
|
|
564
|
+
parser.add_argument('-t', '--target', required=True)
|
|
565
|
+
args = parser.parse_args()
|
|
566
|
+
os.rename(args.source, args.target)
|
|
567
|
+
return 0
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
def Copy() -> int:
|
|
571
|
+
parser = argparse.ArgumentParser(description="This function copies a file or folder.")
|
|
572
|
+
parser.add_argument('-s', '--source', required=True)
|
|
573
|
+
parser.add_argument('-t', '--target', required=True)
|
|
574
|
+
args = parser.parse_args()
|
|
575
|
+
|
|
576
|
+
if os.path.isfile(args.target) or os.path.isdir(args.target):
|
|
577
|
+
raise ValueError(f"Can not copy to '{args.target}' because the target already exists.")
|
|
578
|
+
|
|
579
|
+
source = args.source
|
|
580
|
+
if not os.path.isabs(source):
|
|
581
|
+
source = GeneralUtilities.resolve_relative_path(source, os.getcwd())
|
|
582
|
+
target = args.target
|
|
583
|
+
if not os.path.isabs(target):
|
|
584
|
+
target = GeneralUtilities.resolve_relative_path(target, os.getcwd())
|
|
585
|
+
|
|
586
|
+
if os.path.isfile(source):
|
|
587
|
+
shutil.copyfile(source, target)
|
|
588
|
+
elif os.path.isdir(source):
|
|
589
|
+
GeneralUtilities.ensure_directory_exists(target)
|
|
590
|
+
GeneralUtilities.copy_content_of_folder(source, target)
|
|
591
|
+
else:
|
|
592
|
+
raise ValueError(f"'{source}' can not be copied because the path does not exist.")
|
|
593
|
+
return 0
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def PrintOSName() -> int:
|
|
597
|
+
if GeneralUtilities.current_system_is_windows():
|
|
598
|
+
GeneralUtilities.write_message_to_stdout("Windows")
|
|
599
|
+
elif GeneralUtilities.current_system_is_linux():
|
|
600
|
+
GeneralUtilities.write_message_to_stdout("Linux")
|
|
601
|
+
# TODO consider Mac, Unix, etc. too
|
|
602
|
+
else:
|
|
603
|
+
GeneralUtilities.write_message_to_stderr("Unknown OS.")
|
|
604
|
+
return 1
|
|
605
|
+
return 0
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
def PrintCurrecntWorkingDirectory() -> int:
|
|
609
|
+
GeneralUtilities.write_message_to_stdout(os.getcwd())
|
|
610
|
+
return 0
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
def ListFolderContent() -> int:
|
|
614
|
+
parser = argparse.ArgumentParser(description="This function lists folder-content.")
|
|
615
|
+
parser.add_argument('-p', '--path', required=True)
|
|
616
|
+
parser.add_argument('-f', '--excludefiles', action='store_true', required=False, default=False)
|
|
617
|
+
parser.add_argument('-d', '--excludedirectories', action='store_true', required=False, default=False)
|
|
618
|
+
parser.add_argument('-n', '--printonlynamewithoutpath', action='store_true', required=False, default=False)
|
|
619
|
+
# TODO add option to also list transitively list subfolder
|
|
620
|
+
# TODO add option to show only content which matches a filter by extension or regex or glob-pattern
|
|
621
|
+
args = parser.parse_args()
|
|
622
|
+
folder = args.path
|
|
623
|
+
if not os.path.isabs(folder):
|
|
624
|
+
folder = GeneralUtilities.resolve_relative_path(folder, os.getcwd())
|
|
625
|
+
content = []
|
|
626
|
+
if not args.excludefiles:
|
|
627
|
+
content = content+GeneralUtilities.get_direct_files_of_folder(folder)
|
|
628
|
+
if not args.excludedirectories:
|
|
629
|
+
content = content+GeneralUtilities.get_direct_folders_of_folder(folder)
|
|
630
|
+
for contentitem in content:
|
|
631
|
+
content_to_print: str = None
|
|
632
|
+
if args.printonlynamewithoutpath:
|
|
633
|
+
content_to_print = os.path.basename(contentitem)
|
|
634
|
+
else:
|
|
635
|
+
content_to_print = contentitem
|
|
636
|
+
GeneralUtilities.write_message_to_stdout(content_to_print)
|
|
637
|
+
return 0
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
def ForEach() -> int:
|
|
641
|
+
GeneralUtilities.write_message_to_stderr("This function is not implemented yet.")
|
|
642
|
+
# TODO implement function
|
|
643
|
+
return 1
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
def NpmI() -> int:
|
|
647
|
+
parser = argparse.ArgumentParser(description="Does \"npm clean install\".")
|
|
648
|
+
parser.add_argument('-d', '--directory', required=False, default=".")
|
|
649
|
+
parser.add_argument('-f', '--force', action='store_true', required=False, default=False)
|
|
650
|
+
parser.add_argument('-v', '--verbose', action='store_true', required=False, default=False)
|
|
651
|
+
parser.add_argument('-c', '--nocache', action='store_true', required=False, default=False)
|
|
652
|
+
args = parser.parse_args()
|
|
653
|
+
if os.path.isabs(args.directory):
|
|
654
|
+
folder = args.directory
|
|
655
|
+
else:
|
|
656
|
+
folder = GeneralUtilities.resolve_relative_path(args.directory, os.getcwd())
|
|
657
|
+
t = TFCPS_Tools_General(ScriptCollectionCore())
|
|
658
|
+
t.do_npm_install(folder, args.force,not args.nocache)
|
|
659
|
+
return 0
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
def CurrentUserHasElevatedPrivileges() -> int:
|
|
663
|
+
parser = argparse.ArgumentParser(description="Returns 1 if the current user has elevated privileges. Otherwise this function returns 0.")
|
|
664
|
+
parser.parse_args()
|
|
665
|
+
if GeneralUtilities.current_user_has_elevated_privileges():
|
|
666
|
+
return 1
|
|
667
|
+
else:
|
|
668
|
+
return 0
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
def Espoc() -> int:
|
|
672
|
+
parser = argparse.ArgumentParser(description="Espoc (appreviation for 'exit started programs on close') is a tool to ensure the started processes of your program will also get terminated when the execution of your program is finished.")
|
|
673
|
+
parser.add_argument('-p', '--processid', required=True)
|
|
674
|
+
parser.add_argument('-f', '--file', required=True, help='Specifies the file where the process-ids of the started processes are stored (line by line). This file will be deleted when all started processes are terminated.')
|
|
675
|
+
args = parser.parse_args()
|
|
676
|
+
process_id = int(args.processid)
|
|
677
|
+
process_list_file: str = args.file
|
|
678
|
+
if not os.path.isabs(process_list_file):
|
|
679
|
+
process_list_file = GeneralUtilities.resolve_relative_path(process_list_file, os.getcwd())
|
|
680
|
+
GeneralUtilities.assert_condition(GeneralUtilities.process_is_running_by_id(process_id), f"Process with id {process_id} is not running.")
|
|
681
|
+
while GeneralUtilities.process_is_running_by_id(process_id):
|
|
682
|
+
time.sleep(1)
|
|
683
|
+
GeneralUtilities.write_message_to_stdout(f"Process with id {process_id} is not running anymore. Start terminating remaining processes.")
|
|
684
|
+
if os.path.exists(process_list_file):
|
|
685
|
+
for line in GeneralUtilities.read_lines_from_file(process_list_file):
|
|
686
|
+
if GeneralUtilities.string_has_content(line):
|
|
687
|
+
current_process_id = int(line.strip())
|
|
688
|
+
GeneralUtilities.kill_process(current_process_id, True)
|
|
689
|
+
GeneralUtilities.ensure_file_does_not_exist(process_list_file)
|
|
690
|
+
GeneralUtilities.write_message_to_stdout("All started processes terminated.")
|
|
691
|
+
else:
|
|
692
|
+
GeneralUtilities.write_message_to_stdout(f"File '{process_list_file}' does not exist. No processes to terminate.")
|
|
693
|
+
return 0
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
def ConvertGitRepositoryToBareRepository() -> int:
|
|
697
|
+
parser = argparse.ArgumentParser(description="Converts a local git-repository to a bare repository.")
|
|
698
|
+
parser.add_argument('-f', '--folder', required=True, help='Git-repository-folder which should be converted.')
|
|
699
|
+
args = parser.parse_args()
|
|
700
|
+
sc = ScriptCollectionCore()
|
|
701
|
+
sc.convert_git_repository_to_bare_repository(args.folder)
|
|
702
|
+
return 0
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
def OCRAnalysisOfFolder() -> int:
|
|
706
|
+
parser = argparse.ArgumentParser()
|
|
707
|
+
parser.add_argument('-s', '--serviceaddress', required=False, default=None)
|
|
708
|
+
parser.add_argument('-e', '--extensions', required=False, default=None)
|
|
709
|
+
parser.add_argument('-l', '--languages', required=False, default="en")
|
|
710
|
+
parser.add_argument('-f', '--folder', required=False, default=None)
|
|
711
|
+
args = parser.parse_args()
|
|
712
|
+
sc = ScriptCollectionCore()
|
|
713
|
+
if args.folder is None:
|
|
714
|
+
args.folder = os.getcwd()
|
|
715
|
+
extensions_value: str = None
|
|
716
|
+
if args.extensions is not None:
|
|
717
|
+
if "," in args.extensions:
|
|
718
|
+
extensions_value = args.extensions.split(",")
|
|
719
|
+
else:
|
|
720
|
+
extensions_value = [args.extensions]
|
|
721
|
+
sc.ocr_analysis_of_folder(args.folder, args.serviceaddress, extensions_value, args.languages)
|
|
722
|
+
return 0
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
def OCRAnalysisOfFile() -> int:
|
|
726
|
+
parser = argparse.ArgumentParser()
|
|
727
|
+
parser.add_argument('-s', '--serviceaddress', required=False, default=None)
|
|
728
|
+
parser.add_argument('-l', '--languages', required=False, default="en")
|
|
729
|
+
parser.add_argument('-f', '--file', required=True)
|
|
730
|
+
args = parser.parse_args()
|
|
731
|
+
sc = ScriptCollectionCore()
|
|
732
|
+
sc.ocr_analysis_of_file(args.file, args.serviceaddress, args.languages)
|
|
733
|
+
return 0
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
def OCRAnalysisOfRepository() -> int:
|
|
737
|
+
parser = argparse.ArgumentParser()
|
|
738
|
+
parser.add_argument('-s', '--serviceaddress', required=False, default=None)
|
|
739
|
+
parser.add_argument('-e', '--extensions', required=False, default=None)
|
|
740
|
+
parser.add_argument('-l', '--languages', required=False, default="en")
|
|
741
|
+
parser.add_argument('-f', '--folder', required=False, default=None)
|
|
742
|
+
args = parser.parse_args()
|
|
743
|
+
sc = ScriptCollectionCore()
|
|
744
|
+
if args.folder is None:
|
|
745
|
+
args.folder = os.getcwd()
|
|
746
|
+
extensions_value: str = None
|
|
747
|
+
if args.extensions is not None:
|
|
748
|
+
if "," in args.extensions:
|
|
749
|
+
extensions_value = args.extensions.split(",")
|
|
750
|
+
else:
|
|
751
|
+
extensions_value = [args.extensions]
|
|
752
|
+
sc.ocr_analysis_of_repository(args.folder, args.serviceaddress, extensions_value, args.languages)
|
|
753
|
+
return 0
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
def UpdateImagesInDockerComposeFile() -> int:
|
|
757
|
+
iu: ImageUpdater = ImageUpdater()
|
|
758
|
+
parser = argparse.ArgumentParser()
|
|
759
|
+
parser.add_argument('-f', '--file', required=False, default=None)
|
|
760
|
+
parser.add_argument('-v', '--versionecholon', required=False, default=VersionEcholon.LatestVersion.name, dest="Possible values are: " + ", ".join([e.name for e in VersionEcholon]))
|
|
761
|
+
parser.add_argument("-s", "--servicename", required=True, default=None)
|
|
762
|
+
parser.add_argument("-u", "--updatertype", required=True, default=None)
|
|
763
|
+
args = parser.parse_args()
|
|
764
|
+
if args.file is None:
|
|
765
|
+
args.file = os.path.join(os.getcwd(), "docker-compose.yml")
|
|
766
|
+
versionecholonTyped = VersionEcholon[args.versionecholon]
|
|
767
|
+
iu.update_services_in_docker_compose_file(args.file, [args.servicename], versionecholonTyped, args.updatertype)
|
|
768
|
+
return 0
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
def SetFileContent() -> int:
|
|
772
|
+
parser = argparse.ArgumentParser(description="This function writes content into a file.")
|
|
773
|
+
parser.add_argument('-p', '--path', required=True)
|
|
774
|
+
parser.add_argument('-b', '--argumentisinbase64', action='store_true', required=False, default=False)
|
|
775
|
+
parser.add_argument('-c', '--content', required=True)
|
|
776
|
+
parser.add_argument('-e', '--encoding', required=False, default="utf-8")
|
|
777
|
+
args = parser.parse_args()
|
|
778
|
+
sc = ScriptCollectionCore()
|
|
779
|
+
content = args.content
|
|
780
|
+
if args.argumentisinbase64:
|
|
781
|
+
base64_string: str = args.content
|
|
782
|
+
base64_bytes = base64_string.encode('utf-8')
|
|
783
|
+
original_bytes = base64.b64decode(base64_bytes)
|
|
784
|
+
content = original_bytes.decode('utf-8')
|
|
785
|
+
sc.set_file_content(args.path, content, args.encoding)
|
|
786
|
+
return 0
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
def GenerateTaskfileFromWorkspacefile() -> int:
|
|
790
|
+
parser = argparse.ArgumentParser(description="Generates a taskfile.yml-file from a .code-workspace-file")
|
|
791
|
+
parser.add_argument('-f', '--repositoryfolder', required=True)
|
|
792
|
+
#args = parser.parse_args()
|
|
793
|
+
#t = TasksForCommonProjectStructure()
|
|
794
|
+
#t.generate_tasksfile_from_workspace_file(args.repositoryfolder)
|
|
795
|
+
#return 0
|
|
796
|
+
return 1#TODO
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
def UpdateTimestampInFile() -> int:
|
|
800
|
+
parser = argparse.ArgumentParser(description="Update the timestamp in a comment in a file")
|
|
801
|
+
parser.add_argument('-f', '--file', required=True)
|
|
802
|
+
args = parser.parse_args()
|
|
803
|
+
sc = ScriptCollectionCore()
|
|
804
|
+
sc.update_timestamp_in_file(args.file)
|
|
805
|
+
return 0
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
def LOC() -> int:
|
|
809
|
+
sc = ScriptCollectionCore()
|
|
810
|
+
default_patterns: list[str] = sc.default_excluded_patterns_for_loc
|
|
811
|
+
default_patterns_joined = ",".join(default_patterns)
|
|
812
|
+
parser = argparse.ArgumentParser(description=f"Counts the lines of code in a git-repository. Default patterns are: {default_patterns_joined}")
|
|
813
|
+
parser.add_argument('-r', '--repository', required=True)
|
|
814
|
+
parser.add_argument('-e', '--excluded_pattern', nargs='+')
|
|
815
|
+
parser.add_argument('-d', '--do_not_add_default_pattern', action='store_true', default=False)
|
|
816
|
+
parser.add_argument('-v', '--verbose', action='store_true', default=False)
|
|
817
|
+
args = parser.parse_args()
|
|
818
|
+
|
|
819
|
+
folder: str = None
|
|
820
|
+
if os.path.isabs(args.repository):
|
|
821
|
+
folder = args.repository
|
|
822
|
+
else:
|
|
823
|
+
folder = GeneralUtilities.resolve_relative_path(args.repository, os.getcwd())
|
|
824
|
+
excluded_patterns: list[str] = []
|
|
825
|
+
|
|
826
|
+
if not args.do_not_add_default_pattern:
|
|
827
|
+
excluded_patterns = excluded_patterns + sc.default_excluded_patterns_for_loc
|
|
828
|
+
if args.excluded_pattern is not None:
|
|
829
|
+
excluded_patterns = excluded_patterns + args.excluded_pattern
|
|
830
|
+
|
|
831
|
+
if args.verbose:
|
|
832
|
+
sc.log.loglevel=LogLevel.Debug
|
|
833
|
+
else:
|
|
834
|
+
sc.log.loglevel=LogLevel.Information
|
|
835
|
+
|
|
836
|
+
GeneralUtilities.write_message_to_stdout(str(sc.get_lines_of_code(folder, excluded_patterns)))
|
|
837
|
+
return 0
|
|
838
|
+
|
|
839
|
+
def CreateRelease()->int:
|
|
840
|
+
sc = ScriptCollectionCore()
|
|
841
|
+
parser = argparse.ArgumentParser(description="Creates a release in a git-repository which uses the anion-build-platform.")
|
|
842
|
+
parser.add_argument('-b', '--buildrepository', required=False, default=".")
|
|
843
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
|
844
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
|
845
|
+
parser.add_argument('-s', '--sourcebranch', required=False, default="other/next-release")
|
|
846
|
+
parser.add_argument('-u', '--updatedependencies', required=False, action='store_true', default=False)
|
|
847
|
+
args = parser.parse_args()
|
|
848
|
+
|
|
849
|
+
build_repo_folder: str = None
|
|
850
|
+
if os.path.isabs(args.buildrepository):
|
|
851
|
+
build_repo_folder = args.buildrepository
|
|
852
|
+
else:
|
|
853
|
+
build_repo_folder = GeneralUtilities.resolve_relative_path(args.buildrepository, os.getcwd())
|
|
854
|
+
|
|
855
|
+
verbosity=int(args.verbosity)
|
|
856
|
+
sc.log.loglevel=LogLevel(verbosity)
|
|
857
|
+
|
|
858
|
+
scripts_folder:str=os.path.join(build_repo_folder,"Scripts","CreateRelease")
|
|
859
|
+
arguments=f"CreateRelease.py --buildrepositoriesfolder {build_repo_folder} --verbosity {verbosity} --sourcebranch {args.sourcebranch}"
|
|
860
|
+
if args.updatedependencies:
|
|
861
|
+
arguments=arguments+" --updatedependencies"
|
|
862
|
+
sc.run_program("python", arguments, scripts_folder,print_live_output=True)
|
|
863
|
+
|
|
864
|
+
return 0
|
|
865
|
+
|
|
866
|
+
def CleanToolsCache()->int:
|
|
867
|
+
GeneralUtilities.ensure_folder_exists_and_is_empty(TFCPS_Tools_General(ScriptCollectionCore()).get_global_cache_folder())
|
|
371
868
|
return 0
|