1#!/usr/bin/env python3 2# coding=utf-8 3 4# 5# Copyright (c) 2020-2023 Huawei Device Co., Ltd. 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18 19from dataclasses import dataclass 20 21from _core.context.life_stage import StageEvent 22 23__all__ = ["UploadParams", "SessionInfo", "Connector", "Binder"] 24 25 26@dataclass 27class UploadParams: 28 upload_address: str = "" 29 task_type: str = "" 30 task_name: str = "" 31 mode: str = "" # 当前模式 32 proxy = None # 外部网络 33 device_labels = [] 34 35 36@dataclass 37class SessionInfo: 38 upload_address: str = "" 39 task_type: str = "" 40 task_name: str = "" 41 mode: str = "" # 当前模式 42 proxy = None # 外部网络 43 device_labels = [] 44 45 46class Connector: # 插件间通信 47 48 def __init__(self, info: SessionInfo): 49 self._session_info = info 50 51 def connect(self): 52 from _core.context.service import ContextImpl 53 if self._session_info: 54 ContextImpl().update_session_info(self._session_info) 55 56 57class Binder: 58 59 @staticmethod 60 def is_executing(): 61 from _core.context.center import Context 62 return Context.is_executing() 63 64 @staticmethod 65 def session(): 66 from _core.context.center import Context 67 return Context.session() 68 69 @staticmethod 70 def notify_stage(stage_event: StageEvent): 71 from _core.context.center import Context 72 if Context.get_scheduler(): 73 Context.get_scheduler().notify_stage(stage_event) 74 75 @staticmethod 76 def get_tdd_config(): 77 from _core.context.tdd import TSD 78 return TSD 79 80 @staticmethod 81 def get_runtime_log(): 82 from _core.context.log import RuntimeLogs 83 return RuntimeLogs 84