Я делаю отчёт в Word. Опиши без использования разметки, что делает код from…
- User
Я делаю отчёт в Word. Опиши без использования разметки, что делает код
from twisted.internet import reactor, protocol import yaml import sys import os import logging import re from twisted.internet import threads import subprocess import platform
from src.logic_refactor.test_logic import TestLogic from src.logic_refactor.image_processing import StaticProcessingLogic, DynamicProcessingLogic from src.logic_refactor.model_3d import Model3DLogic
class EchoFactory(protocol.Factory): def init(self, main): super().init() self.main = main
def buildProtocol(self, addr): proto = Echo(self.main) proto.factory = self return protoclass Echo(protocol.Protocol): def init(self, main): super().init() self.main = main
def dataReceived(self, data): try: if data == "calculate".encode('utf-8'): thread_calculate = threads.deferToThread(self.handle_static_calculation) #self.handle_static_calculation() elif data == "calculate_dynamic".encode('utf-8'): thread_calculate_dynamic = threads.deferToThread(self.handle_dynamic_calculation) #self.handle_dynamic_calculation() elif data == "3d".encode('utf-8'): thread_3d = threads.deferToThread(self.handle_3d) #self.handle_3d() elif data == "show_model".encode('utf-8'): #thread_show_model = threads.deferToThread(self.handle_show_model) self.handle_show_model() elif data == "kill".encode('utf-8'): self.main.kill() elif data == "reload".encode('utf-8'): self.main.reload() self.transport.write("reload_ready".encode('utf-8')) else: self.main.logger.info("Был выслан неизвестный TCP запрос") self.transport.write(data) except Exception: pass def handle_static_calculation(self): self.main.logger.info("TCP RECEIVED - calculate") calculater = StaticProcessingLogic( "calculatron/input/ready_photo.png", "calculatron/input/info.json", self.main.config ) self.main.if_previous_request_was_static_drape = True try: self.main.logger.info("Начат расчёт статических коэффициентов") calculater.calculate() self.main.logger.info("Закончен расчёт статических коэффициентов") self.main.logger.info("Начато создание визуализации для статических коэффициентов") calculater.create_plots() self.transport.write("ready".encode('utf-8')) self.main.logger.info("Закончено создание визуализации для статических коэффициентов") del calculater self.main.logger.info("TCP SENDED - ready") except Exception as exp: self.main.logger.exception(exp) def handle_dynamic_calculation(self): self.main.logger.info("TCP RECEIVED - calculate_dynamic") calculater = DynamicProcessingLogic([ "calculatron/input/ready_photo_60rpm.png", "calculatron/input/ready_photo_80rpm.png", "calculatron/input/ready_photo_100rpm.png", "calculatron/input/ready_photo_120rpm.png", ], "calculatron/input/info.json", self.main.config, self.main.if_previous_request_was_static_drape ) self.main.if_previous_request_was_static_drape = False try: self.main.logger.info("Начат расчёт динамических коэффициентов") calculater.calculate() self.transport.write("dynamic_ready".encode('utf-8')) self.main.logger.info("Закончен расчёт динамических коэффициентов") del calculater self.main.logger.info("TCP SENDED - dynamic_ready") except Exception as exp: self.main.logger.exception(exp) def handle_3d(self): self.main.logger.info("TCP RECEIVED - 3d") calculater = Model3DLogic( "calculatron/input/3D", self.main.config ) self.main.if_previous_request_was_static_drape = False try: self.main.logger.info("Происходит создание 3d модели") calculater.create_3d() self.transport.write("3d_ready".encode('utf-8')) self.main.logger.info("Закончено создание 3d модели") del calculater self.main.logger.info("TCP SENDED - 3d_ready") except Exception as exp: self.main.logger.exception(exp) def handle_show_model(self): self.main.logger.info("TCP RECEIVED - show_model") calculater = Model3DLogic( "calculatron/input/3D", self.main.config ) self.main.if_previous_request_was_static_drape = False try: self.main.logger.info("Происходит визуализация 3d модели") calculater.visualise_3d_model() self.transport.write("show_model_ready".encode('utf-8')) self.main.logger.info("Визуализация 3d модели закончена") del calculater self.main.logger.info("TCP SENDED - show_model_ready") except Exception as exp: self.main.logger.exception(exp) - Assistant