opentf-toolkit-nightly 0.50.0.dev650__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.
- opentf/commons/__init__.py +70 -23
- opentf/toolkit/__init__.py +5 -12
- {opentf_toolkit_nightly-0.50.0.dev650.dist-info → opentf_toolkit_nightly-0.50.0.dev653.dist-info}/METADATA +1 -1
- {opentf_toolkit_nightly-0.50.0.dev650.dist-info → opentf_toolkit_nightly-0.50.0.dev653.dist-info}/RECORD +7 -7
- {opentf_toolkit_nightly-0.50.0.dev650.dist-info → opentf_toolkit_nightly-0.50.0.dev653.dist-info}/LICENSE +0 -0
- {opentf_toolkit_nightly-0.50.0.dev650.dist-info → opentf_toolkit_nightly-0.50.0.dev653.dist-info}/WHEEL +0 -0
- {opentf_toolkit_nightly-0.50.0.dev650.dist-info → opentf_toolkit_nightly-0.50.0.dev653.dist-info}/top_level.txt +0 -0
opentf/commons/__init__.py
CHANGED
|
@@ -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
|
|
|
@@ -482,6 +459,76 @@ def make_app(
|
|
|
482
459
|
return app
|
|
483
460
|
|
|
484
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
|
+
|
|
485
532
|
########################################################################
|
|
486
533
|
## Misc. helpers
|
|
487
534
|
|
opentf/toolkit/__init__.py
CHANGED
|
@@ -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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
opentf/commons/__init__.py,sha256=
|
|
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
4
|
opentf/commons/expressions.py,sha256=F8oJgLB0LjqIJOfDHhw2MXY5CQuX7GksJZijY7K-TLc,18982
|
|
@@ -42,11 +42,11 @@ opentf/schemas/opentestfactory.org/v1beta1/Workflow.json,sha256=QZ8mM9PhzsI9gTmw
|
|
|
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
44
|
opentf/scripts/startup.py,sha256=CjKrFqbLyDKdUca-fWB-QkDURjdypkbrBUpEFNy3qQo,18719
|
|
45
|
-
opentf/toolkit/__init__.py,sha256=
|
|
45
|
+
opentf/toolkit/__init__.py,sha256=J8lC8gH952aspCnroErgaoqxsDBaNNAgiorfP8c5e3c,19088
|
|
46
46
|
opentf/toolkit/channels.py,sha256=caUaZIRHp9D4BoJRtFug-M6tsjxrp3TDPaBxPlPghos,16121
|
|
47
47
|
opentf/toolkit/core.py,sha256=40S-pUKXWidbI4JwkmQjGq46WlxJshj6d-wEl4e5TxU,7312
|
|
48
|
-
opentf_toolkit_nightly-0.50.0.
|
|
49
|
-
opentf_toolkit_nightly-0.50.0.
|
|
50
|
-
opentf_toolkit_nightly-0.50.0.
|
|
51
|
-
opentf_toolkit_nightly-0.50.0.
|
|
52
|
-
opentf_toolkit_nightly-0.50.0.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|