opentf-toolkit-nightly 0.50.0.dev644__py3-none-any.whl → 0.50.0.dev653__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.
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- """Helpers for the OpenTestFactory orchestrator"""
15
+ """Helpers for the OpenTestFactory orchestrator services."""
16
16
 
17
17
  from typing import Any, Dict, List, Optional, Tuple, Union
18
18
 
@@ -331,29 +331,6 @@ def get_actor() -> Optional[str]:
331
331
  return None
332
332
 
333
333
 
334
- def run_app(app) -> None:
335
- """Start the app.
336
-
337
- Using waitress as the wsgi server. The logging service is
338
- configured to only show waitress errors and up messages.
339
-
340
- Access logs are only displayed when in DEBUG mode.
341
- """
342
- context = app.config['CONTEXT']
343
-
344
- from waitress import serve
345
-
346
- if _get_debug_level(app.name) == 'DEBUG':
347
- from paste.translogger import TransLogger
348
-
349
- app = TransLogger(app, format=ACCESSLOG_FORMAT, setup_console_handler=False)
350
- else:
351
- logging.getLogger('waitress').setLevel('ERROR')
352
- app.logger.info(f'Serving on http://{context["host"]}:{context["port"]}')
353
-
354
- serve(app, host=context['host'], port=context['port'])
355
-
356
-
357
334
  class EventbusLogger(logging.Handler):
358
335
  """A Notification logger.
359
336
 
@@ -477,12 +454,81 @@ def make_app(
477
454
 
478
455
  app.config['CONTEXT'] = context
479
456
  app.config['CONFIG'] = config
480
- app.config['DEBUG_LEVEL'] = os.environ.get('DEBUG_LEVEL', 'INFO')
481
457
  app.before_request(_make_authenticator(context))
482
458
  app.after_request(_add_securityheaders)
483
459
  return app
484
460
 
485
461
 
462
+ def get_context_parameter(app: Flask, contextparam: str, default: int) -> int:
463
+ """Get an integer parameter from configuration context.
464
+
465
+ Exits with an error code of 2 if the parameter is not an integer.
466
+
467
+ # Required parameters
468
+
469
+ - app: a Flask object
470
+ - contextparam: a string
471
+ - default: an integer
472
+
473
+ # Returned value
474
+
475
+ An integer. `default` if the context parameter is not defined.
476
+ """
477
+ try:
478
+ return int(app.config['CONTEXT'].get(contextparam, default))
479
+ except ValueError as err:
480
+ app.logger.error(
481
+ 'Configuration parameter %s not an integer: %s', contextparam, str(err)
482
+ )
483
+ sys.exit(2)
484
+
485
+
486
+ def get_context_service(app: Flask, service: str) -> Dict[str, Any]:
487
+ """Get service specification from configuration context.
488
+
489
+ Exits with an error code of 2 if the service is missing.
490
+
491
+ # Required parameters
492
+
493
+ - app: a Flask object
494
+ - service: a string
495
+
496
+ # Returned value
497
+
498
+ A dictionary.
499
+ """
500
+ if definition := app.config['CONTEXT'].get('services', {}).get(service):
501
+ return definition
502
+ app.logger.error(
503
+ '.services.{} specification missing in configuration context.',
504
+ service,
505
+ )
506
+ sys.exit(2)
507
+
508
+
509
+ def run_app(app) -> None:
510
+ """Start the app.
511
+
512
+ Using waitress as the wsgi server. The logging service is
513
+ configured to only show waitress errors and up messages.
514
+
515
+ Access logs are only displayed when in DEBUG mode.
516
+ """
517
+ context = app.config['CONTEXT']
518
+
519
+ from waitress import serve
520
+
521
+ if _get_debug_level(app.name) == 'DEBUG':
522
+ from paste.translogger import TransLogger
523
+
524
+ app = TransLogger(app, format=ACCESSLOG_FORMAT, setup_console_handler=False)
525
+ else:
526
+ logging.getLogger('waitress').setLevel('ERROR')
527
+ app.logger.info(f'Serving on http://{context["host"]}:{context["port"]}')
528
+
529
+ serve(app, host=context['host'], port=context['port'])
530
+
531
+
486
532
  ########################################################################
487
533
  ## Misc. helpers
488
534
 
@@ -498,7 +544,7 @@ def make_uuid():
498
544
 
499
545
  def make_status_response(
500
546
  reason: str, message: str, details: Optional[Dict[str, Any]] = None
501
- ):
547
+ ) -> Response:
502
548
  """Return a new status response object.
503
549
 
504
550
  # Required parameters
@@ -512,7 +558,8 @@ def make_status_response(
512
558
 
513
559
  # Returned value
514
560
 
515
- A _status_. A status is a dictionary with the following entries:
561
+ A _flask.Response_. Its body is a _status_ JSON object. It has
562
+ the following entries:
516
563
 
517
564
  - kind: a string (`'Status'`)
518
565
  - apiVersion: a string (`'v1'`)
@@ -25,7 +25,7 @@ from datetime import datetime
25
25
 
26
26
  STRING = r'(\'([^\']*)\')+'
27
27
  IDENTIFIER = r'^[a-zA-Z_][a-zA-Z0-9_-]*'
28
- NUMBER = r'^(0x[0-9a-fA-F]+)|(-?\d+(\.\d+)?)'
28
+ NUMBER = r'^((0x[0-9a-fA-F]+)|(-?\d+(\.\d+)?))'
29
29
  OPERATOR = r'^(==|!=|!|<=|<|>=|>|\[|\]|\(|\)|\.|&&|\|\||~=|,)'
30
30
 
31
31
  INFIX_OPERATOR = ('==', '!=', '<=', '<', '>', '>=', '&&', '||', '~=')
opentf/scripts/startup.py CHANGED
@@ -489,7 +489,7 @@ def main():
489
489
  with open(OPENTF_MANIFEST, 'r', encoding='utf-8') as manifest:
490
490
  conf = yaml.safe_load(manifest)
491
491
  except Exception as err:
492
- logging.error('Reading SquashTF manifest failed: %s.', str(err))
492
+ logging.error('Reading OpenTestFactory Launcher Manifest failed: %s.', str(err))
493
493
  sys.exit(1)
494
494
 
495
495
  logging.info('Checking Configuration...')
@@ -30,6 +30,7 @@ import yaml
30
30
  from opentf.commons import (
31
31
  make_app,
32
32
  run_app,
33
+ get_context_parameter,
33
34
  subscribe,
34
35
  unsubscribe,
35
36
  EXECUTIONCOMMAND,
@@ -324,18 +325,10 @@ def _watchdog(plugin, polling_delay):
324
325
 
325
326
  def _start_watchdog(plugin) -> None:
326
327
  """Set up a watchdog that monitors specified files for changes."""
327
- try:
328
- polling_delay = max(
329
- WATCHDOG_POLLING_DELAY_SECONDS,
330
- int(plugin.config['CONTEXT'].get(WATCHDOG_POLLING_DELAY_KEY, 0)),
331
- )
332
- except ValueError as err:
333
- plugin.logger.error(
334
- 'Configuration parameter %s not an integer: %s.',
335
- WATCHDOG_POLLING_DELAY_KEY,
336
- str(err),
337
- )
338
- sys.exit(2)
328
+ polling_delay = max(
329
+ WATCHDOG_POLLING_DELAY_SECONDS,
330
+ get_context_parameter(plugin, WATCHDOG_POLLING_DELAY_KEY, 0),
331
+ )
339
332
 
340
333
  plugin.logger.info('Watchdog configuration:')
341
334
  plugin.logger.info(
opentf/toolkit/core.py CHANGED
@@ -250,7 +250,7 @@ def attach_file(path: str, **kwargs) -> str:
250
250
  parameters:
251
251
 
252
252
  ```python
253
- core.attach_file('/foo/bar.xml',type='text/xml', 'charset'='utf8')
253
+ core.attach_file('/foo/bar.xml',type='text/xml', charset='utf8')
254
254
  # gives ::attach type=text/xml, charset=utf-8::/foo/bar.xml
255
255
  """
256
256
  if kwargs:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentf-toolkit-nightly
3
- Version: 0.50.0.dev644
3
+ Version: 0.50.0.dev653
4
4
  Summary: OpenTestFactory Orchestrator Toolkit
5
5
  Home-page: https://gitlab.com/henixdevelopment/open-source/opentestfactory/python-toolkit
6
6
  Author: Martin Lafaix
@@ -17,8 +17,8 @@ Classifier: License :: OSI Approved :: Apache Software License
17
17
  Requires-Python: >= 3.8.0
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: requests (>=2.28)
21
- Requires-Dist: PyJWT[crypto] (>=2.6)
20
+ Requires-Dist: requests (>=2.31)
21
+ Requires-Dist: PyJWT[crypto] (>=2.7)
22
22
  Requires-Dist: PyYAML (>=6)
23
23
  Requires-Dist: Flask (>=2.2.3)
24
24
  Requires-Dist: jsonschema (>=4.17)
@@ -1,7 +1,7 @@
1
- opentf/commons/__init__.py,sha256=ish0cuVYcj8g8bQy5cbt64QCe-50WBlj7_7jglZPVt4,18783
1
+ opentf/commons/__init__.py,sha256=DfoMjN4P_PgV37l7HM8qBywGO-r4l0RirKpSXlyz-iE,19986
2
2
  opentf/commons/auth.py,sha256=ADMygTSGy6voOQUAD9EtusPR_hgJ6jUK_uJE8CCpBoE,14481
3
3
  opentf/commons/config.py,sha256=lvxacmFxxQ8Va0qepx-ld7taCpjOr4l-NjDBOTrzrE4,3510
4
- opentf/commons/expressions.py,sha256=geFdZeHGB-l0IEGImS2oHbhqJhMxXaHSAknFqWrqBgs,18980
4
+ opentf/commons/expressions.py,sha256=F8oJgLB0LjqIJOfDHhw2MXY5CQuX7GksJZijY7K-TLc,18982
5
5
  opentf/commons/pubsub.py,sha256=_Psa3wdE_OB6wDHhUwr9zdxHpu5rSz19qtpM1Qo2WsY,5675
6
6
  opentf/commons/schemas.py,sha256=kMhZH47dpBk_HDMZk-1AlTb1dIYF-N6SPiEUmkEtWX0,3909
7
7
  opentf/commons/selectors.py,sha256=yj7Os7_8osvOssKUxi8d4tpKSMKBAa5hM81TWKjIADI,5521
@@ -41,12 +41,12 @@ opentf/schemas/opentestfactory.org/v1beta1/ServiceConfig.json,sha256=m5ZgWAKbutu
41
41
  opentf/schemas/opentestfactory.org/v1beta1/Workflow.json,sha256=QZ8mM9PhzsI9gTmwmKTWYNoRn--rtcM3L0PzgnPBfMU,15424
42
42
  opentf/schemas/opentestfactory.org/v1beta2/ServiceConfig.json,sha256=rEvK2YWL5lG94_qYgR_GnLWNsaQhaQ-2kuZdWJr5NnY,3517
43
43
  opentf/scripts/launch_java_service.sh,sha256=FRYrQD704VWLGXQ3QI-M3m77olXexB0vVEwzyiKLkxc,1579
44
- opentf/scripts/startup.py,sha256=46UL6uCBXId3z3009bIIOD-inFEKrgg3allNQQYFIZs,18703
45
- opentf/toolkit/__init__.py,sha256=s2HZLnfWPIvkfLWboWPT4JwfBNH-8kZd9XMsZ5Tibsk,19303
44
+ opentf/scripts/startup.py,sha256=CjKrFqbLyDKdUca-fWB-QkDURjdypkbrBUpEFNy3qQo,18719
45
+ opentf/toolkit/__init__.py,sha256=J8lC8gH952aspCnroErgaoqxsDBaNNAgiorfP8c5e3c,19088
46
46
  opentf/toolkit/channels.py,sha256=caUaZIRHp9D4BoJRtFug-M6tsjxrp3TDPaBxPlPghos,16121
47
- opentf/toolkit/core.py,sha256=wLu2fvcahExR6MYAwzsLJnG-tdO0wg6_LZ2NxHeUdvA,7314
48
- opentf_toolkit_nightly-0.50.0.dev644.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
- opentf_toolkit_nightly-0.50.0.dev644.dist-info/METADATA,sha256=fqaL6LveGoy170PIl3VLDm1oF1qufNLSogFGBgAeBsQ,1981
50
- opentf_toolkit_nightly-0.50.0.dev644.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
51
- opentf_toolkit_nightly-0.50.0.dev644.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
52
- opentf_toolkit_nightly-0.50.0.dev644.dist-info/RECORD,,
47
+ opentf/toolkit/core.py,sha256=40S-pUKXWidbI4JwkmQjGq46WlxJshj6d-wEl4e5TxU,7312
48
+ opentf_toolkit_nightly-0.50.0.dev653.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
+ opentf_toolkit_nightly-0.50.0.dev653.dist-info/METADATA,sha256=lXf9Al4eFwdGJ-673DrzSYO8u6UZeF6GT5eFdVDFoUo,1981
50
+ opentf_toolkit_nightly-0.50.0.dev653.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
51
+ opentf_toolkit_nightly-0.50.0.dev653.dist-info/top_level.txt,sha256=_gPuE6GTT6UNXy1DjtmQSfCcZb_qYA2vWmjg7a30AGk,7
52
+ opentf_toolkit_nightly-0.50.0.dev653.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.41.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5