torizon-templates-utils 0.0.10__py3-none-any.whl → 0.0.11__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/network.py +9 -0
- torizon_templates_utils/tasks.py +48 -9
- {torizon_templates_utils-0.0.10.dist-info → torizon_templates_utils-0.0.11.dist-info}/METADATA +1 -1
- {torizon_templates_utils-0.0.10.dist-info → torizon_templates_utils-0.0.11.dist-info}/RECORD +6 -6
- {torizon_templates_utils-0.0.10.dist-info → torizon_templates_utils-0.0.11.dist-info}/WHEEL +1 -1
- {torizon_templates_utils-0.0.10.dist-info → torizon_templates_utils-0.0.11.dist-info}/top_level.txt +0 -0
|
@@ -33,3 +33,12 @@ def get_host_ip():
|
|
|
33
33
|
|
|
34
34
|
result = subprocess.run(command, capture_output=True, text=True)
|
|
35
35
|
return result.stdout.split()[0]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def is_in_docker_container():
|
|
39
|
+
return os.path.exists("/.dockerenv")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def is_in_gitlab_ci_container():
|
|
43
|
+
return "GITLAB_CI" in os.environ and is_in_docker_container()
|
|
44
|
+
|
torizon_templates_utils/tasks.py
CHANGED
|
@@ -8,6 +8,7 @@ import mimetypes
|
|
|
8
8
|
import subprocess
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from typing import List, Dict, Type, TypeVar, Union, Tuple, Optional, Literal
|
|
11
|
+
from torizon_templates_utils.network import is_in_docker_container
|
|
11
12
|
from torizon_templates_utils.colors import print, Color
|
|
12
13
|
|
|
13
14
|
T = TypeVar('T')
|
|
@@ -397,17 +398,55 @@ def get_tasks_json(file_path: str) -> TaskConfiguration:
|
|
|
397
398
|
|
|
398
399
|
|
|
399
400
|
def get_settings_json(
|
|
400
|
-
|
|
401
|
-
|
|
401
|
+
file_path: str,
|
|
402
|
+
custom_file: str | None = None
|
|
402
403
|
) -> TorizonSettings:
|
|
403
404
|
_file = custom_file if custom_file else "settings.json"
|
|
405
|
+
local_settings_path = Path(file_path) / ".vscode" / _file
|
|
406
|
+
|
|
407
|
+
try:
|
|
408
|
+
with open(local_settings_path, 'r') as file:
|
|
409
|
+
local_settings = json.load(file)
|
|
410
|
+
except FileNotFoundError:
|
|
411
|
+
print(f"No local settings file found at {local_settings_path}")
|
|
412
|
+
local_settings = {}
|
|
413
|
+
except json.JSONDecodeError as e:
|
|
414
|
+
raise ValueError(f"Invalid JSON in settings file: {e}")
|
|
415
|
+
|
|
416
|
+
workspace_settings = {}
|
|
417
|
+
parent_dir = Path(file_path).parent
|
|
418
|
+
# First check for .code-workspace files directly inside the parent
|
|
419
|
+
for child in parent_dir.glob("*.code-workspace"):
|
|
420
|
+
try:
|
|
421
|
+
with open(child, "r") as ws_file:
|
|
422
|
+
data = json.load(ws_file)
|
|
423
|
+
if "settings" in data:
|
|
424
|
+
print(f"Merging settings from: {child}")
|
|
425
|
+
workspace_settings = data["settings"]
|
|
426
|
+
break
|
|
427
|
+
except Exception as e:
|
|
428
|
+
print(f"Error reading {child}: {e}")
|
|
429
|
+
|
|
430
|
+
# If not found, scan folders in parent_dir
|
|
431
|
+
if not workspace_settings:
|
|
432
|
+
for sub in parent_dir.iterdir():
|
|
433
|
+
if sub.is_dir():
|
|
434
|
+
for child in sub.glob("*.code-workspace"):
|
|
435
|
+
try:
|
|
436
|
+
with open(child, "r") as ws_file:
|
|
437
|
+
data = json.load(ws_file)
|
|
438
|
+
if "settings" in data:
|
|
439
|
+
print(f"Merging settings from: {child}")
|
|
440
|
+
workspace_settings = data["settings"]
|
|
441
|
+
break
|
|
442
|
+
except Exception as e:
|
|
443
|
+
print(f"Error reading {child}: {e}")
|
|
444
|
+
if workspace_settings:
|
|
445
|
+
break
|
|
404
446
|
|
|
405
|
-
with
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return _tor_settings
|
|
447
|
+
# Merge with local settings taking precedence
|
|
448
|
+
combined = {**workspace_settings, **local_settings}
|
|
449
|
+
return _cast_from_json(combined, TorizonSettings)
|
|
411
450
|
|
|
412
451
|
|
|
413
452
|
class TaskRunner:
|
|
@@ -806,7 +845,7 @@ class TaskRunner:
|
|
|
806
845
|
|
|
807
846
|
|
|
808
847
|
def __replace_docker_host(self, arg: str) -> str:
|
|
809
|
-
if "DOCKER_HOST" in arg:
|
|
848
|
+
if "DOCKER_HOST" in arg and is_in_docker_container():
|
|
810
849
|
arg = arg.replace("DOCKER_HOST=", "DOCKER_HOST=tcp://docker:2375")
|
|
811
850
|
|
|
812
851
|
return arg
|
{torizon_templates_utils-0.0.10.dist-info → torizon_templates_utils-0.0.11.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: torizon_templates_utils
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.11
|
|
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
|
{torizon_templates_utils-0.0.10.dist-info → torizon_templates_utils-0.0.11.dist-info}/RECORD
RENAMED
|
@@ -4,9 +4,9 @@ torizon_templates_utils/args.py,sha256=nN1b9Ts2lEYbpAGzaMWpAcmcYIrTUFJHehM_UqvnC
|
|
|
4
4
|
torizon_templates_utils/colors.py,sha256=Y1FZ0HtKvXfLGYTDclsXubtZCQ-epuch5Dgk1DJdjps,1143
|
|
5
5
|
torizon_templates_utils/debug.py,sha256=OfdKSdN1kypuJnV_WcPa9bvonjyDvXvA3QTmc1iKyjw,556
|
|
6
6
|
torizon_templates_utils/errors.py,sha256=Wkk0AeCx0KQW-Qlu_5A6GYaGUkaJU79Mok8lZuZKHjM,1425
|
|
7
|
-
torizon_templates_utils/network.py,sha256=
|
|
8
|
-
torizon_templates_utils/tasks.py,sha256=
|
|
9
|
-
torizon_templates_utils-0.0.
|
|
10
|
-
torizon_templates_utils-0.0.
|
|
11
|
-
torizon_templates_utils-0.0.
|
|
12
|
-
torizon_templates_utils-0.0.
|
|
7
|
+
torizon_templates_utils/network.py,sha256=SFZivQumv-pVL0vglYCW3JS6WWCUG8asoMdgljeJZ24,1703
|
|
8
|
+
torizon_templates_utils/tasks.py,sha256=lDRIF9EXA-cjzLqWYmcf717M4pu6LkJYY5fYbuSu80Y,34597
|
|
9
|
+
torizon_templates_utils-0.0.11.dist-info/METADATA,sha256=PmYKN9vm5QHKexPGflu7Jm8fVnZLpK1iKEd-4a8e_Vw,977
|
|
10
|
+
torizon_templates_utils-0.0.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
torizon_templates_utils-0.0.11.dist-info/top_level.txt,sha256=qlOkS1ASF5C-kSfpbiWbVHJFgmQ0RN6iunmLArNt6zc,24
|
|
12
|
+
torizon_templates_utils-0.0.11.dist-info/RECORD,,
|
{torizon_templates_utils-0.0.10.dist-info → torizon_templates_utils-0.0.11.dist-info}/top_level.txt
RENAMED
|
File without changes
|