本文整理汇总了Python中package.Package.url方法的典型用法代码示例。如果您正苦于以下问题:Python Package.url方法的具体用法?Python Package.url怎么用?Python Package.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类package.Package
的用法示例。
在下文中一共展示了Package.url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from package import Package [as 别名]
# 或者: from package.Package import url [as 别名]
def main():
# use the main mirror
gnome_ftp = 'http://ftp.gnome.org/pub/GNOME/sources'
# read defaults from command line arguments
parser = argparse.ArgumentParser(description='Automatically build Fedora packages for a GNOME release')
parser.add_argument('--fedora-branch', default="rawhide", help='The fedora release to target (default: rawhide)')
parser.add_argument('--simulate', action='store_true', help='Do not commit any changes')
parser.add_argument('--check-installed', action='store_true', help='Check installed version against built version')
parser.add_argument('--force-build', action='store_true', help='Always build even when not newer')
parser.add_argument('--relax-version-checks', action='store_true', help='Relax checks on the version numbering')
parser.add_argument('--cache', default="cache", help='The cache of checked out packages')
parser.add_argument('--buildone', default=None, help='Only build one specific package')
parser.add_argument('--buildroot', default=None, help='Use a custom buildroot, e.g. f18-gnome')
parser.add_argument('--bump-soname', default=None, help='Build any package that deps on this')
parser.add_argument('--copr-id', default=None, help='The COPR to optionally use')
args = parser.parse_args()
if args.copr_id:
copr = CoprHelper(args.copr_id)
# create the cache directory if it's not already existing
if not os.path.isdir(args.cache):
os.mkdir(args.cache)
# use rpm to check the installed version
installed_pkgs = {}
if args.check_installed:
print_info("Loading rpmdb")
ts = rpm.TransactionSet()
mi = ts.dbMatch()
for h in mi:
installed_pkgs[h['name']] = h['version']
print_debug("Loaded rpmdb with %i items" % len(installed_pkgs))
# parse the configuration file
modules = []
data = ModulesXml('modules.xml')
if not args.buildone:
print_debug("Depsolving moduleset...")
if not data.depsolve():
print_fail("Failed to depsolve")
return
for item in data.items:
# ignore just this one module
if item.disabled:
continue
# build just one module
if args.buildone:
if args.buildone != item.name:
continue
# just things that have this as a dep
if args.bump_soname:
if args.bump_soname not in item.deps:
continue
# things we can't autobuild as we don't have upstream data files
if not item.ftpadmin:
continue
# things that are obsolete in later versions
if args.copr_id:
if not args.copr_id[10:] in item.branches:
continue
# get started
print_info("Loading %s" % item.name)
if item.pkgname != item.name:
print_debug("Package name: %s" % item.pkgname)
print_debug("Version glob: %s" % item.release_glob[args.fedora_branch])
# ensure package is checked out
if not item.setup_pkgdir(args.cache, args.fedora_branch):
continue
# get the current version from the spec file
if not item.parse_spec():
continue
print_debug("Current version is %s" % item.version)
# check for newer version on GNOME.org
success = False
for i in range (1, 20):
try:
urllib.urlretrieve ("%s/%s/cache.json" % (gnome_ftp, item.name), "%s/%s/cache.json" % (args.cache, item.pkgname))
success = True
break
except IOError as e:
print_fail("Failed to get JSON on try %i: %s" % (i, e))
if not success:
continue
new_version = None
gnome_branch = item.release_glob[args.fedora_branch]
local_json_file = "%s/%s/cache.json" % (args.cache, item.pkgname)
#.........这里部分代码省略.........
示例2: main
# 需要导入模块: from package import Package [as 别名]
# 或者: from package.Package import url [as 别名]
def main():
parser = argparse.ArgumentParser(description='Build a list of packages')
parser.add_argument('--branch-source', default="f21", help='The branch to use as a source')
parser.add_argument('--copr-id', default="el7-gnome-3-14", help='The COPR to use')
parser.add_argument('--packages', default="./data/el7-gnome-3-14.txt", help='the list if packages to build')
args = parser.parse_args()
copr = CoprHelper(args.copr_id)
koji = KojiHelper()
data = ModulesXml('modules.xml')
# add the copr id (e.g. el7) to any items in modules.xml file
f = open(args.packages, 'r')
for l in f.readlines():
if l.startswith('#'):
continue
if l.startswith('\n'):
continue
linedata = l.strip().split(',')
pkgname = linedata[0]
item = data._get_item_by_pkgname(pkgname)
if not item:
print("%s not found" % pkgname)
continue
item.releases.append(copr.release)
item.custom_package_url = None
if len(linedata) > 1:
item.custom_package_url = linedata[1]
f.close()
# disable any modules without the copr-specific release
for item in data.items:
if copr.release not in item.releases:
item.disabled = True
continue
# depsolve
print_debug("Depsolving moduleset...")
if not data.depsolve():
print_fail("Failed to depsolve")
return
# process all packages
current_depsolve_level = 0
for item in data.items:
if item.disabled:
continue;
# wait for builds
if current_depsolve_level != item.depsolve_level:
rc = copr.wait_for_builds()
if not rc:
print_fail("A build failed, so aborting")
break
current_depsolve_level = item.depsolve_level
print_debug("Now running depsolve level %i" % current_depsolve_level)
# find the koji package
pkg = None
if not item.custom_package_url:
pkg = koji.get_newest_build(args.branch_source, item.pkgname)
if not pkg:
print_fail("package %s does not exists in koji" % item.pkgname)
continue
pkg2 = koji.get_newest_build(args.branch_source + '-updates-candidate', item.pkgname)
if not pkg2:
print_fail("package %s does not exists in koji" % item.pkgname)
continue
# use the newest package
if pkg.get_nvr() != pkg2.get_nvr():
if rpm.labelCompare(pkg.get_evr(), pkg2.get_evr()) < 0:
pkg = pkg2;
else:
pkg = Package()
nvr = os.path.basename(item.custom_package_url).rsplit('-', 2)
pkg.name = nvr[0]
pkg.version = nvr[1]
pkg.release = nvr[2].replace('.src.rpm', '')
pkg.url = item.custom_package_url
print_debug("Latest version of %s: %s" % (item.pkgname, pkg.get_nvr()))
# find if the package has been built in the copr
try:
status = copr.get_pkg_status(pkg)
except CoprException, e:
print_fail(str(e))
continue
if status == CoprBuildStatus.ALREADY_BUILT:
print_debug("Already built")
continue
elif status == CoprBuildStatus.FAILED_TO_BUILD:
print_debug("Failed, so retrying build")
elif status == CoprBuildStatus.NOT_FOUND:
print_debug("Not found, so building")
elif status == CoprBuildStatus.IN_PROGRESS:
print_debug("Already in progress")
#.........这里部分代码省略.........