torizon-templates-utils 0.0.8__tar.gz → 0.0.9__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.
Files changed (18) hide show
  1. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/PKG-INFO +1 -1
  2. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/pyproject.toml +1 -1
  3. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/errors.py +5 -1
  4. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/tasks.py +25 -14
  5. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils.egg-info/PKG-INFO +1 -1
  6. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/LICENSE +0 -0
  7. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/README.md +0 -0
  8. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/setup.cfg +0 -0
  9. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/__init__.py +0 -0
  10. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/animations.py +0 -0
  11. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/args.py +0 -0
  12. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/colors.py +0 -0
  13. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/debug.py +0 -0
  14. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils/network.py +0 -0
  15. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils.egg-info/SOURCES.txt +0 -0
  16. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils.egg-info/dependency_links.txt +0 -0
  17. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils.egg-info/requires.txt +0 -0
  18. {torizon_templates_utils-0.0.8 → torizon_templates_utils-0.0.9}/torizon_templates_utils.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: torizon_templates_utils
3
- Version: 0.0.8
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "torizon_templates_utils"
7
- version = "0.0.8"
7
+ version = "0.0.9"
8
8
  authors = [
9
9
  { name="Matheus Castello", email="matheus.castello@toradex.com" },
10
10
  ]
@@ -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
  )
@@ -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 = True
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 = False
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
- raise RuntimeError(f"Error running torizon-io.xsh: {_p_ret.stderr}")
571
-
572
- _next = int(_p_ret.stdout.strip()) +1
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
- ret.append(
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: torizon_templates_utils
3
- Version: 0.0.8
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