AttributeError:“模块”对象没有属性“ install_htx”

时间:2019-10-21 10:38:22

标签: python-2.7

我在同一文件夹中有两个脚本-Util.py和Lpar.py。我在Util.py [类Util]中有一个类,其中包含一个函数[def install_htx()]。我想从文件Lpar.py-[Util.install_htx()]中的另一个函数def post_install()调用此函数。我已经在Lpar.py中导入了Util类,但是出现了错误。

AttributeError:“模块”对象没有属性“ install_htx”

class Util:

    def install_htx(self, htx_version=None):
    """
    this will install netop on lpar.

    :param netop_version:
    :return:
    """
        is_htx_already_installed = self.execute_command("lslpp -l htx", throw_exception=False)
        if is_htx_already_installed is None:
            self.execute_command("chfs -a size=+2G /", throw_exception=False)
        if htx_version is None:
            try:
                bs = self.get_version_stream()
                logging.info(bs)
                htx_version = latest_htx[bs]
            except KeyError as ke:
                logging.error("HTX version for {} is not found HTX installation is not done!".format(bs))
                return None
        return self.install_fileset("{}/FVT_PACKAGES/TEST_TOOLS/HTX/{}".format(Utility.ROOT_PATH, htx_version))
    else:
        logging.info(
            "HTX is already installed on {}\n HTX Detail: {}".format(self.lpar_name, is_htx_already_installed))

从Lpar.py调用

import Util
def post_install(lpar, post_install_options=["DEFAULT"]):

    if "HTX" in post_install_options:
        logging.info("Installing HTX")
        Util.install_htx()
        logging.info("Installing HTX Done!")

if __name__ == '__main__':

    post_install(lpar=lpar, post_install_options=args.post_install)

0 个答案:

没有答案