Coverage for /opt/cloud/slavespace/usr1/096471637100f3de0fcfc01072822a80/ut/src/asys/drv/env_var.py: 100%
20 statements
« prev ^ index » next coverage.py v7.15.3, created at 2026-08-11 18:39 +0800
« prev ^ index » next coverage.py v7.15.3, created at 2026-08-11 18:39 +0800
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# ----------------------------------------------------------------------------
4# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5#
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# ----------------------------------------------------------------------------
19import os
21from common import FileOperate as f
24class EnvVarName:
25 def __init__(self):
26 self.process_log_path = self._set_env_path("ASCEND_PROCESS_LOG_PATH")
27 self.npu_collect_path = self._set_env_path("NPU_COLLECT_PATH")
28 self.dump_graph_path = self._set_env_path("DUMP_GRAPH_PATH")
29 self.work_path = self._set_env_path("ASCEND_WORK_PATH")
30 self.cache_path = self._set_env_path("ASCEND_CACHE_PATH")
31 self.opp_path = self._set_env_path("ASCEND_OPP_PATH")
32 self.custom_opp_path = self._set_env_path("ASCEND_CUSTOM_OPP_PATH")
33 self.current_path = os.getcwd()
34 self.home_path = os.path.expanduser("~")
36 @staticmethod
37 def _set_env_path(env_var):
38 env_path = os.getenv(env_var)
39 if env_path and f.check_dir(env_path):
40 ret = os.path.abspath(env_path)
41 else:
42 ret = None
43 return ret