Add src/nucleus/domains/executor/handler.py
Update src/nucleus/__main__.py Update src/nucleus/domains/comparator/handler.py Update src/nucleus/domains/config/broker.py Update src/nucleus/domains/config/common.py Update src/nucleus/domains/config/log.py Update src/nucleus/domains/executor/handler.py
This commit is contained in:
@@ -5,9 +5,9 @@ import sys
|
||||
import argparse
|
||||
import traceback
|
||||
|
||||
from controller.cli.rpc import handler_rpc
|
||||
from controller.cli.server import handler_server
|
||||
from controller.cli.version import handler_version
|
||||
from nucleus.cli.rpc import handler_rpc
|
||||
from nucleus.cli.server import handler_server
|
||||
from nucleus.cli.version import handler_version
|
||||
|
||||
|
||||
def main():
|
||||
@@ -24,7 +24,7 @@ def main():
|
||||
)
|
||||
parser.add_argument(
|
||||
"--config-path",
|
||||
default='/etc/dynamic/controller',
|
||||
default='/etc/dynamic/nucleus',
|
||||
help="Файл конфигурации"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ from dsl.state import State
|
||||
from dsl.handlers.state import variable_addition
|
||||
from helpers.yaml import yaml_read
|
||||
|
||||
from controller.core import config
|
||||
from controller.injector.broker import register
|
||||
from nucleus.core import config
|
||||
from nucleus.injector.broker import register
|
||||
|
||||
|
||||
class Comparator:
|
||||
|
||||
@@ -3,9 +3,9 @@ __email__ = 'remizoffalex@mail.ru'
|
||||
|
||||
from helpers.yaml import yaml_read
|
||||
|
||||
from controller.core import config, broker
|
||||
from controller.domains.comparator.handler import Comparator
|
||||
from controller.domains.executor.handler import Executor
|
||||
from nucleus.core import config, broker
|
||||
from nucleus.domains.comparator.handler import Comparator
|
||||
from nucleus.domains.executor.handler import Executor
|
||||
|
||||
|
||||
def handler_config_broker():
|
||||
|
||||
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
|
||||
from helpers.yaml import yaml_read
|
||||
|
||||
from controller.core import config
|
||||
from nucleus.core import config
|
||||
|
||||
|
||||
def handler_config(path):
|
||||
|
||||
@@ -5,7 +5,7 @@ from logging.config import dictConfig
|
||||
|
||||
from helpers.yaml import yaml_read
|
||||
|
||||
from controller.core import config
|
||||
from nucleus.core import config
|
||||
|
||||
|
||||
def handler_config_log():
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
|
||||
from logging import getLogger
|
||||
|
||||
from dsl.visitor import Visitor
|
||||
from dsl.state import State
|
||||
from dsl.injector.dsl import register
|
||||
from dsl.handlers.state import variable_addition, variable_get
|
||||
from helpers.yaml import yaml_read
|
||||
|
||||
from nucleus.domains.http.models.response import Response
|
||||
from nucleus.core import config
|
||||
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
||||
class Executor:
|
||||
def __init__(self, identifier):
|
||||
self.identifier = identifier
|
||||
|
||||
def __call__(self, request):
|
||||
variables = {
|
||||
'request': request,
|
||||
'Response': Response
|
||||
}
|
||||
|
||||
visitor = Visitor()
|
||||
register(visitor)
|
||||
|
||||
context = State()
|
||||
for key in variables:
|
||||
variable_addition(context, key, variables[key])
|
||||
|
||||
handler_path = config['dynamic.data.path'] / \
|
||||
'handlers' / self.identifier / 'data.yml'
|
||||
print(handler_path)
|
||||
source = yaml_read(handler_path)
|
||||
|
||||
visitor.visit(source, context)
|
||||
response = variable_get(context, 'response')
|
||||
print('response:', response)
|
||||
|
||||
raw = response()
|
||||
return raw
|
||||
Reference in New Issue
Block a user