コード例 #1
0
 def convertKIDSBuildFile(self, kidsFile):
     from KIDSPatchParser import KIDSPatchParser, outputMetaDataInJSON
     assert os.path.exists(kidsFile)
     """ write KIDS metadata file """
     kidsParser = KIDSPatchParser(None)
     """ do not parse the routine part """
     kidsParser.unregisterSectionHandler(KIDSPatchParser.ROUTINE_SECTION)
     kidsParser.parseKIDSBuild(kidsFile)
     logger.info("output meta data as %s" % (kidsFile + ".json"))
     outputMetaDataInJSON(kidsParser, kidsFile + ".json")
     self.convertToSha1File(kidsFile)
コード例 #2
0
def main():
    testClientParser = createTestClientArgParser()
    parser = argparse.ArgumentParser(description='Default KIDS Installer',
                                     parents=[testClientParser])
    parser.add_argument('kidsFile', help='path to KIDS Build file')
    parser.add_argument('-l',
                        '--logFile',
                        default=None,
                        help='path to logFile')
    parser.add_argument(
        '-r',
        '--reinstall',
        default=False,
        action='store_true',
        help='whether re-install the KIDS even it is already installed')
    parser.add_argument('-g',
                        '--globalFiles',
                        default=None,
                        nargs='*',
                        help='list of global files that need to import')

    result = parser.parse_args()
    print(result)
    testClient = VistATestClientFactory.createVistATestClientWithArgs(result)
    assert testClient
    initConsoleLogging()
    with testClient:
        kidsFile = os.path.abspath(result.kidsFile)
        from KIDSPatchParser import KIDSPatchParser
        kidsParser = KIDSPatchParser(None)
        kidsParser.unregisterSectionHandler(KIDSPatchParser.ROUTINE_SECTION)
        kidsParser.parseKIDSBuild(kidsFile)
        installNameList = kidsParser.installNameList
        installName = installNameList[0]
        multiBuildList = installNameList
        if len(installNameList) == 1:
            multiBuildList = None
        defaultKidsInstall = DefaultKIDSPatchInstaller(
            kidsFile,
            installName,
            logFile=result.logFile,
            multiBuildList=multiBuildList,
            globals=result.globalFiles)
        defaultKidsInstall.runInstallation(testClient, result.reinstall)
コード例 #3
0
    def __parseAllKIDSBuildFilesList__(self):
        for basename in self._kidsBuildFileDict.iterkeys():
            kidsFile, sha1Path = self._kidsBuildFileDict[basename]
            if kidsFile == None:
                logger.error("No KIDS file available for name %s" % basename)
                continue
            installNameList, seqNo, kidsBuilds = None, None, None
            if isValidKIDSPatchHeaderSuffix(kidsFile):
                from KIDSPatchParser import loadMetaDataFromJSON
                #continue
                installNameList, seqNo, kidsBuilds = loadMetaDataFromJSON(
                    kidsFile)
            else:
                kidsParser = KIDSPatchParser(None)
                kidsParser.unregisterSectionHandler(
                    KIDSPatchParser.ROUTINE_SECTION)
                kidsParser.parseKIDSBuild(kidsFile)
                installNameList = kidsParser.installNameList
                logger.debug("install name list is %s" % installNameList)
                seqNo = kidsParser.seqNo
                kidsBuilds = kidsParser.kidsBuilds
            if len(installNameList) > 1:
                if not self._multiBuildDict.get(kidsFile):
                    self._multiBuildDict[kidsFile] = installNameList
                else:
                    assert self._multiBuildDict[kidsFile] == installNameList
            elif seqNo:
                if installNameList[0] not in self._installNameSeqMap:
                    self._installNameSeqMap[installNameList[0]] = seqNo
                else:
                    logger.error("Duplicated KIDS build file %s" % kidsFile)
            for installName in installNameList:
                if installName in self._kidsInstallNameDict:
                    logger.warn("%s is already in the dict %s" %
                                (installName, kidsFile))
                logger.debug("Added installName %s, file %s" %
                             (installName, kidsFile))
                self._kidsInstallNameDict[installName] = os.path.normpath(
                    kidsFile)
                """ handle KIDS sha1 file Path """
                if sha1Path:
                    if installName in self._kidsInstallNameSha1Dict:
                        logger.warn("%s is already in the dict %s" %
                                    (installName, sha1Path))
                    self._kidsInstallNameSha1Dict[installName] = sha1Path
                """ update kids dependency """
                if installName in self._kidsDepBuildDict:
                    logger.warn(
                        "%s is already has the dep map %s" %
                        (installName, self._kidsDepBuildDict[installName]))
                if kidsBuilds:
                    for kidsBuild in kidsBuilds:
                        if kidsBuild.installName == installName:
                            depList = kidsBuild.dependencyList
                            if depList:
                                self._kidsDepBuildDict[installName] = set(
                                    [x[0] for x in depList])
                                logger.info(
                                    "%s: %s" %
                                    (installName,
                                     self._kidsDepBuildDict[installName]))

        logger.debug("%s" % sorted(self._kidsInstallNameDict.keys()))
        logger.info("Total # of install name %d" %
                    len(self._kidsInstallNameDict))