本文整理汇总了Python中StringUtils.StringUtils.splitPackageNameAndVersion方法的典型用法代码示例。如果您正苦于以下问题:Python StringUtils.splitPackageNameAndVersion方法的具体用法?Python StringUtils.splitPackageNameAndVersion怎么用?Python StringUtils.splitPackageNameAndVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtils.StringUtils
的用法示例。
在下文中一共展示了StringUtils.splitPackageNameAndVersion方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _buildPackage
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def _buildPackage(self):
try:
self.sandbox.create(self.package + "-" + self.version)
tUtils = ToolChainUtils(self.logName, self.logPath)
if self.sandbox.hasToolchain():
tUtils.installExtraToolchainRPMS(self.sandbox, self.package, self.version)
else:
tUtils.installToolchainRPMS(self.sandbox, self.package, self.version, availablePackages=self.doneList)
listDependentPackages, listTestPackages, listInstalledPackages, listInstalledRPMs = (
self._findDependentPackagesAndInstalledRPM(self.sandbox))
pkgUtils = PackageUtils(self.logName, self.logPath)
if listDependentPackages:
self.logger.debug("Installing the build time dependent packages......")
for pkg in listDependentPackages:
packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
self._installPackage(pkgUtils, packageName, packageVersion, self.sandbox, self.logPath,listInstalledPackages, listInstalledRPMs)
for pkg in listTestPackages:
flag = False
packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
for depPkg in listDependentPackages:
depPackageName, depPackageVersion = StringUtils.splitPackageNameAndVersion(depPkg)
if depPackageName == packageName:
flag = True
break;
if flag == False:
self._installPackage(pkgUtils, packageName,packageVersion, self.sandbox, self.logPath,listInstalledPackages, listInstalledRPMs)
pkgUtils.installRPMSInOneShot(self.sandbox)
self.logger.debug("Finished installing the build time dependent packages....")
pkgUtils.adjustGCCSpecs(self.sandbox, self.package, self.version)
pkgUtils.buildRPMSForGivenPackage(self.sandbox, self.package, self.version,
self.logPath)
self.logger.debug("Successfully built the package: " + self.package)
except Exception as e:
self.logger.error("Failed while building package: " + self.package)
self.logger.debug("Sandbox: " + self.sandbox.getID() +
" not deleted for debugging.")
logFileName = os.path.join(self.logPath, self.package + ".log")
fileLog = os.popen('tail -n 100 ' + logFileName).read()
self.logger.info(fileLog)
raise e
if self.sandbox:
self.sandbox.destroy()
示例2: _getWeight
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def _getWeight(package):
# Package weights are assumed to be independent of package
# version (i.e., in the case of multi-version packages such as
# Go or Kubernetes, all the versions have the same weight). So
# convert packageName-version to packageName before looking up
# the package weight.
package, _ = StringUtils.splitPackageNameAndVersion(package)
try:
return int(Scheduler.pkgWeights[package]) + 1
except KeyError:
return 1
示例3: _installDependentRunTimePackages
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def _installDependentRunTimePackages(self, pkgUtils, package, packageVersion, sandbox, destLogPath,
listInstalledPackages, listInstalledRPMs):
listRunTimeDependentPackages = self._findRunTimeRequiredRPMPackages(package, packageVersion)
if listRunTimeDependentPackages:
for pkg in listRunTimeDependentPackages:
if pkg in self.mapPackageToCycles:
continue
packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
rpmfile = pkgUtils.findRPMFile(packageName, packageVersion)
if rpmfile is None:
self.logger.error("No rpm file found for package: " + packageName + "-" + packageVersion)
raise Exception("Missing rpm file")
latestPkgRPM = os.path.basename(rpmfile).replace(".rpm", "")
if pkg in listInstalledPackages and latestPkgRPM in listInstalledRPMs:
continue
self._installPackage(pkgUtils, packageName,packageVersion, sandbox, destLogPath,listInstalledPackages, listInstalledRPMs)
示例4: build
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def build(self, pkg, doneList):
packageName, packageVersion = StringUtils.splitPackageNameAndVersion(pkg)
#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 not constants.rpmCheck or packageName in constants.testForceRPMS:
if self._checkIfPackageIsAlreadyBuilt(packageName, packageVersion, doneList):
return
self._buildPackagePrepareFunction(packageName, packageVersion, doneList)
try:
self._buildPackage()
except Exception as e:
# TODO: self.logger might be None
self.logger.exception(e)
raise e
示例5: _createGraphNodes
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def _createGraphNodes():
# GRAPH-BUILD STEP 1: Initialize graph nodes for each package.
#
# Create a graph with a node to represent every package and all
# its dependent packages in the given list.
for package in Scheduler.sortedList:
packageName, packageVersion = StringUtils.splitPackageNameAndVersion(package)
node = DependencyGraphNode(packageName, packageVersion,
Scheduler._getWeight(package))
Scheduler.mapPackagesToGraphNodes[package] = node
for package in Scheduler.sortedList:
pkgNode = Scheduler.mapPackagesToGraphNodes[package]
for childPackage in Scheduler._getBuildRequiredPackages(package):
childPkgNode = Scheduler.mapPackagesToGraphNodes[childPackage]
pkgNode.buildRequiresPkgNodes.add(childPkgNode)
for childPackage in Scheduler._getRequiredPackages(package):
childPkgNode = Scheduler.mapPackagesToGraphNodes[childPackage]
pkgNode.installRequiresPkgNodes.add(childPkgNode)
# GRAPH-BUILD STEP 2: Mark package dependencies in the graph.
#
# Add parent-child relationships between dependent packages.
# If a package 'A' build-requires or install-requires package 'B', then:
# - Mark 'B' as a child of 'A' in the graph.
# - Mark 'A' as a parent of 'B' in the graph.
#
# A
#
# / \
# v v
#
# B C
#
for package in Scheduler.sortedList:
pkgNode = Scheduler.mapPackagesToGraphNodes[package]
for childPkgNode in pkgNode.buildRequiresPkgNodes:
pkgNode.childPkgNodes.add(childPkgNode)
childPkgNode.parentPkgNodes.add(pkgNode)
for childPkgNode in pkgNode.installRequiresPkgNodes:
pkgNode.childPkgNodes.add(childPkgNode)
childPkgNode.parentPkgNodes.add(pkgNode)
示例6: main
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def main():
usage = "Usage: %prog [options]"
parser = ArgumentParser(usage)
parser.add_argument("-i", "--input-type", dest="input_type", default=DEFAULT_INPUT_TYPE)
parser.add_argument("-p", "--pkg", dest="pkg")
parser.add_argument("-f", "--file", dest="json_file", default="packages_minimal.json")
parser.add_argument("-d", "--display-option", dest="display_option", default=DEFAULT_DISPLAY_OPTION)
parser.add_argument("-s", "--spec-path", dest="spec_path", default=SPEC_FILE_DIR)
parser.add_argument("-l", "--log-path", dest="log_path", default=LOG_FILE_DIR)
parser.add_argument("-y", "--log-level", dest="log_level", default="info")
parser.add_argument("-t", "--stage-dir", dest="stage_dir", default="../../stage")
parser.add_argument("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/")
parser.add_argument("-o", "--output-dir", dest="output_dir", default="../../stage/common/data")
options = parser.parse_args()
constants.setSpecPath(options.spec_path)
constants.setLogPath(options.log_path)
constants.setLogLevel(options.log_level)
constants.initialize()
cmdUtils = CommandUtils()
logger = Logger.getLogger("SpecDeps", options.log_path, options.log_level)
if not os.path.isdir(options.output_dir):
cmdUtils.runCommandInShell("mkdir -p "+options.output_dir)
if not options.input_data_dir.endswith('/'):
options.input_data_dir += '/'
try:
specDeps = SpecDependencyGenerator(options.log_path, options.log_level)
if options.input_type == "remove-upward-deps":
isToolChainPkg = specDeps.process("is-toolchain-pkg", options.pkg, options.display_option)
if isToolChainPkg:
logger.info("Removing all staged RPMs since toolchain packages were modified")
cmdUtils.runCommandInShell("rm -rf stage/RPMS/")
else:
whoNeedsList = specDeps.process("get-upward-deps", options.pkg, options.display_option)
logger.info("Removing upward dependencies: " + str(whoNeedsList))
for pkg in whoNeedsList:
package, version = StringUtils.splitPackageNameAndVersion(pkg)
release = SPECS.getData().getRelease(package, version)
for p in SPECS.getData().getPackages(package,version):
buildarch=SPECS.getData().getBuildArch(p, version)
rpmFile = "stage/RPMS/" + buildarch + "/" + p + "-" + version + "-" + release + ".*" + buildarch+".rpm"
cmdUtils.runCommandInShell("rm -f "+rpmFile)
elif options.input_type == "print-upward-deps":
whoNeedsList = specDeps.process("get-upward-deps", options.pkg, options.display_option)
logger.info("Upward dependencies: " + str(whoNeedsList))
# To display/print package dependencies on console
elif (options.input_type == "pkg" or
options.input_type == "who-needs"):
specDeps.process(options.input_type, options.pkg, options.display_option)
elif options.input_type == "json":
list_json_files = options.json_file.split("\n")
# Generate the expanded package dependencies json file based on package_list_file
logger.info("Generating the install time dependency list for all json files")
if list_json_files:
shutil.copy2(os.path.dirname(list_json_files[0]) + "/build_install_options_all.json", options.output_dir)
for json_file in list_json_files:
output_file = None
if options.display_option == "json":
output_file = os.path.join(options.output_dir, os.path.basename(json_file))
specDeps.process(options.input_type, json_file, options.display_option, output_file)
except Exception as e:
traceback.print_exc()
sys.stderr.write(str(e))
sys.stderr.write("Failed to generate dependency lists from spec files\n")
sys.exit(1)
sys.exit(0)
示例7: getBasePkg
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def getBasePkg(self, pkg):
package, version = StringUtils.splitPackageNameAndVersion(pkg)
return self.getSpecName(package)+"-"+version
示例8: getPackagesForPkg
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def getPackagesForPkg(self, pkg):
pkgs=[]
package, version = StringUtils.splitPackageNameAndVersion(pkg)
for p in self.getPackages(package, version):
pkgs.append(p+"-"+version)
return pkgs
示例9: getRequiresForPkg
# 需要导入模块: from StringUtils import StringUtils [as 别名]
# 或者: from StringUtils.StringUtils import splitPackageNameAndVersion [as 别名]
def getRequiresForPkg(self, pkg):
package, version = StringUtils.splitPackageNameAndVersion(pkg)
return self.getRequiresForPackage(package, version)