1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4# 5# Copyright (c) 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 19import os 20import sys 21 22from containers.arg import Arg 23from containers.arg import ModuleType 24from resolver.interface.args_resolver_interface import ArgsResolverInterface 25from modules.interface.update_module_interface import UpdateModuleInterface 26from util.component_util import ComponentUtil 27from exceptions.ohos_exception import OHOSException 28from services.hpm import CMDTYPE 29 30class UpdateArgsResolver(ArgsResolverInterface): 31 32 def __init__(self, args_dict: dict): 33 super().__init__(args_dict) 34 35 @staticmethod 36 def resolve_part(target_arg: Arg, update_module: UpdateModuleInterface): 37 part_name = target_arg.arg_value 38 if len(sys.argv) > 2 and not sys.argv[2].startswith("-"): # 第一个部件名参数 39 part_name = sys.argv[2] 40 if part_name: 41 update_module.hpm.regist_flag('part_name', part_name) 42 43 @staticmethod 44 def resolve_global(target_arg: Arg, update_module: UpdateModuleInterface): 45 if target_arg.arg_value == True or target_arg.arg_value == '': 46 update_module.hpm.regist_flag('global', '')