本文整理汇总了Python中osclib.stagingapi.StagingAPI.item_exists方法的典型用法代码示例。如果您正苦于以下问题:Python StagingAPI.item_exists方法的具体用法?Python StagingAPI.item_exists怎么用?Python StagingAPI.item_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osclib.stagingapi.StagingAPI
的用法示例。
在下文中一共展示了StagingAPI.item_exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_staging
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import item_exists [as 别名]
def do_staging(self, subcmd, opts, *args):
"""${cmd_name}: Commands to work with staging projects
"accept" will accept all requests in
openSUSE:Factory:Staging:<LETTER> (into Factory)
"check" will check if all packages are links without changes
"cleanup_rings" will try to cleanup rings content and print
out problems
"freeze" will freeze the sources of the project's links (not
affecting the packages actually in)
"list" will pick the requests not in rings
"select" will add requests to the project
"unselect" will remove from the project - pushing them back to the backlog
Usage:
osc staging accept LETTER
osc staging check [--old] REPO
osc staging cleanup_rings
osc staging freeze PROJECT...
osc staging list
osc staging select [--no-freeze] [--move [--from PROJECT]] LETTER REQUEST...
osc staging unselect REQUEST...
"""
if opts.version:
self._print_version()
# verify the argument counts match the commands
if len(args) == 0:
raise oscerr.WrongArgs('No command given, see "osc help staging"!')
cmd = args[0]
if cmd in ('accept', 'freeze'):
min_args, max_args = 1, None
elif cmd == 'check':
min_args, max_args = 0, 2
elif cmd == 'select':
min_args, max_args = 1, None
if not opts.add:
min_args = 2
elif cmd == 'unselect':
min_args, max_args = 1, None
elif cmd == 'adi':
min_args, max_args = None, None
elif cmd in ('list', 'cleanup_rings'):
min_args, max_args = 0, 0
else:
raise oscerr.WrongArgs('Unknown command: %s' % cmd)
if len(args) - 1 < min_args:
raise oscerr.WrongArgs('Too few arguments.')
if max_args is not None and len(args) - 1 > max_args:
raise oscerr.WrongArgs('Too many arguments.')
# Init the OBS access and configuration
opts.project = self._full_project_name(opts.project)
opts.apiurl = self.get_api_url()
opts.verbose = False
Config(opts.project)
with OBSLock(opts.apiurl, opts.project):
api = StagingAPI(opts.apiurl, opts.project)
# call the respective command and parse args by need
if cmd == 'check':
prj = args[1] if len(args) > 1 else None
CheckCommand(api).perform(prj, opts.old)
elif cmd == 'freeze':
for prj in args[1:]:
FreezeCommand(api).perform(api.prj_from_letter(prj))
elif cmd == 'accept':
cmd = AcceptCommand(api)
for prj in args[1:]:
if not cmd.perform(api.prj_from_letter(prj)):
return
cmd.accept_other_new()
cmd.update_factory_version()
if api.item_exists(api.crebuild):
cmd.sync_buildfailures()
elif cmd == 'unselect':
UnselectCommand(api).perform(args[1:])
elif cmd == 'select':
tprj = api.prj_from_letter(args[1])
if opts.add:
api.mark_additional_packages(tprj, [opts.add])
else:
SelectCommand(api, tprj).perform(args[2:], opts.move,
opts.from_, opts.no_freeze)
elif cmd == 'cleanup_rings':
CleanupRings(api).perform()
elif cmd == 'list':
ListCommand(api).perform()
elif cmd == 'adi':
AdiCommand(api).perform(args[1:])
示例2: do_staging
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import item_exists [as 别名]
#.........这里部分代码省略.........
print('{} last frozen {}{:.1f} days ago'.format(
Fore.YELLOW + prj + Fore.RESET,
Fore.GREEN if api.prj_frozen_enough(prj) else Fore.RED,
api.days_since_last_freeze(prj)))
elif cmd == 'acheck':
# Is it safe to accept? Meaning: /totest contains what it should and is not dirty
version_totest = api.get_binary_version(api.project, "openSUSE-release.rpm", repository="totest", arch="x86_64")
if version_totest:
version_openqa = api.pseudometa_file_load('version_totest')
totest_dirty = api.is_repo_dirty(api.project, 'totest')
print("version_openqa: %s / version_totest: %s / totest_dirty: %s\n" % (version_openqa, version_totest, totest_dirty))
else:
print("acheck is unavailable in %s!\n" % (api.project))
elif cmd == 'accept':
# Is it safe to accept? Meaning: /totest contains what it should and is not dirty
version_totest = api.get_binary_version(api.project, "openSUSE-release.rpm", repository="totest", arch="x86_64")
if version_totest is None or opts.force:
# SLE does not have a totest_version or openqa_version - ignore it
version_openqa = version_totest
totest_dirty = False
else:
version_openqa = api.pseudometa_file_load('version_totest')
totest_dirty = api.is_repo_dirty(api.project, 'totest')
if version_openqa == version_totest and not totest_dirty:
cmd = AcceptCommand(api)
for prj in args[1:]:
if cmd.perform(api.prj_from_letter(prj), opts.force):
cmd.reset_rebuild_data(prj)
else:
return
if not opts.no_cleanup:
if api.item_exists(api.prj_from_letter(prj)):
cmd.cleanup(api.prj_from_letter(prj))
cmd.accept_other_new()
if opts.project.startswith('openSUSE:'):
cmd.update_factory_version()
if api.item_exists(api.crebuild):
cmd.sync_buildfailures()
else:
print("Not safe to accept: /totest is not yet synced")
elif cmd == 'unselect':
if opts.message:
print('Ignoring requests first')
IgnoreCommand(api).perform(args[1:], opts.message)
UnselectCommand(api).perform(args[1:], opts.cleanup)
elif cmd == 'select':
# Include list of all stagings in short-hand and by full name.
existing_stagings = api.get_staging_projects_short(None)
existing_stagings += api.get_staging_projects()
stagings = []
requests = []
for arg in args[1:]:
# Since requests may be given by either request ID or package
# name and stagings may include multi-letter special stagings
# there is no easy way to distinguish between stagings and
# requests in arguments. Therefore, check if argument is in the
# list of short-hand and full project name stagings, otherwise
# consider it a request. This also allows for special stagings
# with the same name as package, but the staging will be assumed
# first time around. The current practice seems to be to start a
# special staging with a capital letter which makes them unique.
# lastly adi stagings are consistently prefix with adi: which
# also makes it consistent to distinguish them from request IDs.
if arg in existing_stagings and arg not in stagings:
示例3: do_staging
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import item_exists [as 别名]
#.........这里部分代码省略.........
min_args = 2
elif cmd == "unselect":
min_args, max_args = 1, None
elif cmd == "adi":
min_args, max_args = None, None
elif cmd in ("list", "accept"):
min_args, max_args = 0, None
elif cmd in ("cleanup_rings", "acheck"):
min_args, max_args = 0, 0
else:
raise oscerr.WrongArgs("Unknown command: %s" % cmd)
if len(args) - 1 < min_args:
raise oscerr.WrongArgs("Too few arguments.")
if max_args is not None and len(args) - 1 > max_args:
raise oscerr.WrongArgs("Too many arguments.")
# Init the OBS access and configuration
opts.project = self._full_project_name(opts.project)
opts.apiurl = self.get_api_url()
opts.verbose = False
Config(opts.project)
with OBSLock(opts.apiurl, opts.project):
api = StagingAPI(opts.apiurl, opts.project)
# call the respective command and parse args by need
if cmd == "check":
prj = args[1] if len(args) > 1 else None
CheckCommand(api).perform(prj, opts.old)
elif cmd == "freeze":
for prj in args[1:]:
FreezeCommand(api).perform(api.prj_from_letter(prj), copy_bootstrap=opts.bootstrap)
elif cmd == "frozenage":
for prj in args[1:]:
print "%s last frozen %0.1f days ago" % (
api.prj_from_letter(prj),
api.days_since_last_freeze(api.prj_from_letter(prj)),
)
elif cmd == "acheck":
# Is it safe to accept? Meaning: /totest contains what it should and is not dirty
version_totest = api.get_binary_version(
api.project, "openSUSE-release.rpm", repository="totest", arch="x86_64"
)
if version_totest:
version_openqa = api.load_file_content("%s:Staging" % api.project, "dashboard", "version_totest")
totest_dirty = api.is_repo_dirty(api.project, "totest")
print "version_openqa: %s / version_totest: %s / totest_dirty: %s\n" % (
version_openqa,
version_totest,
totest_dirty,
)
else:
print "acheck is unavailable in %s!\n" % (api.project)
elif cmd == "accept":
# Is it safe to accept? Meaning: /totest contains what it should and is not dirty
version_totest = api.get_binary_version(
api.project, "openSUSE-release.rpm", repository="totest", arch="x86_64"
)
if version_totest is None or opts.force:
# SLE does not have a totest_version or openqa_version - ignore it
version_openqa = version_totest
totest_dirty = False
else:
version_openqa = api.load_file_content("%s:Staging" % api.project, "dashboard", "version_totest")
totest_dirty = api.is_repo_dirty(api.project, "totest")
if version_openqa == version_totest and not totest_dirty:
cmd = AcceptCommand(api)
for prj in args[1:]:
if not cmd.perform(api.prj_from_letter(prj), opts.force):
return
if not opts.no_cleanup:
if api.item_exists(api.prj_from_letter(prj)):
cmd.cleanup(api.prj_from_letter(prj))
if api.item_exists("%s:DVD" % api.prj_from_letter(prj)):
cmd.cleanup("%s:DVD" % api.prj_from_letter(prj))
if opts.project.startswith("openSUSE:"):
cmd.accept_other_new()
cmd.update_factory_version()
if api.item_exists(api.crebuild):
cmd.sync_buildfailures()
else:
print "Not safe to accept: /totest is not yet synced"
elif cmd == "unselect":
UnselectCommand(api).perform(args[1:])
elif cmd == "select":
tprj = api.prj_from_letter(args[1])
if opts.add:
api.mark_additional_packages(tprj, [opts.add])
else:
SelectCommand(api, tprj).perform(args[2:], opts.move, opts.from_, opts.no_freeze)
elif cmd == "cleanup_rings":
CleanupRings(api).perform()
elif cmd == "list":
ListCommand(api).perform(args[1:], supersede=opts.supersede)
elif cmd == "adi":
AdiCommand(api).perform(args[1:], move=opts.move, by_dp=opts.by_develproject, split=opts.split)
elif cmd == "repair":
RepairCommand(api).perform(args[1:])