from services.hpm import CMDTYPE
from modules.interface.install_module_interface import InstallModuleInterface
from resolver.interface.args_resolver_interface import ArgsResolverInterface
from exceptions.ohos_exception import OHOSException
from services.interface.build_file_generator_interface import BuildFileGeneratorInterface
from util.log_util import LogUtil
from containers.status import throw_exception
class OHOSInstallModule(InstallModuleInterface):
_instance = None
def __init__(self, args_dict: dict, args_resolver: ArgsResolverInterface, hpm: BuildFileGeneratorInterface):
super().__init__(args_dict, args_resolver)
self._hpm = hpm
OHOSInstallModule._instance = self
@property
def hpm(self):
return self._hpm
@staticmethod
def get_instance():
if OHOSInstallModule._instance is not None:
return OHOSInstallModule._instance
else:
raise OHOSException(
'OHOSInstallModule has not been instantiated', '0000')
@throw_exception
def run(self):
try:
super().run()
except OHOSException as exception:
raise exception
else:
LogUtil.hb_info('{} build success')
def _install(self):
self._run_phase()
self.hpm.execute_hpm_cmd(CMDTYPE.INSTALL)
def _run_phase(self):
for arg in self.args_dict.values():
self.args_resolver.resolve_arg(arg, self)