u = core.makeurl(self.apiurl, ['source', prj], query=query)
try:
- print u
f = core.http_POST(u)
except urllib2.HTTPError, e:
e.osc_msg = 'could not trigger disable build flag for project \'%s\'' % (prj)
u = core.makeurl(self.apiurl, ['source', prj], query=query)
try:
- print u
f = core.http_POST(u)
except urllib2.HTTPError, e:
e.osc_msg = 'could not trigger default build flag for project \'%s\'' % (prj)
raise
return
+ def addPerson(self, prj, users):
+ """
+ add persons to a project
+ users = {'userid': ['maintainer', 'bugowner', ...], ...}
+ """
+
+ path = core.quote_plus(prj),
+ kind = 'prj'
+ data = core.meta_exists(metatype=kind,
+ path_args=path,
+ template_args=None,
+ create_new=False)
+ if not data:
+ return
+
+ root = ElementTree.fromstring(''.join(data))
+ for user in users:
+ for role in users[user]:
+ found = False
+ for person in root.getiterator('person'):
+ if person.get('userid') == user and person.get('role') == role:
+ found = True
+ break
+ if not found:
+ root.insert(2, ElementTree.Element('person', role=role, userid=user))
+ core.edit_meta(metatype=kind,
+ path_args=path,
+ data=ElementTree.tostring(root))
+
import re
import xml.etree.cElementTree as ElementTree
from xml.sax.saxutils import escape
+from time import sleep
from osc import core
from gitbuildsys.errors import ObsError
src_meta_xml = build.get_meta(obs_target_prj)
src_xml_root = ElementTree.fromstringlist(src_meta_xml)
# get peron list from obs_target_prj meta
+ person_dict = {}
for person in src_xml_root.findall('person'):
- # add person to prerelease project
- core.addPerson(build.apiurl, obs_project, None, person.get('userid'),
- person.get('role'))
+ if person.get('userid') in person_dict:
+ person_dict[person.get('userid')].append(person.get('role'))
+ else:
+ person_dict[person.get('userid')] = [person.get('role')]
+ # add person to prerelease project
+ if person_dict:
+ build.addPerson(obs_project, person_dict)
def create_related_packages(build, obs_target_prj, obs_pre_prj, pre_package):
"""create the 'link' package that relate the original package
submitter = gerrit_account_name
if gerrit_account_email:
submitter += ' <%s>' % gerrit_account_email
- create_project(url, gerrit_project, git_tag, gerrit_newrev,
- build, obs_target_prj, project, submitter, package)
- if pub_enabled:
- rest.publish_event("pre_created", {
- "project": project,
- "tag": git_tag,
- "product": obs_target_prj,
- "gitpath": gerrit_project,
- })
+ retry_count = 3
+ while retry_count > 0:
+ try:
+ create_project(url, gerrit_project, git_tag, gerrit_newrev,
+ build, obs_target_prj, project, submitter, package)
+ if pub_enabled:
+ rest.publish_event("pre_created", {
+ "project": project,
+ "tag": git_tag,
+ "product": obs_target_prj,
+ "gitpath": gerrit_project,
+ })
+ break
+ except Exception, err:
+ print 'obs operation failed, retrying...'
+ print err
+ sleep(5)
+ retry_count -= 1
+ if not retry_count:
+ print 'retrying failed'
+ return 1
elif build_type == 'snapshot':
if not is_ref_deleted(gerrit_oldrev, gerrit_newrev):
if build.exists(obs_target_prj):