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


Python CommandUtils.runCommandInShell方法代码示例

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


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

示例1: buildCoreToolChainPackages

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def buildCoreToolChainPackages(self):
     self.logger.info("Building core tool chain packages.....")
     chrootID=None
     try:
         pkgUtils=PackageUtils(self.logName,self.logPath)
         for package in constants.listCoreToolChainRPMPackages:
             rpmPkg=pkgUtils.findRPMFileForGivenPackage(package)
             if rpmPkg is not None:
                 continue
             chrUtils = ChrootUtils(self.logName,self.logPath)
             chrootName="build-core-toolchain"
             destLogPath=constants.logPath+"/build-"+package
             if not os.path.isdir(destLogPath):
                 cmdUtils = CommandUtils()
                 cmdUtils.runCommandInShell("mkdir -p "+destLogPath)
             returnVal,chrootID = chrUtils.createChroot(chrootName)
             if not returnVal:
                 self.logger.error("Creating chroot failed")
                 raise Exception("creating chroot failed")
             self.installToolChainRPMS(chrootID)
             pkgUtils.adjustGCCSpecs(package, chrootID, destLogPath)
             pkgUtils.buildRPMSForGivenPackage(package, chrootID,destLogPath)
             chrUtils.destroyChroot(chrootID)
             chrootID=None
         self.logger.info("Successfully built toolchain")
         if chrootID is not None:
             chrUtils.destroyChroot(chrootID)
     except Exception as e:
         self.logger.error("Unable to build tool chain.")
         # print stacktrace
         traceback.print_exc()
         raise e
开发者ID:jacob-vmware,项目名称:photon,代码行数:34,代码来源:ToolChainUtils.py

示例2: buildPackage

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def buildPackage(self,package):
     #should initialize a logger based on package name
     chrUtils = ChrootUtils(self.logName,self.logPath)
     chrootName="build-"+package
     chrootID=None
     isToolChainPackage=False
     if package in constants.listToolChainPackages:
         isToolChainPackage=True
     try:
         chrootID = self.prepareBuildRoot(chrootName,isToolChainPackage)
         destLogPath=constants.logPath+"/build-"+package
         if not os.path.isdir(destLogPath):
             cmdUtils = CommandUtils()
             cmdUtils.runCommandInShell("mkdir -p "+destLogPath)
         
         listInstalledPackages=self.findInstalledPackages(chrootID)
         self.logger.info("List of installed packages")
         self.logger.info(listInstalledPackages)
         listDependentPackages=self.findBuildTimeRequiredPackages(package)
         
         if len(listDependentPackages) != 0:
             self.logger.info("Installing the build time dependent packages......")
             for pkg in listDependentPackages:
                 self.installPackage(pkg,chrootID,destLogPath,listInstalledPackages)
             self.logger.info("Finished installing the build time dependent packages......")
         self.adjustGCCSpecs(package, chrootID, destLogPath)
         pkgUtils = PackageUtils(self.logName,self.logPath)
         pkgUtils.buildRPMSForGivenPackage(package,chrootID,destLogPath)
         self.logger.info("Successfully built the package:"+package)
     except Exception as e:
         self.logger.error("Failed while building package:" + package)
         self.logger.debug("Chroot with ID: " + chrootID + " not deleted for debugging.")
         raise e
     if chrootID is not None:
         chrUtils.destroyChroot(chrootID)
开发者ID:johnt337,项目名称:photon,代码行数:37,代码来源:PackageBuilder.py

示例3: installRPMSInAOneShot

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def installRPMSInAOneShot(self,chrootID,destLogPath):
     chrootCmd=self.runInChrootCommand+" "+chrootID
     rpmInstallcmd=self.rpmBinary+" "+ self.installRPMPackageOptions
     if self.noDepsRPMFilesToInstallInAOneShot != "":
         self.logger.info("Installing nodeps rpms: " + self.noDepsPackagesToInstallInAOneShot)
         logFile=chrootID+constants.topDirPath+"/LOGS/install_rpms_nodeps.log"
         cmdUtils = CommandUtils()
         cmd = rpmInstallcmd+" "+self.nodepsRPMPackageOptions + " " + self.noDepsRPMFilesToInstallInAOneShot
         returnVal = cmdUtils.runCommandInShell(cmd, logFile, chrootCmd)
         if destLogPath is not None:
             shutil.copy2(logFile, destLogPath)
         if not returnVal:
             self.logger.error("Unable to install rpms")
             raise Exception("RPM installation failed")
     if self.rpmFilesToInstallInAOneShot != "":
         self.logger.info("Installing rpms: " + self.packagesToInstallInAOneShot)
         logFile=chrootID+constants.topDirPath+"/LOGS/install_rpms.log"
         cmdUtils = CommandUtils()
         cmd=rpmInstallcmd+" "+self.rpmFilesToInstallInAOneShot
         returnVal = cmdUtils.runCommandInShell(cmd, logFile, chrootCmd)
         if destLogPath is not None:
             shutil.copy2(logFile, destLogPath)
         if not returnVal:
             self.logger.error("Unable to install rpms")
             raise Exception("RPM installation failed")
开发者ID:BillTheBest,项目名称:photon,代码行数:27,代码来源:PackageUtils.py

示例4: _copySourcesToContainer

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def _copySourcesToContainer(self, listSourceFiles, package, containerID, destDir, index=0):
     cmdUtils = CommandUtils()
     for source in listSourceFiles:
         sourcePath = self._verifyShaAndGetSourcePath(source, package, index)
         self.logger.info("Copying source file: " + sourcePath[0])
         copyCmd = "docker cp " + sourcePath[0] + " " + containerID.short_id + ":" + destDir
         cmdUtils.runCommandInShell(copyCmd)
开发者ID:TiejunChina,项目名称:photon,代码行数:9,代码来源:PackageUtils.py

示例5: _buildPackagePrepareFunction

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def _buildPackagePrepareFunction(self, package):
     self.package = package
     self.logName = "build-" + package
     self.logPath = constants.logPath + "/build-" + package
     if not os.path.isdir(self.logPath):
         cmdUtils = CommandUtils()
         cmdUtils.runCommandInShell("mkdir -p " + self.logPath)
     self.logger = Logger.getLogger(self.logName, self.logPath)
开发者ID:vinaykul,项目名称:photon,代码行数:10,代码来源:PackageBuilder.py

示例6: writePkgListToFile

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def writePkgListToFile(self, fileName):
     self.logger.debug("Writing package list to the json file")
     cmdUtils = CommandUtils()
     dirPath = os.path.basename(fileName)
     if not os.path.isdir(dirPath):
         cmdUtils.runCommandInShell("mkdir -p " + dirPath)
     with open(fileName, 'w+') as pkgInfoFile:
         json.dump(self.pkgList, pkgInfoFile, indent=4)
开发者ID:frapposelli,项目名称:photon,代码行数:10,代码来源:PackageInfo.py

示例7: copyRPM

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def copyRPM(self, rpmFile, destDir):
     cmdUtils = CommandUtils()
     rpmName = os.path.basename(rpmFile)
     rpmDestDir = self.getRPMDestDir(rpmName, destDir)
     if not os.path.isdir(rpmDestDir):
         cmdUtils.runCommandInShell("mkdir -p " + rpmDestDir)
     rpmDestPath = rpmDestDir + "/" + rpmName
     shutil.copyfile(rpmFile, rpmDestPath)
     return rpmDestPath
开发者ID:johnt337,项目名称:photon,代码行数:11,代码来源:PackageUtils.py

示例8: writePkgListToFile

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def writePkgListToFile(fileName):
     SourcePackageInfo.logger.info("Writing source package list to the json file")
     cmdUtils = CommandUtils()
     dirPath = os.path.basename(fileName)
     if not os.path.isdir(dirPath):
         cmdUtils.runCommandInShell("mkdir -p " + dirPath)
     pkgInfoFile = open(fileName, "w+")
     json.dump(SourcePackageInfo.sourcePkgList, pkgInfoFile, indent=4)
     pkgInfoFile.close()
开发者ID:casualjim,项目名称:photon,代码行数:11,代码来源:PackageInfo.py

示例9: buildPackage

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
    def buildPackage(self,package):
        #do not build if RPM is already built
        #test only if the package is in the testForceRPMS with rpmCheck
        #build only if the package is not in the testForceRPMS with rpmCheck
        if self.checkIfPackageIsAlreadyBuilt(package):
            if not constants.rpmCheck:
                self.logger.info("Skipping building the package:"+package)
                return
            elif constants.rpmCheck and package not in constants.testForceRPMS:
                self.logger.info("Skipping testing the package:"+package)
                return

        #should initialize a logger based on package name
        chrUtils = ChrootUtils(self.logName,self.logPath)
        chrootName="build-"+package
        chrootID=None
        isToolChainPackage=False
        if package in constants.listToolChainPackages:
            isToolChainPackage=True
        try:
            chrootID = self.prepareBuildRoot(chrootName,isToolChainPackage)
            destLogPath=constants.logPath+"/build-"+package
            if not os.path.isdir(destLogPath):
                cmdUtils = CommandUtils()
                cmdUtils.runCommandInShell("mkdir -p "+destLogPath)

            listInstalledPackages=self.findInstalledPackages(chrootID)
            listDependentPackages=self.findBuildTimeRequiredPackages(package)
            if constants.rpmCheck and package in constants.testForceRPMS:
                testPackages=set(constants.listMakeCheckRPMPkgtoInstall)-set(listInstalledPackages)-set([package])
                listDependentPackages.extend(testPackages)

            pkgUtils = PackageUtils(self.logName,self.logPath)
            if len(listDependentPackages) != 0:
                self.logger.info("Installing the build time dependent packages......")
                for pkg in listDependentPackages:
                    self.installPackage(pkgUtils, pkg,chrootID,destLogPath,listInstalledPackages)
                pkgUtils.installRPMSInAOneShot(chrootID,destLogPath)
                self.logger.info("Finished installing the build time dependent packages......")

            pkgUtils.adjustGCCSpecs(package, chrootID, destLogPath)
            pkgUtils.buildRPMSForGivenPackage(package,chrootID,self.listBuildOptionPackages,self.pkgBuildOptionFile,destLogPath)
            self.logger.info("Successfully built the package:"+package)
        except Exception as e:
            self.logger.error("Failed while building package:" + package)
            self.logger.debug("Chroot with ID: " + chrootID + " not deleted for debugging.")
            logFileName = os.path.join(destLogPath, package + ".log")
            fileLog = os.popen('tail -n 100 ' + logFileName).read()
            self.logger.debug(fileLog)
            raise e
        if chrootID is not None:
            chrUtils.destroyChroot(chrootID)
开发者ID:pbidkar,项目名称:photon,代码行数:54,代码来源:PackageBuilder.py

示例10: buildSourcesList

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
def buildSourcesList(yamlDir, blackListPkgs, logger, singleFile=True):
    cmdUtils = CommandUtils()
    yamlSourceDir = os.path.join(yamlDir, "yaml_sources")
    if not os.path.isdir(yamlSourceDir):
        cmdUtils.runCommandInShell("mkdir -p " + yamlSourceDir)
    if singleFile:
        yamlFile = open(yamlSourceDir + "/sources_list.yaml", "w")
    listPackages = SPECS.getData().getListPackages()
    listPackages.sort()
    import PullSources
    for package in listPackages:
        if package in blackListPkgs:
            continue
        ossname = package
        for version in SPECS.getData().getVersions(package):
            modified = False
            listPatches = SPECS.getData().getPatches(package, version)
            if listPatches:
                modified = True
            url = SPECS.getData().getSourceURL(package, version)
            if url is None:
                url = SPECS.getData().getURL(package, version)

            sourceName = None
            listSourceNames = SPECS.getData().getSources(package, version)
            if listSourceNames:
                sourceName = listSourceNames[0]
                sha1 = SPECS.getData().getSHA1(package, version, sourceName)
                if sha1 is not None:
                    PullSources.get(package, sourceName, sha1, yamlSourceDir,
                                    constants.getPullSourcesURLs(package),
                                    logger)

            if not singleFile:
                yamlFile = open(yamlSourceDir + "/" + ossname + "-" + version + ".yaml", "w")
            yamlFile.write("vmwsource:" + ossname + ":" + version + ":\n")
            yamlFile.write("  repository: VMWsource\n")
            yamlFile.write("  name: '" + ossname + "'\n")
            yamlFile.write("  version: '" + version + "'\n")
            yamlFile.write("  url: " + str(url) + "\n")
            yamlFile.write("  license: UNKNOWN\n")
            if sourceName is not None:
                yamlFile.write("  vmwsource-distribution: " + str(sourceName) + "\n")
            if modified:
                yamlFile.write("  modified: true\n")
            yamlFile.write("\n")
            if not singleFile:
                yamlFile.close()

    if singleFile:
        yamlFile.close()
    logger.debug("Generated source yaml files for all packages")
开发者ID:vmware,项目名称:photon,代码行数:54,代码来源:GenerateOSSFiles.py

示例11: buildSRPMList

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
def buildSRPMList(srpmPath, yamlDir, blackListPkgs, dist_tag, logger, singleFile=True):
    cmdUtils = CommandUtils()
    yamlSrpmDir = os.path.join(yamlDir, "yaml_srpms")
    if not os.path.isdir(yamlSrpmDir):
        cmdUtils.runCommandInShell("mkdir -p " + yamlSrpmDir)
    if singleFile:
        yamlFile = open(yamlSrpmDir + "/srpm_list.yaml", "w")
    listPackages = SPECS.getData().getListPackages()
    listPackages.sort()
    for package in listPackages:
        if package in blackListPkgs:
            continue
        ossname = package
        for ossversion in SPECS.getData().getVersions(package):
            ossrelease = SPECS.getData().getRelease(package, ossversion)
            srpm_file_name = "%s-%s-%s%s.src.rpm" % (ossname, ossversion, ossrelease, dist_tag)
            logger.info("srpm name is %s" % (srpm_file_name))
            listFoundSRPMFiles = cmdUtils.findFile(srpm_file_name, srpmPath)

            srpmName = None
            if len(listFoundSRPMFiles) == 1:
                srpmFullPath = listFoundSRPMFiles[0]
                srpmName = os.path.basename(srpmFullPath)
                cpcmd = "cp " + srpmFullPath + " " + yamlSrpmDir + "/"
                returnVal = cmdUtils.runCommandInShell(cpcmd)
                if returnVal != 0:
                    logger.error("Copy SRPM File is failed for package:" + ossname)
            else:
                logger.error("SRPM file is not found:" + ossname)

            if not singleFile:
                yamlFile = open(yamlSrpmDir + "/" + ossname + "-" + ossversion + "-"
                                + ossrelease + ".yaml", "w")

            yamlFile.write("baseos:" + ossname + ":" + ossversion + "-" + ossrelease + dist_tag +  ":\n")
            yamlFile.write("  repository: BaseOS\n")
            yamlFile.write("  name: '" + ossname + "'\n")
            yamlFile.write("  version: '" + ossversion + "-" + ossrelease + dist_tag +"'\n")
            yamlFile.write("  url: 'http://www.vmware.com'\n")
            yamlFile.write("  baseos-style: rpm\n")
            yamlFile.write("  baseos-source: '" + str(srpmName) + "'\n")
            yamlFile.write("  baseos-osname: 'photon'\n")
            yamlFile.write("\n")
            if not singleFile:
                yamlFile.close()

    if singleFile:
        yamlFile.close()
    logger.debug("Generated SRPM yaml files for all packages")
开发者ID:vmware,项目名称:photon,代码行数:51,代码来源:GenerateOSSFiles.py

示例12: _copyRPM

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def _copyRPM(self, rpmFile, destDir):
     cmdUtils = CommandUtils()
     rpmName = os.path.basename(rpmFile)
     rpmDestDir = self._getRPMDestDir(rpmName, destDir)
     # shutil is not atomic. copy & move to ensure atomicity.
     rpmDestPath = rpmDestDir + "/" + rpmName
     rpmDestPathTemp = (rpmDestDir + "/." +
                        ''.join([random.choice(string.ascii_letters +
                                               string.digits) for n in range(10)]))
     if os.geteuid() == 0:
         if not os.path.isdir(rpmDestDir):
             cmdUtils.runCommandInShell("mkdir -p " + rpmDestDir)
         shutil.copyfile(rpmFile, rpmDestPathTemp)
         shutil.move(rpmDestPathTemp, rpmDestPath)
     return rpmDestPath
开发者ID:TiejunChina,项目名称:photon,代码行数:17,代码来源:PackageUtils.py

示例13: destroyChroot

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
 def destroyChroot(self,chrootID):
     # need to add timeout for this step
     # http://stackoverflow.com/questions/1191374/subprocess-with-timeout
     cmdUtils=CommandUtils()
     returnVal=cmdUtils.runCommandInShell("./cleanup-build-root.sh "+chrootID)
     if not returnVal:
         self.logger.error("Unable to destroy chroot:"+ chrootID +".Unknown error.")
         return False
     
     returnVal=cmdUtils.runCommandInShell("rm -rf "+chrootID)
     if not returnVal:
         self.logger.error("Unable to destroy chroot:"+ chrootID +".Unknown error.")
         return False
     self.logger.info("Successfully destroyed chroot:"+chrootID)
     return True
开发者ID:ericgray,项目名称:photon,代码行数:17,代码来源:ChrootUtils.py

示例14: installCustomToolChainRPMS

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
    def installCustomToolChainRPMS(self, chrootID, listOfToolChainPkgs, packageName):
        self.logger.info("Installing package specific tool chain RPMs for " + packageName +
                         ".......")
        rpmFiles = ""
        packages = ""
        cmdUtils = CommandUtils()
        for package in listOfToolChainPkgs:
            pkgUtils = PackageUtils(self.logName, self.logPath)
            print("DEBUG:" + package)
            if "openjre8" in packageName or "openjdk8" in packageName:
                # x86_64 has openjdk/jre as a published rpms but aarch64 has openjdk8/jre8
                # Remove this condition after publishxrpms for x86_^4 got updated
                if ((package == "openjdk" or package == "openjre") and
                        platform.machine() == "aarch64"):
                    package = package + "8"
                rpmFile = self.findRPMFileInGivenLocation(package, constants.prevPublishXRPMRepo)
            else:
                rpmFile = self.findRPMFileInGivenLocation(package, constants.prevPublishRPMRepo)
            if rpmFile is None:
                self.logger.error("Unable to find rpm "+ package +
                                  " in current and previous versions")
                raise Exception("Input Error")
            rpmFiles += " " + rpmFile
            packages += " " + package

        self.logger.debug("Installing custom rpms:" + packages)
        cmd = (self.rpmCommand + " -i -v --nodeps --noorder --force --root " +
               chrootID + " --define \'_dbpath /var/lib/rpm\' " + rpmFiles)
        retVal = cmdUtils.runCommandInShell(cmd, self.logPath +
                                            "/install_custom_toolchain_rpms.log")
        if not retVal:
            self.logger.debug("Command Executed:" + cmd)
            self.logger.error("Installing tool chain  failed")
            raise Exception("RPM installation failed")
        self.logger.info("Successfully installed all Tool Chain X RPMS")
开发者ID:vinaykul,项目名称:photon,代码行数:37,代码来源:ToolChainUtils.py

示例15: adjustGCCSpecs

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell [as 别名]
    def adjustGCCSpecs(self, package, chrootID, logPath):
        opt = ""
        # TODO: reading of hardening flag from spec files
        if package == "linux" or package == "glibc":
            opt = " clean"
        elif package.startswith("xf86-") or package.startswith("xorg-server") :
            opt = " nonow"

        shutil.copy2(self.adjustGCCSpecScript,  chrootID+"/tmp/"+self.adjustGCCSpecScript)
        cmdUtils=CommandUtils()
        cmd = "/tmp/"+self.adjustGCCSpecScript+opt
        logFile = logPath+"/adjustGCCSpecScript.log"
        chrootCmd=self.runInChrootCommand+" "+chrootID
        retryCount=10
        returnVal=False
        while retryCount > 0:
            returnVal = cmdUtils.runCommandInShell(cmd, logFile, chrootCmd)
            if returnVal:
                return
            self.logger.error("Failed while adjusting gcc specs")
            self.logger.error("Retrying again .....")
            retryCount = retryCount - 1
            sleep(5)
        if not returnVal:
            self.logger.error("Failed while adjusting gcc specs")
            raise "Failed while adjusting gcc specs"
开发者ID:gijs,项目名称:photon-1,代码行数:28,代码来源:PackageBuilder.py


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