opentf-toolkit-nightly 0.60.0.dev1223__py3-none-any.whl → 0.60.0.dev1230__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.
@@ -29,8 +29,12 @@ from flask import Flask, current_app, make_response, request, g, Response
29
29
 
30
30
  from toposort import toposort, CircularDependencyError
31
31
 
32
+ from .auth import (
33
+ initialize_authn_authz,
34
+ get_user_accessible_namespaces,
35
+ is_user_authorized,
36
+ )
32
37
  from .config import (
33
- ConfigError,
34
38
  make_argparser,
35
39
  configure_logging,
36
40
  read_config,
@@ -38,11 +42,7 @@ from .config import (
38
42
  get_named,
39
43
  get_debug_level,
40
44
  )
41
- from .auth import (
42
- initialize_authn_authz,
43
- get_user_accessible_namespaces,
44
- is_user_authorized,
45
- )
45
+ from .exceptions import ConfigError
46
46
  from .pubsub import make_dispatchqueue, make_event, publish, subscribe, unsubscribe
47
47
  from .schemas import *
48
48
 
opentf/commons/config.py CHANGED
@@ -24,6 +24,7 @@ from logging.config import dictConfig
24
24
 
25
25
  import yaml
26
26
 
27
+ from .exceptions import ConfigError
27
28
  from .schemas import validate_schema, SERVICECONFIG
28
29
 
29
30
 
@@ -44,10 +45,6 @@ DEBUG_LEVELS = {'CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG', 'NOTSET'}
44
45
  ########################################################################
45
46
 
46
47
 
47
- class ConfigError(Exception):
48
- """Invalid configuration file."""
49
-
50
-
51
48
  def make_argparser(description: str, configfile: str) -> argparse.ArgumentParser:
52
49
  parser = argparse.ArgumentParser(description=description)
53
50
  parser.add_argument('--descriptor', help='alternate descriptor file')
@@ -18,9 +18,9 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
18
18
 
19
19
  from datetime import datetime
20
20
 
21
-
22
21
  from flask import current_app
23
22
 
23
+ from opentf.commons.exceptions import ServiceError
24
24
  from opentf.commons.expressions import evaluate_bool
25
25
  from opentf.commons.selectors import match_selectors
26
26
 
@@ -49,21 +49,13 @@ CREATION_TIMESTAMP = 'creationTimestamp'
49
49
  ## Helpers
50
50
 
51
51
 
52
- class DataSourceScopeError(Exception):
52
+ class DataSourceScopeError(ServiceError):
53
53
  """DataSourceScopeError class"""
54
54
 
55
- def __init__(self, msg, details=None):
56
- self.msg = msg
57
- self.details = details
58
-
59
55
 
60
- class DataSourceDataError(Exception):
56
+ class DataSourceDataError(ServiceError):
61
57
  """DataSourceDataError class"""
62
58
 
63
- def __init__(self, msg, details=None):
64
- self.msg = msg
65
- self.details = details
66
-
67
59
 
68
60
  def _merge_dicts(dict1: Dict[str, Any], dict2: Dict[str, Any]) -> Dict[str, Any]:
69
61
  for k, v in dict1.items():
@@ -0,0 +1,108 @@
1
+ # Copyright (c) 2024 Henix, Henix.fr
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Helpers for the OpenTestFactory orchestrator exceptions.
16
+
17
+ ```plaintext
18
+ OpentfError
19
+ |- ConfigError
20
+ |- ServiceError
21
+ | |- AlreadyExistsError
22
+ | |- BadRequestError
23
+ | |- ConflictError
24
+ | |- InvalidRequestError
25
+ | |- NotFoundError
26
+ | |- UnauthorizedError
27
+ |- ExecutionError
28
+ ```
29
+ """
30
+
31
+
32
+ class OpentfError(Exception):
33
+ """Base orchestrator exceptions."""
34
+
35
+
36
+ class ConfigError(OpentfError):
37
+ """Invalid configuration file."""
38
+
39
+
40
+ class ServiceError(OpentfError):
41
+ """Base exception for request errors."""
42
+
43
+ status_name = 'ServiceError'
44
+
45
+ def __init__(self, msg, details=None):
46
+ self.msg = msg
47
+ self.details = details
48
+
49
+ @property
50
+ def http_status_name(self):
51
+ return self.status_name
52
+
53
+
54
+ class AlreadyExistsError(ServiceError):
55
+ """AlreadyExists exception."""
56
+
57
+ status_name = 'AlreadyExists'
58
+
59
+
60
+ class BadRequestError(ServiceError):
61
+ """BadRequest exception."""
62
+
63
+ status_name = 'BadRequest'
64
+
65
+
66
+ class ConflictError(ServiceError):
67
+ """Invalid exception."""
68
+
69
+ status_name = 'Conflict'
70
+
71
+
72
+ class InvalidRequestError(ServiceError):
73
+ """Invalid exception."""
74
+
75
+ status_name = 'Invalid'
76
+
77
+
78
+ class NotFoundError(ServiceError):
79
+ """NotFound exception."""
80
+
81
+ status_name = 'NotFound'
82
+
83
+
84
+ class UnauthorizedError(ServiceError):
85
+ """Invalid exception."""
86
+
87
+ status_name = 'Unauthorized'
88
+
89
+
90
+ ########################################################################
91
+ ## Exception helpers
92
+
93
+
94
+ class ExecutionError(OpentfError):
95
+ """An ExecutionError exception.
96
+
97
+ Only expected to be raised in a workflow thread. Will publish
98
+ the corresponding ExecutionError event if in this context.
99
+ """
100
+
101
+ def __init__(self, *args):
102
+ if args:
103
+ self.message = args[0]
104
+ else:
105
+ self.message = None
106
+
107
+ def __str__(self):
108
+ return str(self.message)
@@ -410,9 +410,11 @@ def process_output(
410
410
  filename, pattern = params.get('file'), params.get('pattern')
411
411
  if not filename and not pattern:
412
412
  pattern = '*'
413
+ found = False
413
414
  for artifact in artifacts:
414
415
  artifact_name = artifact.split('_')[-1]
415
416
  if filename and filename == artifact_name:
417
+ found = True
416
418
  if not remote_path:
417
419
  targeted_remote_path = core.join_path(
418
420
  targeted_remote_path, artifact_name, is_windows
@@ -420,11 +422,15 @@ def process_output(
420
422
  _put(targeted_remote_path, artifact)
421
423
  continue
422
424
  if pattern and fnmatch.fnmatch(artifact_name, pattern):
425
+ found = True
423
426
  pattern_path = core.join_path(
424
427
  targeted_remote_path, artifact_name, is_windows
425
428
  )
426
429
  _put(pattern_path, artifact)
427
- return resp
430
+ if found:
431
+ return resp
432
+ logs.append('ERROR,No artifact matching requested name/pattern found.')
433
+ return 2
428
434
  except Exception as err:
429
435
  logs.append(
430
436
  f'ERROR,Could not send artifacts to remote path {remote_path}: {err}.'
opentf/toolkit/core.py CHANGED
@@ -30,6 +30,7 @@ from opentf.commons import (
30
30
  make_event,
31
31
  make_uuid,
32
32
  )
33
+ from opentf.commons.exceptions import ExecutionError
33
34
 
34
35
 
35
36
  ########################################################################
@@ -86,27 +87,6 @@ def _getstep() -> Dict[str, Any]:
86
87
  return _getbody()['step']
87
88
 
88
89
 
89
- ########################################################################
90
- ## Exception helpers
91
-
92
-
93
- class ExecutionError(Exception):
94
- """An ExecutionError exception.
95
-
96
- Only expected to be raised in a workflow thread. Will publish
97
- the corresponding ExecutionError event if in this context.
98
- """
99
-
100
- def __init__(self, *args):
101
- if args:
102
- self.message = args[0]
103
- else:
104
- self.message = None
105
-
106
- def __str__(self):
107
- return str(self.message)
108
-
109
-
110
90
  ########################################################################
111
91
  ## Publication helpers
112
92
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentf-toolkit-nightly
3
- Version: 0.60.0.dev1223
3
+ Version: 0.60.0.dev1230
4
4
  Summary: OpenTestFactory Orchestrator Toolkit
5
5
  Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
6
6
  Author: Martin Lafaix
@@ -16,14 +16,14 @@ Classifier: License :: OSI Approved :: Apache Software License
16
16
  Requires-Python: >= 3.9.0
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
- Requires-Dist: requests >=2.32
20
- Requires-Dist: PyJWT[crypto] >=2.9
21
- Requires-Dist: PyYAML >=6
22
- Requires-Dist: Flask <4,>=3
23
- Requires-Dist: jsonschema >=4.23
24
- Requires-Dist: toposort >=1.10
25
- Requires-Dist: waitress >=3
26
- Requires-Dist: paste >=3.10
19
+ Requires-Dist: requests>=2.32
20
+ Requires-Dist: PyJWT[crypto]>=2.9
21
+ Requires-Dist: PyYAML>=6
22
+ Requires-Dist: Flask<4,>=3
23
+ Requires-Dist: jsonschema>=4.23
24
+ Requires-Dist: toposort>=1.10
25
+ Requires-Dist: waitress>=3
26
+ Requires-Dist: paste>=3.10
27
27
 
28
28
  # opentf-toolkit
29
29
 
@@ -1,7 +1,8 @@
1
- opentf/commons/__init__.py,sha256=JLif958eOnOeJSQ6bLF-Dpr_aFJ3JtxHrjvUe_KbzEc,22579
1
+ opentf/commons/__init__.py,sha256=xbDeHfYHshJtopyxljdTWw5vUXcUKosU6ILDNcEBZrY,22598
2
2
  opentf/commons/auth.py,sha256=bM2Z3kxm2Wku1lKXaRAIg37LHvXWAXIZIqjplDfN2P8,15899
3
- opentf/commons/config.py,sha256=dyus4K5Zdmcftc3Y9Z1YRkzA1KwiRLHoeAlg2_A49QM,7876
4
- opentf/commons/datasources.py,sha256=GSbjrYnZQup2B3r7T7l3C_o6R2jS13nQiu6dRitoenk,26194
3
+ opentf/commons/config.py,sha256=_8WzSaeB0yjGRa8mTQ69OASyUSbKZbwNOiKpMp2jFwI,7842
4
+ opentf/commons/datasources.py,sha256=c_bqqpiFibkRur75oIwV-gZtCLnluTS-9oVBoQ_NgGo,26054
5
+ opentf/commons/exceptions.py,sha256=7dhUXO8iyAbqVwlUKxZhgRzGqVcb7LkG39hFlm-VxIA,2407
5
6
  opentf/commons/expressions.py,sha256=jM_YKXVOFhvOE2aE2IuacuvxhIsOYTFs2oQkpcbWR6g,19645
6
7
  opentf/commons/pubsub.py,sha256=M0bvajR9raUP-xe5mfRjdrweZyHQw1_Qsy56gS-Sck4,7676
7
8
  opentf/commons/schemas.py,sha256=cjyPXRhRIPQauCdy9zGRaOkqdVcklz47JnljTTLNpq8,4254
@@ -56,10 +57,10 @@ opentf/schemas/opentestfactory.org/v1beta2/ServiceConfig.json,sha256=rEvK2YWL5lG
56
57
  opentf/scripts/launch_java_service.sh,sha256=S0jAaCuv2sZy0Gf2NGBuPX-eD531rcM-b0fNyhmzSjw,2423
57
58
  opentf/scripts/startup.py,sha256=sggwEpMx7PTaSgYzs-2uCF5YZzpsncMyTlfF_G60CrE,21518
58
59
  opentf/toolkit/__init__.py,sha256=mYeJPZ92ulbTBItqEsZgF4nnuRh6G19QPY3Jxc92ifc,23028
59
- opentf/toolkit/channels.py,sha256=lqFGQiHYiGMaYuGAXmbyaIsW2B_9KlaUTF8LiUIQOAg,23399
60
- opentf/toolkit/core.py,sha256=cscUkwdwvLkerqMRL05dgtKJ42QbBQQc28kRBiyZM9o,9883
61
- opentf_toolkit_nightly-0.60.0.dev1223.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
62
- opentf_toolkit_nightly-0.60.0.dev1223.dist-info/METADATA,sha256=R2zLhfHUmpQ3ooKvqJtLUnwhHhwCqxpXKVMzB1U5G5c,1940
63
- opentf_toolkit_nightly-0.60.0.dev1223.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
64
- opentf_toolkit_nightly-0.60.0.dev1223.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
65
- opentf_toolkit_nightly-0.60.0.dev1223.dist-info/RECORD,,
60
+ opentf/toolkit/channels.py,sha256=h5QLrr4vNLKjt8K524ZcJMqmHhE9kV5lxiW-MN6zMvQ,23622
61
+ opentf/toolkit/core.py,sha256=fqnGgaYnuVcd4fyeNIwpc0QtyUo7jsKeVgdkBfY3iqo,9443
62
+ opentf_toolkit_nightly-0.60.0.dev1230.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
63
+ opentf_toolkit_nightly-0.60.0.dev1230.dist-info/METADATA,sha256=PdJ6rkck6iblkKJG4M0n7Us3nWTGIOULosmmxqGlkig,1932
64
+ opentf_toolkit_nightly-0.60.0.dev1230.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
65
+ opentf_toolkit_nightly-0.60.0.dev1230.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
66
+ opentf_toolkit_nightly-0.60.0.dev1230.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5