Skip to content

Commit

Permalink
- ask user to create maintenance incident when submit request fails a…
Browse files Browse the repository at this point in the history
…t release project
  • Loading branch information
adrianschroeter committed Jan 23, 2012
1 parent a2030b9 commit cb78230
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- support dryrun of branching to preview the expected result. "osc sm" is doing this now by default.
- maintenance requests accept package lists as source and target incidents to be merged in
- add "setincident" command to "request" to re-direct a maintenance request
- ask user to create "maintenance incident" request when submit request is failing at release project

0.133
- add --meta option also to "list", "cat" and "less" commands
Expand Down
31 changes: 25 additions & 6 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3433,12 +3433,15 @@ def create_maintenance_request(apiurl, src_project, src_packages, tgt_project, o

# This creates an old style submit request for server api 1.0
def create_submit_request(apiurl,
src_project, src_package,
src_project, src_package=None,
dst_project=None, dst_package=None,
message="", orev=None, src_update=None):

import cgi
options_block=""
package=""
if src_update:
package="""package="%s" """ % (src_package)
if src_update:
options_block="""<options><sourceupdate>%s</sourceupdate></options> """ % (src_update)

Expand All @@ -3453,15 +3456,15 @@ def create_submit_request(apiurl,
xml = """\
<request type="submit">
<submit>
<source project="%s" package="%s" rev="%s"/>
<source project="%s" %s rev="%s"/>
%s
%s
</submit>
<state name="new"/>
<description>%s</description>
</request>
""" % (src_project,
src_package,
package,
orev or show_upstream_rev(apiurl, src_project, src_package),
targetxml,
options_block,
Expand All @@ -3473,10 +3476,26 @@ def create_submit_request(apiurl,
# I guess, my original workaround was not that bad.

u = makeurl(apiurl, ['request'], query='cmd=create')
f = http_POST(u, data=xml)
try:
f = http_POST(u, data=xml)
root = ET.parse(f).getroot()
r = root.get('id')
except urllib2.HTTPError, e:
if e.headers.get('X-Opensuse-Errorcode') == "submit_request_rejected":
print "This project is just for releasign maintenance updates. Do you want to create a maintenance incident request instead ? [y/n]"
if sys.stdin.read(1) == "y":
xpath = 'attribute/@name = \'%s\'' % conf.config['maintenance_attribute']
res = search(apiurl, project_id=xpath)
root = res['project_id']
project = root.find('project')
if project is None:
sys.exit('Unable to find defined OBS:MaintenanceProject project on server.')
tproject = project.get('name')
r = create_maintenance_request(apiurl, src_project, [src_package], tproject, src_update, message)
else:
raise

root = ET.parse(f).getroot()
return root.get('id')
return r


def get_request(apiurl, reqid):
Expand Down

0 comments on commit cb78230

Please sign in to comment.