def _sct_send(self): with logging.LogCall(__file__, "_sct_send", self.__class__): with SCTSock(create_socket(self.get_url(), self.get_port()), timeout=self.request.max_timeout) as sock: sock.send_init(self.request.setting_version) while self._sct_loop(sock): pass
def serialize(self) -> dict: with logging.LogCall(__file__, "serialize", self.__class__): ret = {} for k, v in self.__dict__.items(): if hasattr(v, "serialize"): ret[k] = v.serialize() else: ret[k] = v return ret
def execute(self, request: Request) -> Response: with logging.LogCall(__file__, "execute", self.__class__): res = self.Response() try: exec = self.Executor(self, request) exec.execute() res.error = exec.get_error() # pylint: disable=assignment-from-none if res.error: res.error_text = exec.get_error_text() res.text = exec.get_text() res.points = exec.get_points() except Exception as e: res.set_exception(e) return res
def _start_container(self): with logging.LogCall(__file__, "_start_container", self.__class__): c = self._docker_container if c.exists(): if c.is_running(): self.logger.debug( "Container(%s) is running", self._docker_container.container_name, ) return True else: if self._docker_image.create(self.plugin.path): self.logger.debug( "Image(%s) created", self._docker_image.image_name ) if self._docker_container.create(self._docker_image): self.logger.debug( "Container(%s) created", self._docker_container.container_name ) if self._docker_container.start(): self.logger.debug( "Container(%s) started", self._docker_container.container_name ) return True
def __init__(self, info: Info, path: str): with logging.LogCall(__file__, "__init__", self.__class__): self.info = info self.path = path self.logger = logging.PluginLogger(self.info.uid) self.logger.debug("%s initialized!", self.__class__.__name__)
def execute(self): with logging.LogCall(__file__, "execute", self.__class__): self._sct_send()
def __init__(self, *args, **kwargs): with logging.LogCall(__file__, "__init__", self.__class__): super().__init__(*args, **kwargs) self._sct_debug = [] self._sct_data = None
def from_form_data(self, data: dict = {}): """translate your form data structure to your settings structure""" with logging.LogCall(__file__, "from_form_data", self.__class__): pass
def get_form_data(self) -> dict: """translate your settings structure to your forms data structure""" with logging.LogCall(__file__, "get_form_data", self.__class__): return self.serialize()
def execute(self): with logging.LogCall(__file__, "execute", self.__class__): if django_settings.DOCKER_ENABLED != True: raise PluginException("Container disabled") self._start_container()
def __init__(self, *args, **kwargs): with logging.LogCall(__file__, "__init__", self.__class__): super().__init__(*args, **kwargs) self._docker_container = Container(self.request.token) self._docker_image = Image(self.plugin.info.uid, self.plugin.info.version)
def execute(self): with logging.LogCall(__file__, "execute", self.__class__): self.logger.critical("execute is not implemented by %s", self.__class__.__name__) raise NotImplementedError
def __init__(self, plugin, request, *args, **kwargs): with logging.LogCall(__file__, "__init__", self.__class__): self.request = request self.plugin = plugin self.logger = logging.PluginLogger(plugin.info.uid) self.logger.debug("Initializing %s", self.__class__.__name__)