本文整理汇总了Python中osclib.stagingapi.StagingAPI.load_file_content方法的典型用法代码示例。如果您正苦于以下问题:Python StagingAPI.load_file_content方法的具体用法?Python StagingAPI.load_file_content怎么用?Python StagingAPI.load_file_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osclib.stagingapi.StagingAPI
的用法示例。
在下文中一共展示了StagingAPI.load_file_content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ToTestBase
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import load_file_content [as 别名]
#.........这里部分代码省略.........
self.api.switch_flag_in_prj('openSUSE:%s:ToTest' % self.project, flag='publish', state='disable')
for product in self.ftp_products:
self.release_package('openSUSE:%s' % self.project, product)
for cd in self.livecd_products:
self.release_package('openSUSE:%s:Live' % self.project, cd, set_release='Snapshot%s' % snapshot)
for cd in self.main_products:
self.release_package('openSUSE:%s' % self.project, cd, set_release='Snapshot%s' % snapshot)
def publish_factory_totest(self):
logger.info('Publish ToTest')
if not self.dryrun:
self.api.switch_flag_in_prj('openSUSE:%s:ToTest' % self.project, flag='publish', state='enable')
def totest_is_publishing(self):
"""Find out if the publishing flag is set in totest's _meta"""
url = self.api.makeurl(['source', 'openSUSE:%s:ToTest' % self.project, '_meta'])
f = self.api.retried_GET(url)
root = ET.parse(f).getroot()
if not root.find('publish'): # default true
return True
for flag in root.find('publish'):
if flag.get('repository', None) or flag.get('arch', None):
continue
if flag.tag == 'enable':
return True
return False
def totest(self):
current_snapshot = self.get_current_snapshot()
new_snapshot = self.current_version()
current_result = self.overall_result(current_snapshot)
current_qa_version = self.api.load_file_content("%s:Staging" % self.api.project, "dashboard", "version_totest")
logger.info('current_snapshot %s: %s'%(current_snapshot, self._result2str(current_result)))
logger.debug('new_snapshot %s', new_snapshot)
logger.debug('current_qa_version %s', current_qa_version)
snapshotable = self.factory_snapshottable()
logger.debug("snapshotable: %s", snapshotable)
can_release = (current_result != QA_INPROGRESS and snapshotable)
# not overwriting
if new_snapshot == current_snapshot:
logger.debug("no change in snapshot version")
can_release = False
elif not self.all_repos_done('openSUSE:%s:ToTest' % self.project):
logger.debug("not all repos done, can't release")
# the repos have to be done, otherwise we better not touch them with a new release
can_release = False
can_publish = (current_result == QA_PASSED)
# already published
if self.totest_is_publishing():
logger.debug("totest already publishing")
can_publish = False
if can_publish:
if current_qa_version == current_snapshot:
self.publish_factory_totest()
self.write_version_to_dashboard("snapshot", current_snapshot)
can_release = False # we have to wait
else:
# We reached a very bad status: openQA testing is 'done', but not of the same version
# currently in :ToTest. This can happen when 'releasing' the product failed
raise Exception("Publishing stopped: tested version (%s) does not match :ToTest version (%s)"
% (current_qa_version, current_snapshot))
if can_release:
self.update_totest(new_snapshot)
self.write_version_to_dashboard("totest", new_snapshot)
def release(self):
new_snapshot = self.current_version()
self.update_totest(new_snapshot)
def known_failures_from_dashboard(self, project):
known_failures = []
if self.project == "Factory:PowerPC":
project = "Factory"
else:
project = self.project
url = self.api.makeurl(['source', 'openSUSE:%s:Staging' % project, 'dashboard', 'known_failures'])
f = self.api.retried_GET(url)
for line in f:
if not line[0] == '#':
known_failures.append(line.strip())
return known_failures
def write_version_to_dashboard(self, target, version):
if not self.dryrun:
url = self.api.makeurl(['source', 'openSUSE:%s:Staging' % self.project, 'dashboard', 'version_%s' % target])
osc.core.http_PUT(url + '?comment=Update+version', data=version)
示例2: do_staging
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import load_file_content [as 别名]
def do_staging(self, subcmd, opts, *args):
"""${cmd_name}: Commands to work with staging projects
${cmd_option_list}
"accept" will accept all requests in
openSUSE:Factory:Staging:<LETTER> (into Factory)
"acheck" will check if it's safe to accept new staging projects
As openSUSE:Factory is syncing the right package versions between
/standard, /totest and /snapshot, it's important that the projects
are clean prior to a checkin round.
"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)
"frozenage" will show when the respective staging project was last frozen
"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 [--force] [LETTER...]
osc staging check [--old] REPO
osc staging cleanup_rings
osc staging freeze [--no-boostrap] PROJECT...
osc staging frozenage PROJECT...
osc staging list [--supersede]
osc staging select [--no-freeze] [--move [--from PROJECT]] LETTER REQUEST...
osc staging unselect REQUEST...
osc staging repair 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 ("freeze", "frozenage", "repair"):
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", "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")
#.........这里部分代码省略.........