osclib/stagingapi: drop {load,save}_file_content() methods.
Since the implementations have been made generic and dropped to osclib.core there is not point in having wrappers in StagingAPI with the same args.
This commit is contained in:
parent
26884da458
commit
5e6df089a6
@ -13,6 +13,8 @@ from osc.core import change_request_state, show_package_meta, wipebinaries
|
||||
from osc.core import http_GET, http_PUT, http_DELETE, http_POST
|
||||
from osc.core import delete_package, search, set_devel_project
|
||||
from osclib.config_command import ConfigCommand
|
||||
from osclib.core import source_file_load
|
||||
from osclib.core import source_file_save
|
||||
from datetime import date
|
||||
|
||||
|
||||
@ -171,10 +173,10 @@ class AcceptCommand(object):
|
||||
# intend to break the kiwi file
|
||||
arch = package.split('-')[-1]
|
||||
fakepkgname = 'I-am-breaks-kiwi-build'
|
||||
oldkiwifile = self.api.load_file_content(project, package, 'PRODUCT-'+arch+'.kiwi')
|
||||
oldkiwifile = source_file_load(self.api.apiurl, project, package, 'PRODUCT-'+arch+'.kiwi')
|
||||
if oldkiwifile is not None:
|
||||
newkiwifile = re.sub(r'<repopackage name="openSUSE-release"/>', '<repopackage name="%s"/>' % fakepkgname, oldkiwifile)
|
||||
self.api.save_file_content(project, package, 'PRODUCT-' + arch + '.kiwi', newkiwifile)
|
||||
source_file_save(self.api.apiurl, project, package, 'PRODUCT-' + arch + '.kiwi', newkiwifile)
|
||||
|
||||
# do wipe binary now
|
||||
query = { 'cmd': 'wipe' }
|
||||
@ -250,7 +252,7 @@ class AcceptCommand(object):
|
||||
|
||||
if len(filelist) > 1:
|
||||
# There is more than one .spec file in the package; link package containers as needed
|
||||
origmeta = self.api.load_file_content(project, pkgname, '_meta')
|
||||
origmeta = source_file_load(self.api.apiurl, project, pkgname, '_meta')
|
||||
for specfile in filelist:
|
||||
package = specfile[:-5] # stripping .spec off the filename gives the packagename
|
||||
if package == pkgname:
|
||||
@ -272,9 +274,9 @@ class AcceptCommand(object):
|
||||
newmeta = re.sub(r'</package>',
|
||||
r'<bcntsynctag>{}</bcntsynctag></package>'.format(pkgname),
|
||||
newmeta)
|
||||
self.api.save_file_content(project, package, '_meta', newmeta)
|
||||
source_file_save(self.api.apiurl, project, package, '_meta', newmeta)
|
||||
link = "<link package=\"{}\" cicount=\"copy\" />".format(pkgname)
|
||||
self.api.save_file_content(project, package, '_link', link)
|
||||
source_file_save(self.api.apiurl, project, package, '_link', link)
|
||||
return True
|
||||
|
||||
def update_factory_version(self):
|
||||
|
@ -37,10 +37,6 @@ class CheckDuplicateBinariesCommand(object):
|
||||
|
||||
current = yaml.dump(duplicates, default_flow_style=False)
|
||||
if save:
|
||||
args = ['{}:Staging'.format(self.api.project), 'dashboard', 'duplicate_binaries']
|
||||
previous = self.api.load_file_content(*args)
|
||||
if current != previous:
|
||||
args.append(current)
|
||||
self.api.save_file_content(*args)
|
||||
self.api.dashboard_content_ensure('duplicate_binaries', current)
|
||||
else:
|
||||
print(current)
|
||||
|
@ -15,6 +15,8 @@
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
from osclib.config_command import ConfigCommand
|
||||
from osclib.core import source_file_load
|
||||
from osclib.core import source_file_save
|
||||
import time
|
||||
import re
|
||||
from xml.etree import cElementTree as ET
|
||||
@ -170,12 +172,12 @@ class FreezeCommand(object):
|
||||
if not self.api.item_exists(project, product):
|
||||
return None
|
||||
|
||||
kiwifile = self.api.load_file_content(project, product, 'PRODUCT-'+arch+'.kiwi')
|
||||
kiwifile = source_file_load(self.api.apiurl, project, product, 'PRODUCT-'+arch+'.kiwi')
|
||||
|
||||
tmpkiwifile = re.sub(r'<productinfo name="VERSION">.*</productinfo>', '<productinfo name="VERSION">%s</productinfo>' % version, kiwifile)
|
||||
newkiwifile = re.sub(r'<productvar name="VERSION">.*</productvar>', '<productvar name="VERSION">%s</productvar>' % version, tmpkiwifile)
|
||||
|
||||
self.api.save_file_content(project, product, 'PRODUCT-' + arch + '.kiwi', newkiwifile)
|
||||
source_file_save(self.api.apiurl, project, product, 'PRODUCT-' + arch + '.kiwi', newkiwifile)
|
||||
|
||||
def prj_meta_for_bootstrap_copy(self, prj):
|
||||
root = ET.Element('project', {'name': prj})
|
||||
|
@ -1244,8 +1244,8 @@ class StagingAPI(object):
|
||||
# If adi project, check for baselibs.conf in all specs to catch both
|
||||
# dynamically generated and static baselibs.conf.
|
||||
baselibs = False if self.is_adi_project(project) else None
|
||||
if baselibs is False and 'baselibs.conf' in str(self.load_file_content(
|
||||
src_prj, src_pkg, '{}.spec'.format(src_pkg), src_rev)):
|
||||
if baselibs is False and 'baselibs.conf' in str(source_file_load(
|
||||
self.apiurl, src_prj, src_pkg, '{}.spec'.format(src_pkg), src_rev)):
|
||||
baselibs = True
|
||||
|
||||
for sub_prj, sub_pkg in self.get_sub_packages(tar_pkg, project):
|
||||
@ -1261,8 +1261,8 @@ class StagingAPI(object):
|
||||
url = self.makeurl(['source', sub_prj, sub_pkg, '_link'])
|
||||
http_PUT(url, data=ET.tostring(root))
|
||||
|
||||
if baselibs is False and 'baselibs.conf' in str(self.load_file_content(
|
||||
src_prj, src_pkg, '{}.spec'.format(sub_pkg), src_rev)):
|
||||
if baselibs is False and 'baselibs.conf' in str(source_file_load(
|
||||
self.apiurl, src_prj, src_pkg, '{}.spec'.format(sub_pkg), src_rev)):
|
||||
baselibs = True
|
||||
|
||||
if baselibs:
|
||||
@ -1467,7 +1467,7 @@ class StagingAPI(object):
|
||||
|
||||
version = None
|
||||
|
||||
specfile = self.load_file_content(project, package, '{}.spec'.format(package))
|
||||
specfile = source_file_load(self.apiurl, project, package, '{}.spec'.format(package))
|
||||
if specfile:
|
||||
try:
|
||||
version = re.findall('^Version:(.*)', specfile, re.MULTILINE)[0].strip()
|
||||
@ -1487,27 +1487,6 @@ class StagingAPI(object):
|
||||
return None
|
||||
raise
|
||||
|
||||
def load_file_content(self, project, package, filename, revision=None):
|
||||
"""
|
||||
Load the content of a file and return the content as data. If the package is a link, it will be expanded
|
||||
:param project: The project to query
|
||||
:param package: The package to quert
|
||||
:param filename: The filename to query
|
||||
:param revision: The revision to query
|
||||
"""
|
||||
return source_file_load(self.apiurl, project, package, filename, revision)
|
||||
|
||||
def save_file_content(self, project, package, filename, content, comment='script updated'):
|
||||
"""
|
||||
Save content to a project/package/file
|
||||
:param project: The project containing the package
|
||||
:param package: the package to update
|
||||
:param filename: the filename to save the data to
|
||||
:param content: the content to write to the file
|
||||
"""
|
||||
url = self.makeurl(['source', project, package, filename], {'comment': comment})
|
||||
http_PUT(url, data=content)
|
||||
|
||||
def dashboard_content_load(self, filename, revision=None):
|
||||
return project_pseudometa_file_load(self.apiurl, self.project, filename, revision)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user