torizon-templates-utils 0.0.7__py3-none-any.whl → 0.0.9__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.
- torizon_templates_utils/errors.py +5 -1
- torizon_templates_utils/network.py +1 -1
- torizon_templates_utils/tasks.py +30 -16
- {torizon_templates_utils-0.0.7.dist-info → torizon_templates_utils-0.0.9.dist-info}/METADATA +1 -1
- torizon_templates_utils-0.0.9.dist-info/RECORD +13 -0
- {torizon_templates_utils-0.0.7.dist-info → torizon_templates_utils-0.0.9.dist-info}/WHEEL +1 -1
- torizon_templates_utils-0.0.7.dist-info/RECORD +0 -13
- {torizon_templates_utils-0.0.7.dist-info → torizon_templates_utils-0.0.9.dist-info}/LICENSE +0 -0
- {torizon_templates_utils-0.0.7.dist-info → torizon_templates_utils-0.0.9.dist-info}/top_level.txt +0 -0
|
@@ -11,7 +11,8 @@ class _error_struct:
|
|
|
11
11
|
self.code = code
|
|
12
12
|
self.message = message
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
# Standard Unix errors. There may be other standard error codes also:
|
|
15
|
+
# https://github.com/kaushalparikh/nuttx/blob/master/include/errno.h
|
|
15
16
|
class Error(Enum):
|
|
16
17
|
ENOCONF = _error_struct(
|
|
17
18
|
1, "Not configured"
|
|
@@ -28,6 +29,9 @@ class Error(Enum):
|
|
|
28
29
|
EABORT = _error_struct(
|
|
29
30
|
170, "Abort"
|
|
30
31
|
)
|
|
32
|
+
ETASKEXEC = _error_struct(
|
|
33
|
+
310, "Task execution error"
|
|
34
|
+
)
|
|
31
35
|
ENOFOUND = _error_struct(
|
|
32
36
|
404, "Not found"
|
|
33
37
|
)
|
|
@@ -5,7 +5,7 @@ import subprocess
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def get_host_ip():
|
|
8
|
-
if 'WSL_DISTRO_NAME' in os.environ:
|
|
8
|
+
if 'WSL_DISTRO_NAME' in os.environ and os.environ['WSL_DISTRO_NAME'] != '':
|
|
9
9
|
command = ["/mnt/c/Windows/System32/Wbem/WMIC.exe", "NICCONFIG", "WHERE", "IPEnabled=true", "GET", "IPAddress"]
|
|
10
10
|
|
|
11
11
|
# if inside a container we need to run the command in the host
|
torizon_templates_utils/tasks.py
CHANGED
|
@@ -428,7 +428,7 @@ class TaskRunner:
|
|
|
428
428
|
self.__settings = settings
|
|
429
429
|
self.__debug = debug
|
|
430
430
|
self.__gitlab_ci = False
|
|
431
|
-
self.__override_env =
|
|
431
|
+
self.__override_env = False
|
|
432
432
|
self.__cli_inputs: Dict[str, str] = {}
|
|
433
433
|
self.__can_receive_interactive_input = False
|
|
434
434
|
|
|
@@ -444,7 +444,7 @@ class TaskRunner:
|
|
|
444
444
|
self.__gitlab_ci = True
|
|
445
445
|
|
|
446
446
|
if "TASKS_OVERRIDE_ENV" in os.environ:
|
|
447
|
-
self.__override_env =
|
|
447
|
+
self.__override_env = True
|
|
448
448
|
|
|
449
449
|
if "TASKS_DEBUG" in os.environ:
|
|
450
450
|
self.__debug = True
|
|
@@ -563,20 +563,31 @@ class TaskRunner:
|
|
|
563
563
|
os.environ["config:tcb_packageName"]
|
|
564
564
|
],
|
|
565
565
|
capture_output=True,
|
|
566
|
-
text=True
|
|
566
|
+
text=True,
|
|
567
|
+
env=os.environ
|
|
567
568
|
)
|
|
568
569
|
|
|
569
570
|
if _p_ret.returncode != 0:
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
571
|
+
# Sometimes the error is presented on stdout and not stderr
|
|
572
|
+
raise RuntimeError(f"Error running torizon-io.xsh: {_p_ret}")
|
|
573
|
+
|
|
574
|
+
# TODO: Maybe not use this and instead disable colors on the terminal
|
|
575
|
+
# Remove ANSI escape sequences. Regex from this thread:
|
|
576
|
+
# https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python
|
|
577
|
+
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
578
|
+
_latest_ver = ansi_escape.sub('', _p_ret.stdout.strip())
|
|
579
|
+
|
|
580
|
+
_latest_ver_number = _latest_ver.rsplit('-', 1)[-1]
|
|
581
|
+
_latest_ver_last_number = _latest_ver_number.rsplit('.', 1)[-1]
|
|
582
|
+
try:
|
|
583
|
+
_next = int(_latest_ver_last_number) +1
|
|
584
|
+
except:
|
|
585
|
+
raise ValueError(f"Package version should be in one of the following formats: <int>, <string-int>, <major.minor.patch>, or <string-major.minor.patch>. Depending on format, int or patch value will be incremented")
|
|
573
586
|
|
|
574
587
|
if self.__debug:
|
|
575
588
|
print(f"Next package version: {_next}")
|
|
576
589
|
|
|
577
|
-
|
|
578
|
-
value.replace("${{command:tcb.getNextPackageVersion}}", f"{_next}")
|
|
579
|
-
)
|
|
590
|
+
value = value.replace(f"${{command:tcb.getNextPackageVersion}}", f"{_next}")
|
|
580
591
|
|
|
581
592
|
elif "tcb.outputTEZIFolder" in value:
|
|
582
593
|
# load the tcbuild.yaml
|
|
@@ -589,7 +600,7 @@ class TaskRunner:
|
|
|
589
600
|
except KeyError:
|
|
590
601
|
raise RuntimeError("Error replacing variable tcb.outputTEZIFolder, make sure the tcbuild.yaml has the output.easy-installer.local property")
|
|
591
602
|
|
|
592
|
-
value = value.replace("${{command:tcb.outputTEZIFolder}}", _tezi_folder)
|
|
603
|
+
value = value.replace(f"${{command:tcb.outputTEZIFolder}}", _tezi_folder)
|
|
593
604
|
|
|
594
605
|
# for all the items we need to replace ${command:tcb. with ${config:tcb.
|
|
595
606
|
_pattern = r"(?<=\$\{command:tcb\.).*?(?=\s*})"
|
|
@@ -887,14 +898,14 @@ class TaskRunner:
|
|
|
887
898
|
if _env is not None:
|
|
888
899
|
for env, value in _env.items():
|
|
889
900
|
if self.__override_env:
|
|
890
|
-
__env = self.__parse_envs(env, _task)
|
|
891
|
-
if __env:
|
|
892
|
-
os.environ[env] = __env
|
|
893
|
-
else:
|
|
894
901
|
if env not in os.environ:
|
|
895
902
|
__env = self.__parse_envs(env, _task)
|
|
896
903
|
if __env:
|
|
897
904
|
os.environ[env] = __env
|
|
905
|
+
else:
|
|
906
|
+
__env = self.__parse_envs(env, _task)
|
|
907
|
+
if __env:
|
|
908
|
+
os.environ[env] = __env
|
|
898
909
|
|
|
899
910
|
# we need to change the cwd if it's set
|
|
900
911
|
if _cwd is not None:
|
|
@@ -913,12 +924,16 @@ class TaskRunner:
|
|
|
913
924
|
print(f"Parsed Args: {_args}", color=Color.YELLOW)
|
|
914
925
|
print(f"Parsed Command: {_cmd_join}", color=Color.YELLOW)
|
|
915
926
|
|
|
927
|
+
# use bash to execute the VSCode tasks commands and scripts, as they
|
|
928
|
+
# are written and tested in bash. Valid just for commands of shell
|
|
929
|
+
# type, not process type ones
|
|
916
930
|
_ret = subprocess.run(
|
|
917
931
|
[_cmd, *_args] if not _shell else _cmd_join,
|
|
918
932
|
stdout=None,
|
|
919
933
|
stderr=None,
|
|
920
934
|
env=os.environ,
|
|
921
|
-
shell=_shell
|
|
935
|
+
shell=_shell,
|
|
936
|
+
executable="/bin/bash" if _shell else None
|
|
922
937
|
)
|
|
923
938
|
|
|
924
939
|
# go back to the last cwd
|
|
@@ -927,4 +942,3 @@ class TaskRunner:
|
|
|
927
942
|
if _ret.returncode != 0:
|
|
928
943
|
print(f"> TASK [{label}] exited with error code [{_ret.returncode}] <", color=Color.RED)
|
|
929
944
|
raise RuntimeError(f"Error running task: {label}")
|
|
930
|
-
|
{torizon_templates_utils-0.0.7.dist-info → torizon_templates_utils-0.0.9.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: torizon_templates_utils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.9
|
|
4
4
|
Summary: Package with utilities for Torizon Templates scripts
|
|
5
5
|
Author-email: Matheus Castello <matheus.castello@toradex.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/torizon/vscode-torizon-templates
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
torizon_templates_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
torizon_templates_utils/animations.py,sha256=RrySPMhlrE6f40BBeLvHEHJPOwOnIsv3rHWNt636lro,1671
|
|
3
|
+
torizon_templates_utils/args.py,sha256=nN1b9Ts2lEYbpAGzaMWpAcmcYIrTUFJHehM_UqvnCWA,2142
|
|
4
|
+
torizon_templates_utils/colors.py,sha256=Y1FZ0HtKvXfLGYTDclsXubtZCQ-epuch5Dgk1DJdjps,1143
|
|
5
|
+
torizon_templates_utils/debug.py,sha256=OfdKSdN1kypuJnV_WcPa9bvonjyDvXvA3QTmc1iKyjw,556
|
|
6
|
+
torizon_templates_utils/errors.py,sha256=Wkk0AeCx0KQW-Qlu_5A6GYaGUkaJU79Mok8lZuZKHjM,1425
|
|
7
|
+
torizon_templates_utils/network.py,sha256=zAy2NVspy_VItGeyPKCBqhd7rsQV0Jv-vJurUOfcXyI,1330
|
|
8
|
+
torizon_templates_utils/tasks.py,sha256=elJcgLghGDMcwgOoaGRoI4N0gy5-vFkJmKcJbvcuK7A,32444
|
|
9
|
+
torizon_templates_utils-0.0.9.dist-info/LICENSE,sha256=9sElQO1hY3ElhihFD_PlS5hXMIuSelsJZpIfjNpxBlQ,1099
|
|
10
|
+
torizon_templates_utils-0.0.9.dist-info/METADATA,sha256=etzYySwO6WIOULO8HBJQMGNCYVh-ZizBf5znI-AQyT8,968
|
|
11
|
+
torizon_templates_utils-0.0.9.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
|
12
|
+
torizon_templates_utils-0.0.9.dist-info/top_level.txt,sha256=qlOkS1ASF5C-kSfpbiWbVHJFgmQ0RN6iunmLArNt6zc,24
|
|
13
|
+
torizon_templates_utils-0.0.9.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
torizon_templates_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
torizon_templates_utils/animations.py,sha256=RrySPMhlrE6f40BBeLvHEHJPOwOnIsv3rHWNt636lro,1671
|
|
3
|
-
torizon_templates_utils/args.py,sha256=nN1b9Ts2lEYbpAGzaMWpAcmcYIrTUFJHehM_UqvnCWA,2142
|
|
4
|
-
torizon_templates_utils/colors.py,sha256=Y1FZ0HtKvXfLGYTDclsXubtZCQ-epuch5Dgk1DJdjps,1143
|
|
5
|
-
torizon_templates_utils/debug.py,sha256=OfdKSdN1kypuJnV_WcPa9bvonjyDvXvA3QTmc1iKyjw,556
|
|
6
|
-
torizon_templates_utils/errors.py,sha256=rvQjWPkwmOQE56vFywq1yQiiRcl-AL7LRVlpyoYDXvc,1214
|
|
7
|
-
torizon_templates_utils/network.py,sha256=-Bj0GEFNf6Zx5hCqTzCpk4HnxuJIvOqS1_P6vrTPowc,1290
|
|
8
|
-
torizon_templates_utils/tasks.py,sha256=qBszFzfR1umUWgkZvSB_hrORTS2yuByX__ImMWDtkho,31213
|
|
9
|
-
torizon_templates_utils-0.0.7.dist-info/LICENSE,sha256=9sElQO1hY3ElhihFD_PlS5hXMIuSelsJZpIfjNpxBlQ,1099
|
|
10
|
-
torizon_templates_utils-0.0.7.dist-info/METADATA,sha256=FFwNtaqD5vjbPBc-SP1wDF51AK0k65V9zzfThdMfDVc,968
|
|
11
|
-
torizon_templates_utils-0.0.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
12
|
-
torizon_templates_utils-0.0.7.dist-info/top_level.txt,sha256=qlOkS1ASF5C-kSfpbiWbVHJFgmQ0RN6iunmLArNt6zc,24
|
|
13
|
-
torizon_templates_utils-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
{torizon_templates_utils-0.0.7.dist-info → torizon_templates_utils-0.0.9.dist-info}/top_level.txt
RENAMED
|
File without changes
|