38 lines
No EOL
1.6 KiB
Python
38 lines
No EOL
1.6 KiB
Python
from toloka2MediaServer.config_parser import load_configurations, get_toloka_client
|
|
from toloka2MediaServer.logger_setup import setup_logging
|
|
from toloka2MediaServer.models.config import Config
|
|
from toloka2MediaServer.clients.dynamic import dynamic_client_init
|
|
|
|
def initiate_config():
|
|
app_config_path='data/app.ini'
|
|
title_config_path='data/titles.ini'
|
|
logger_path = 'data/app_web.log'
|
|
|
|
app_config, titles_config, application_config = load_configurations(app_config_path,title_config_path)
|
|
toloka=get_toloka_client(application_config)
|
|
logger=setup_logging(logger_path)
|
|
|
|
config = Config(
|
|
logger=logger,
|
|
toloka=toloka,
|
|
app_config=app_config,
|
|
titles_config=titles_config,
|
|
application_config=application_config
|
|
)
|
|
|
|
client = dynamic_client_init(config)
|
|
config.client = client
|
|
|
|
return config
|
|
|
|
def serialize_operation_result(operation_result):
|
|
return {
|
|
"operation_type": operation_result.operation_type.name if operation_result.operation_type else None,
|
|
"torrent_references": [str(torrent) for torrent in operation_result.torrent_references],
|
|
"titles_references": [str(titles) for titles in operation_result.titles_references],
|
|
"status_message": operation_result.status_message,
|
|
"response_code": operation_result.response_code.name if operation_result.response_code else None,
|
|
"operation_logs": operation_result.operation_logs,
|
|
"start_time": operation_result.start_time.isoformat() if operation_result.start_time else None,
|
|
"end_time": operation_result.end_time.isoformat() if operation_result.end_time else None
|
|
} |