torizon-templates-utils 0.0.9__tar.gz → 0.0.10__tar.gz
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-0.0.9 → torizon_templates_utils-0.0.10}/PKG-INFO +4 -4
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/pyproject.toml +8 -4
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/network.py +2 -2
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/tasks.py +37 -40
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils.egg-info/PKG-INFO +4 -4
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils.egg-info/SOURCES.txt +0 -1
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils.egg-info/requires.txt +1 -0
- torizon_templates_utils-0.0.9/LICENSE +0 -23
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/README.md +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/setup.cfg +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/__init__.py +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/animations.py +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/args.py +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/colors.py +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/debug.py +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/errors.py +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils.egg-info/dependency_links.txt +0 -0
- {torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: torizon_templates_utils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.10
|
|
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
|
|
@@ -8,13 +8,13 @@ Project-URL: Issues, https://github.com/torizon/vscode-torizon-templates/issues
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
13
|
Requires-Dist: torizon-io-api
|
|
15
14
|
Requires-Dist: requests
|
|
16
15
|
Requires-Dist: pyyaml
|
|
17
16
|
Requires-Dist: debugpy
|
|
17
|
+
Requires-Dist: pkginfo>=1.12
|
|
18
18
|
|
|
19
19
|
# Torizon Templates Utils
|
|
20
20
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=70.0", "pkginfo>=1.12"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "torizon_templates_utils"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.10"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Matheus Castello", email="matheus.castello@toradex.com" },
|
|
10
10
|
]
|
|
11
11
|
description = "Package with utilities for Torizon Templates scripts"
|
|
12
12
|
readme = "README.md"
|
|
13
|
-
requires-python = ">=3.
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Programming Language :: Python :: 3",
|
|
16
16
|
"License :: OSI Approved :: MIT License",
|
|
@@ -20,9 +20,13 @@ dependencies = [
|
|
|
20
20
|
"torizon-io-api",
|
|
21
21
|
"requests",
|
|
22
22
|
"pyyaml",
|
|
23
|
-
"debugpy"
|
|
23
|
+
"debugpy",
|
|
24
|
+
"pkginfo>=1.12"
|
|
24
25
|
]
|
|
25
26
|
|
|
27
|
+
[tool.setuptools]
|
|
28
|
+
license-files = []
|
|
29
|
+
|
|
26
30
|
[project.urls]
|
|
27
31
|
Homepage = "https://github.com/torizon/vscode-torizon-templates"
|
|
28
32
|
Issues = "https://github.com/torizon/vscode-torizon-templates/issues"
|
{torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/network.py
RENAMED
|
@@ -6,14 +6,14 @@ import subprocess
|
|
|
6
6
|
|
|
7
7
|
def get_host_ip():
|
|
8
8
|
if 'WSL_DISTRO_NAME' in os.environ and os.environ['WSL_DISTRO_NAME'] != '':
|
|
9
|
-
command = ["/mnt/c/Windows/System32/
|
|
9
|
+
command = ["/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe", "-c", '(Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias (Get-NetRoute -DestinationPrefix "0.0.0.0/0").InterfaceAlias).IPAddress']
|
|
10
10
|
|
|
11
11
|
# if inside a container we need to run the command in the host
|
|
12
12
|
if "APOLLOX_CONTAINER" in os.environ:
|
|
13
13
|
command = [
|
|
14
14
|
"sudo", "nsenter", "-t", "1", "-m", "-u", "-n", "-i",
|
|
15
15
|
"--",
|
|
16
|
-
"/mnt/c/Windows/System32/
|
|
16
|
+
"/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe", "-c", '(Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias (Get-NetRoute -DestinationPrefix "0.0.0.0/0").InterfaceAlias).IPAddress'
|
|
17
17
|
]
|
|
18
18
|
|
|
19
19
|
result = subprocess.run(command, capture_output=True, text=True)
|
{torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/tasks.py
RENAMED
|
@@ -14,7 +14,7 @@ T = TypeVar('T')
|
|
|
14
14
|
|
|
15
15
|
def replace_tasks_input():
|
|
16
16
|
for file in Path('.').rglob('*.json'):
|
|
17
|
-
print(file)
|
|
17
|
+
print(file, flush=True)
|
|
18
18
|
mime_type, _ = mimetypes.guess_type(file)
|
|
19
19
|
|
|
20
20
|
if mime_type is None or mime_type.startswith("application/octet-stream"):
|
|
@@ -428,12 +428,12 @@ class TaskRunner:
|
|
|
428
428
|
self.__settings = settings
|
|
429
429
|
self.__debug = debug
|
|
430
430
|
self.__gitlab_ci = False
|
|
431
|
-
self.
|
|
431
|
+
self.__tasks_override_env = False
|
|
432
432
|
self.__cli_inputs: Dict[str, str] = {}
|
|
433
433
|
self.__can_receive_interactive_input = False
|
|
434
434
|
|
|
435
435
|
# check if we have stdin
|
|
436
|
-
if os.isatty(0) and ("TASKS_DISABLE_INTERACTIVE_INPUT" not in os.environ):
|
|
436
|
+
if os.isatty(0) and (("TASKS_DISABLE_INTERACTIVE_INPUT" not in os.environ) or (os.environ["TASKS_DISABLE_INTERACTIVE_INPUT"] != "True")):
|
|
437
437
|
self.__can_receive_interactive_input = True
|
|
438
438
|
|
|
439
439
|
# environment configs
|
|
@@ -443,10 +443,10 @@ class TaskRunner:
|
|
|
443
443
|
if "GITLAB_CI" in os.environ:
|
|
444
444
|
self.__gitlab_ci = True
|
|
445
445
|
|
|
446
|
-
if "TASKS_OVERRIDE_ENV" in os.environ:
|
|
447
|
-
self.
|
|
446
|
+
if "TASKS_OVERRIDE_ENV" in os.environ and os.environ["TASKS_OVERRIDE_ENV"] == "True":
|
|
447
|
+
self.__tasks_override_env = True
|
|
448
448
|
|
|
449
|
-
if "TASKS_DEBUG" in os.environ:
|
|
449
|
+
if "TASKS_DEBUG" in os.environ and os.environ["TASKS_DEBUG"] == "True":
|
|
450
450
|
self.__debug = True
|
|
451
451
|
|
|
452
452
|
self.__settings_to_env()
|
|
@@ -473,10 +473,10 @@ class TaskRunner:
|
|
|
473
473
|
for task in self.__tasks:
|
|
474
474
|
if no_index:
|
|
475
475
|
if show_hidden or not task.hide:
|
|
476
|
-
print(task.label)
|
|
476
|
+
print(task.label, flush=True)
|
|
477
477
|
else:
|
|
478
478
|
if show_hidden or not task.hide:
|
|
479
|
-
print(f"{i}. \t{task.label}")
|
|
479
|
+
print(f"{i}. \t{task.label}", flush=True)
|
|
480
480
|
|
|
481
481
|
i += 1
|
|
482
482
|
|
|
@@ -503,7 +503,7 @@ class TaskRunner:
|
|
|
503
503
|
|
|
504
504
|
if task is not None:
|
|
505
505
|
task_txt = json.dumps(task.to_dict(), indent=4)
|
|
506
|
-
print(task_txt)
|
|
506
|
+
print(task_txt, flush=True)
|
|
507
507
|
else:
|
|
508
508
|
raise ReferenceError(f"Task with index [{label}] not found")
|
|
509
509
|
|
|
@@ -558,7 +558,7 @@ class TaskRunner:
|
|
|
558
558
|
_p_ret = subprocess.run(
|
|
559
559
|
[
|
|
560
560
|
"xonsh",
|
|
561
|
-
"
|
|
561
|
+
"./.conf/torizon-io.xsh",
|
|
562
562
|
"package", "latest", "version",
|
|
563
563
|
os.environ["config:tcb_packageName"]
|
|
564
564
|
],
|
|
@@ -585,7 +585,7 @@ class TaskRunner:
|
|
|
585
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")
|
|
586
586
|
|
|
587
587
|
if self.__debug:
|
|
588
|
-
print(f"Next package version: {_next}")
|
|
588
|
+
print(f"Next package version: {_next}", flush=True)
|
|
589
589
|
|
|
590
590
|
value = value.replace(f"${{command:tcb.getNextPackageVersion}}", f"{_next}")
|
|
591
591
|
|
|
@@ -797,8 +797,8 @@ class TaskRunner:
|
|
|
797
797
|
exp_value_str = " ".join(expvalue)
|
|
798
798
|
|
|
799
799
|
if self.__debug:
|
|
800
|
-
print(f"Env: {env}={_env_value}", color=Color.YELLOW)
|
|
801
|
-
print(f"Parsed Env: {env}={exp_value_str}", color=Color.YELLOW)
|
|
800
|
+
print(f"Env: {env}={_env_value}", color=Color.YELLOW, flush=True)
|
|
801
|
+
print(f"Parsed Env: {env}={exp_value_str}", color=Color.YELLOW, flush=True)
|
|
802
802
|
|
|
803
803
|
return exp_value_str
|
|
804
804
|
|
|
@@ -835,6 +835,16 @@ class TaskRunner:
|
|
|
835
835
|
if _task is None:
|
|
836
836
|
raise ReferenceError(f"Task with label [{label}] not found")
|
|
837
837
|
|
|
838
|
+
_depends = []
|
|
839
|
+
if _task.dependsOn is not None:
|
|
840
|
+
_depends = _task.dependsOn
|
|
841
|
+
|
|
842
|
+
# first we need to run the dependencies
|
|
843
|
+
for dep in _depends:
|
|
844
|
+
self.run_task(dep)
|
|
845
|
+
|
|
846
|
+
print(f"> Executing task: {label} <", color=Color.GREEN, flush=True)
|
|
847
|
+
|
|
838
848
|
# prepare the command
|
|
839
849
|
_cmd = _task.command
|
|
840
850
|
|
|
@@ -858,16 +868,6 @@ class TaskRunner:
|
|
|
858
868
|
_env = _task.options.env
|
|
859
869
|
_cwd = _task.options.cwd
|
|
860
870
|
|
|
861
|
-
_depends = []
|
|
862
|
-
if _task.dependsOn is not None:
|
|
863
|
-
_depends = _task.dependsOn
|
|
864
|
-
|
|
865
|
-
# first we need to run the dependencies
|
|
866
|
-
for dep in _depends:
|
|
867
|
-
self.run_task(dep)
|
|
868
|
-
|
|
869
|
-
print(f"> Executing task: {label} <", color=Color.GREEN)
|
|
870
|
-
|
|
871
871
|
_is_background = ""
|
|
872
872
|
if _task.isBackground:
|
|
873
873
|
_is_background = " &"
|
|
@@ -894,18 +894,15 @@ class TaskRunner:
|
|
|
894
894
|
if self.__gitlab_ci:
|
|
895
895
|
_cmd = self.__replace_docker_host(_cmd)
|
|
896
896
|
|
|
897
|
-
|
|
897
|
+
task_env = os.environ.copy()
|
|
898
|
+
# If TASKS_OVERRIDE_ENV is true, override the env vars with the
|
|
899
|
+
# env var values present on the task. If false, set just the env vars
|
|
900
|
+
# present on the task that doesn't already exist on the env var
|
|
898
901
|
if _env is not None:
|
|
899
|
-
for env,
|
|
900
|
-
if self.
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
if __env:
|
|
904
|
-
os.environ[env] = __env
|
|
905
|
-
else:
|
|
906
|
-
__env = self.__parse_envs(env, _task)
|
|
907
|
-
if __env:
|
|
908
|
-
os.environ[env] = __env
|
|
902
|
+
for env, _ in _env.items():
|
|
903
|
+
if self.__tasks_override_env == True or env not in os.environ:
|
|
904
|
+
__parsed_env_value = self.__parse_envs(env, _task)
|
|
905
|
+
task_env[env] = __parsed_env_value
|
|
909
906
|
|
|
910
907
|
# we need to change the cwd if it's set
|
|
911
908
|
if _cwd is not None:
|
|
@@ -919,10 +916,10 @@ class TaskRunner:
|
|
|
919
916
|
_cmd_join = f"{_cmd} {' '.join(_args)}{_is_background}"
|
|
920
917
|
|
|
921
918
|
if self.__debug:
|
|
922
|
-
print(f"Command: {_task.command}", color=Color.YELLOW)
|
|
923
|
-
print(f"Args: {_task.args}", color=Color.YELLOW)
|
|
924
|
-
print(f"Parsed Args: {_args}", color=Color.YELLOW)
|
|
925
|
-
print(f"Parsed Command: {_cmd_join}", color=Color.YELLOW)
|
|
919
|
+
print(f"Command: {_task.command}", color=Color.YELLOW, flush=True)
|
|
920
|
+
print(f"Args: {_task.args}", color=Color.YELLOW, flush=True)
|
|
921
|
+
print(f"Parsed Args: {_args}", color=Color.YELLOW, flush=True)
|
|
922
|
+
print(f"Parsed Command: {_cmd_join}", color=Color.YELLOW, flush=True)
|
|
926
923
|
|
|
927
924
|
# use bash to execute the VSCode tasks commands and scripts, as they
|
|
928
925
|
# are written and tested in bash. Valid just for commands of shell
|
|
@@ -931,7 +928,7 @@ class TaskRunner:
|
|
|
931
928
|
[_cmd, *_args] if not _shell else _cmd_join,
|
|
932
929
|
stdout=None,
|
|
933
930
|
stderr=None,
|
|
934
|
-
env=
|
|
931
|
+
env=task_env,
|
|
935
932
|
shell=_shell,
|
|
936
933
|
executable="/bin/bash" if _shell else None
|
|
937
934
|
)
|
|
@@ -940,5 +937,5 @@ class TaskRunner:
|
|
|
940
937
|
os.chdir(_last_cwd)
|
|
941
938
|
|
|
942
939
|
if _ret.returncode != 0:
|
|
943
|
-
print(f"> TASK [{label}] exited with error code [{_ret.returncode}] <", color=Color.RED)
|
|
940
|
+
print(f"> TASK [{label}] exited with error code [{_ret.returncode}] <", color=Color.RED, flush=True)
|
|
944
941
|
raise RuntimeError(f"Error running task: {label}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: torizon_templates_utils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.10
|
|
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
|
|
@@ -8,13 +8,13 @@ Project-URL: Issues, https://github.com/torizon/vscode-torizon-templates/issues
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
13
|
Requires-Dist: torizon-io-api
|
|
15
14
|
Requires-Dist: requests
|
|
16
15
|
Requires-Dist: pyyaml
|
|
17
16
|
Requires-Dist: debugpy
|
|
17
|
+
Requires-Dist: pkginfo>=1.12
|
|
18
18
|
|
|
19
19
|
# Torizon Templates Utils
|
|
20
20
|
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) Toradex AG 2024
|
|
4
|
-
|
|
5
|
-
All rights reserved.
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
SOFTWARE.
|
|
File without changes
|
|
File without changes
|
{torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/args.py
RENAMED
|
File without changes
|
{torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/colors.py
RENAMED
|
File without changes
|
{torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/debug.py
RENAMED
|
File without changes
|
{torizon_templates_utils-0.0.9 → torizon_templates_utils-0.0.10}/torizon_templates_utils/errors.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|