当前位置: 首页>>代码示例>>Python>>正文


Python Interface.debug方法代码示例

本文整理汇总了Python中Interface.Interface.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.debug方法的具体用法?Python Interface.debug怎么用?Python Interface.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Interface.Interface的用法示例。


在下文中一共展示了Interface.debug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Interface import Interface [as 别名]
# 或者: from Interface.Interface import debug [as 别名]
class MakeTests:
    """
    This is main class. It finds all modules in the given directory and creates tests for them.
    """

    def __init__(self, tests_directory_path, local_modules_path, modules_path=None):
        """
        You should give to this constructor following arguments:
          * local_modules_path = Path to puppet modules which will be scanned for test files
          * tests_directory_path = Output directory where files will be written
          * modules_path = (Optional) Use this path to modules on test host system instead of local_modules_path.
            Useful when path to puppet modules differ on machine where tests are made and where they are executed.
        """
        self.interface = Interface(debuglevel=4)
        self.interface.debug('Starting MakeTests', 1)

        if not os.path.isdir(local_modules_path):
            self.interface.error('No such dir: ' + local_modules_path, 1)

        if not os.path.isdir(tests_directory_path):
            self.interface.error('No such dir: ' + tests_directory_path, 1)

        self.__local_modules_path = local_modules_path
        self.__modules_path = local_modules_path
        if modules_path:
            self.__modules_path = modules_path
        self.__tests_directory_path = tests_directory_path

        self.__default_template_file = 'puppet_module_test.py'
        self.__test_file_name_prefix = 'TestPuppetModule'

        self.__modules = []
        self.__module_templates = {}
        self.__make_tests_dir = os.path.dirname(os.path.abspath(__file__))

        self.setTemplatesDir('templates')
        self.setInternalModulesPath('/etc/puppet/modules')
        self.setInternalManifestsPath('/etc/puppet/manifests')

        self.findModules()

    def setTemplatesDir(self, template_dir):
        """
        Set directory to take templates from
        """
        if not os.path.isdir(template_dir):
            self.interface.error("No such dir: " + template_dir)
        self.__template_loader = jinja2.FileSystemLoader(searchpath=template_dir)
        self.__template_environment = templateEnv = jinja2.Environment(
            loader=self.__template_loader,
        )

    def setModuleTemplates(self, module_templates_dictionary):
        """
        Set module template file override dictionary
        """
        if type(module_templates_dictionary) is dict:
            self.__module_templates = module_templates_dictionary
        else:
            self.interface.error("Argument is not Dictionary")

    def setDefaultTemplateFile(self, template_file):
        """
        Set default script template file
        """
        self.__default_template_file = template_file

    def setInternalModulesPath(self, internal_modules_path):
        """
        Set path to modules inside virtual machine
        """
        self.__internal_modules_path = internal_modules_path

    def setInternalManifestsPath(self, internal_manifests_path):
        """
        Set path to manifests directory inside virtual machine
        """
        self.__internal_manifests_path = internal_manifests_path

    def getModulesList(self):
        """
        Get list of PuppetModule objects
        """
        return self.__modules

    def findModules(self):
        """
        Find all Puppet modules in module_library_path
        and create array of PuppetModule objects
        """
        self.interface.debug('Starting findModules in "%s"' % self.__local_modules_path, 2)
        for module_dir in os.listdir(self.__local_modules_path):
            full_local_module_path = os.path.join(self.__local_modules_path, module_dir)
            full_local_tests_path = os.path.join(full_local_module_path, 'tests')
            if not os.path.isdir(full_local_tests_path):
                continue
            self.interface.debug('Found Puppet module: "%s"' % full_local_module_path, 3)
            puppet_module = PuppetModule(full_local_module_path, self.interface)
            self.__modules.append(puppet_module)

#.........这里部分代码省略.........
开发者ID:dmitryilyin,项目名称:puppet_tests,代码行数:103,代码来源:MakeTests.py


注:本文中的Interface.Interface.debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。