1#!/usr/bin/env python3
2# coding=utf-8
3
4#
5# Copyright (c) 2022 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 devicetest.core.exception import TestTerminated
20from devicetest.error import ErrorMessage
21
22
23class DeviceTestRecord:
24    is_aborted = False  # 初始值为False,DeviceTest过程执行异常置为True
25
26
27class ProjectRecord:
28    def __init__(self, log):
29        # 记录工程执行状态的全局变量
30        self.log = log
31        self.is_aborted = False  # 初始值为False,DeviceTest过程执行异常置为True
32        self.is_upload_suitereporter = False
33
34    def is_shutdown(self, raise_exception=True):
35        if self.is_aborted:
36            err_msg = ErrorMessage.Common.Code_0201004
37            self.log.error(err_msg)
38            if raise_exception:
39                raise TestTerminated(err_msg)
40            return True
41
42        return False
43
44    def set_is_upload_suitereporter_status(self, status):
45        self.is_upload_suitereporter = status
46        self.log.info(
47            "set is upload suitereporter status as: {}".format(status))
48