コード例 #1
0
 def getTemplates(self):
   machineTemplates = {}
   for d in self._templateDirs:
     files = listPath(d)
     for f in files:
       if os.path.isfile(f) and  os.path.splitext(os.path.basename(f))[1] == ".template":
         try:
           openedFile = open(os.path.join(f), "r")
           template = yaml.load(openedFile)
           machineTemplates["{0}:{1}".format(template.getName(),template.getVersion())] = template
           REGISTRYLOGGER.debug("Template stored in '{0}' loaded".format(f))
         except Exception as e:
           REGISTRYLOGGER.warning("Unable to load template stored in '{0}: {1}".format(f,str(e)))
           REGISTRYLOGGER.debug(traceback.format_exc())
   return machineTemplates
コード例 #2
0
ファイル: registries.py プロジェクト: baseboxorg/machination
 def getTemplates(self):
     machineTemplates = {}
     for d in self._templateDirs:
         files = listPath(d)
         for f in files:
             if os.path.isfile(f) and os.path.splitext(
                     os.path.basename(f))[1] == ".template":
                 try:
                     openedFile = open(os.path.join(f), "r")
                     template = yaml.load(openedFile)
                     machineTemplates["{0}:{1}".format(
                         template.getName(),
                         template.getVersion())] = template
                     REGISTRYLOGGER.debug(
                         "Template stored in '{0}' loaded".format(f))
                 except Exception as e:
                     REGISTRYLOGGER.warning(
                         "Unable to load template stored in '{0}: {1}".
                         format(f, str(e)))
                     REGISTRYLOGGER.debug(traceback.format_exc())
     return machineTemplates