本文整理汇总了Python中osclib.stagingapi.StagingAPI.pseudometa_file_load方法的典型用法代码示例。如果您正苦于以下问题:Python StagingAPI.pseudometa_file_load方法的具体用法?Python StagingAPI.pseudometa_file_load怎么用?Python StagingAPI.pseudometa_file_load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osclib.stagingapi.StagingAPI
的用法示例。
在下文中一共展示了StagingAPI.pseudometa_file_load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ToTestManager
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import pseudometa_file_load [as 别名]
class ToTestManager(ToolBase.ToolBase):
def __init__(self, tool):
ToolBase.ToolBase.__init__(self)
# copy attributes
self.logger = logging.getLogger(__name__)
self.apiurl = tool.apiurl
self.debug = tool.debug
self.caching = tool.caching
self.dryrun = tool.dryrun
def setup(self, project):
self.project = ToTest(project, self.apiurl)
self.api = StagingAPI(self.apiurl, project=project)
def version_file(self, target):
return 'version_%s' % target
def write_version_to_dashboard(self, target, version):
if self.dryrun or self.project.do_not_release:
return
self.api.pseudometa_file_ensure(self.version_file(target), version,
comment='Update version')
def current_qa_version(self):
return self.api.pseudometa_file_load(self.version_file('totest'))
def iso_build_version(self, project, tree, repo=None, arch=None):
for binary in self.binaries_of_product(project, tree, repo=repo, arch=arch):
result = re.match(r'.*-(?:Build|Snapshot)([0-9.]+)(?:-Media.*\.iso|\.docker\.tar\.xz|\.raw\.xz)', binary)
if result:
return result.group(1)
raise NotFoundException("can't find %s iso version" % project)
def version_from_totest_project(self):
if len(self.project.main_products):
return self.iso_build_version(self.project.test_project, self.project.main_products[0])
return self.iso_build_version(self.project.test_project, self.project.image_products[0].package,
arch=self.project.image_products[0].archs[0])
def binaries_of_product(self, project, product, repo=None, arch=None):
if repo is None:
repo = self.project.product_repo
if arch is None:
arch = self.project.product_arch
url = self.api.makeurl(['build', project, repo, arch, product])
try:
f = self.api.retried_GET(url)
except HTTPError:
return []
ret = []
root = ET.parse(f).getroot()
for binary in root.findall('binary'):
ret.append(binary.get('filename'))
return ret
def ftp_build_version(self, project, tree):
for binary in self.binaries_of_product(project, tree):
result = re.match(r'.*-Build(.*)-Media1.report', binary)
if result:
return result.group(1)
raise NotFoundException("can't find %s ftp version" % project)
# make sure to update the attribute as atomic as possible - as such
# only update the snapshot and don't erase anything else. The snapshots
# have very different update times within the pipeline, so there is
# normally no chance that releaser and publisher overwrite states
def update_status(self, status, snapshot):
status_dict = self.get_status_dict()
if self.dryrun:
self.logger.info('setting {} snapshot to {}'.format(status, snapshot))
return
if status_dict.get(status) != snapshot:
status_dict[status] = snapshot
text = yaml.safe_dump(status_dict)
self.api.attribute_value_save('ToTestManagerStatus', text)
def get_status_dict(self):
text = self.api.attribute_value_load('ToTestManagerStatus')
if text:
return yaml.safe_load(text)
return dict()
def get_status(self, status):
return self.get_status_dict().get(status)
def release_package(self, project, package, set_release=None, repository=None,
target_project=None, target_repository=None):
query = {'cmd': 'release'}
if set_release:
query['setrelease'] = set_release
if repository is not None:
query['repository'] = repository
#.........这里部分代码省略.........
示例2: do_staging
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import pseudometa_file_load [as 别名]
#.........这里部分代码省略.........
stagings = api.get_staging_projects_short(None) + \
api.get_staging_projects()
for arg in args[1:]:
if arg in stagings:
projects.add(api.prj_from_short(arg))
elif key is None:
key = arg
elif value is None:
value = arg
else:
value += ' ' + arg
if not len(projects):
projects = api.get_staging_projects()
ConfigCommand(api).perform(projects, key, value, opts.append, opts.clear)
elif cmd == 'freeze':
for prj in args[1:]:
prj = api.prj_from_short(prj)
print(Fore.YELLOW + prj)
FreezeCommand(api).perform(prj, copy_bootstrap=opts.bootstrap)
elif cmd == 'frozenage':
projects = api.get_staging_projects_short() if len(args) == 1 else args[1:]
for prj in projects:
prj = api.prj_from_letter(prj)
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:
示例3: StagingHelper
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import pseudometa_file_load [as 别名]
class StagingHelper(object):
def __init__(self, project):
self.project = project
self.apiurl = osc.conf.config['apiurl']
Config(self.apiurl, self.project)
self.api = StagingAPI(self.apiurl, self.project)
def get_support_package_list(self, project, repository):
f = osc.core.get_buildconfig(self.apiurl, project, repository).splitlines()
pkg_list = []
for line in f:
if re.match('Preinstall', line) or re.match('VM[Ii]nstall', line) or re.match('Support', line):
content = line.split(':')
variables = [x.strip() for x in content[1].split(' ')]
for var in variables:
if var != '' and var not in pkg_list:
if var.startswith('!') and var[1:] in pkg_list:
pkg_list.remove(var[1:])
else:
pkg_list.append(var)
return pkg_list
def get_project_binarylist(self, project, repository, arch):
query = {'view': 'binaryversions'}
root = ET.parse(http_GET(makeurl(self.apiurl, ['build', project, repository, arch],
query=query))).getroot()
return root
def process_project_binarylist(self, project, repository, arch):
prj_binarylist = self.get_project_binarylist(project, repository, arch)
files = {}
for package in prj_binarylist.findall('./binaryversionlist'):
for binary in package.findall('binary'):
result = re.match(r'(.*)-([^-]*)-([^-]*)\.([^-\.]+)\.rpm', binary.attrib['name'])
if not result:
continue
bname = result.group(1)
if bname.endswith('-debuginfo') or bname.endswith('-debuginfo-32bit'):
continue
if bname.endswith('-debugsource'):
continue
if bname.startswith('::import::'):
continue
if result.group(4) == 'src':
continue
files[bname] = package.attrib['package'].split(':', 1)[0]
return files
def check_multiple_specs(self, project, packages):
expanded_packages = []
for pkg in packages:
query = {'expand': 1}
url = makeurl(self.apiurl, ['source', project, pkg], query=query)
try:
root = ET.parse(http_GET(url)).getroot()
except HTTPError as e:
if e.code == 404:
continue
raise
for en in root.findall('entry'):
if en.attrib['name'].endswith('.spec'):
expanded_packages.append(en.attrib['name'][:-5])
return expanded_packages
def crawl(self):
"""Main method"""
rebuild_data = self.api.pseudometa_file_load('support_pkg_rebuild')
if rebuild_data is None:
print("There is no support_pkg_rebuild file!")
return
logging.info('Gathering support package list from %s' % self.project)
support_pkgs = self.get_support_package_list(self.project, 'standard')
files = self.process_project_binarylist(self.project, 'standard', 'x86_64')
staging_projects = ["%s:%s"%(self.api.cstaging, p) for p in self.api.get_staging_projects_short()]
cand_sources = defaultdict(list)
for stg in staging_projects:
prj_meta = self.api.get_prj_pseudometa(stg)
prj_staged_packages = [req['package'] for req in prj_meta['requests']]
prj_expanded_packages = self.check_multiple_specs(self.project, prj_staged_packages)
for pkg in support_pkgs:
if files.get(pkg) and files.get(pkg) in prj_expanded_packages:
if files.get(pkg) not in cand_sources[stg]:
cand_sources[stg].append(files.get(pkg))
root = ET.fromstring(rebuild_data)
logging.info('Checking rebuild data...')
for stg in root.findall('staging'):
rebuild = stg.find('rebuild').text
suppkg_list = stg.find('supportpkg').text
need_rebuild = False
suppkgs = []
if suppkg_list:
suppkgs = suppkg_list.split(',')
#.........这里部分代码省略.........