1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-11 16:36:14 +01:00

- reworked do_requestmaintainership()

This commit is contained in:
Marcus Huewe 2011-01-25 21:06:28 +01:00
parent db8818c30f
commit 8a488d3b6d

View File

@ -1459,11 +1459,19 @@ Please submit there instead, or use --nodevelproject to force direct submission.
${cmd_option_list}
"""
import cgi
args = slash_split(args)
apiurl = self.get_api_url()
if len(args) < 2:
if is_package_dir(os.getcwd()):
if len(args) == 2:
project = args[0]
package = args[1]
user = conf.get_apiurl_usr(apiurl)
elif len(args) == 3:
project = args[0]
package = args[1]
user = args[2]
elif len(args) < 2 and is_package_dir(os.curdir):
project = store_read_project(os.curdir)
package = store_read_package(os.curdir)
if len(args) == 0:
@ -1472,35 +1480,18 @@ Please submit there instead, or use --nodevelproject to force direct submission.
user = args[0]
else:
raise oscerr.WrongArgs('Wrong number of arguments.')
elif len(args) == 2:
project = args[0]
package = args[1]
user = conf.get_apiurl_usr(apiurl)
elif len(args) == 3:
project = args[0]
package = args[1]
user = args[2]
else:
raise oscerr.WrongArgs('Wrong number of arguments.')
if not opts.role in ('maintainer', 'bugowner'):
raise oscerr.WrongOptions('invalid \'--role\': either specify \'maintainer\' or \'bugowner\'')
arg = [ user, opts.role, project, package ]
actionsxml = self._add_user(arg, None)
if not opts.message:
opts.message = edit_message()
import cgi
xml = """<request> %s <state name="new"/> <description>%s</description> </request> """ % \
(actionsxml, cgi.escape(opts.message or ""))
u = makeurl(apiurl, ['request'], query='cmd=create')
f = http_POST(u, data=xml)
root = ET.parse(f).getroot()
return root.get('id')
r = Request()
r.add_action('add_role', tgt_project=project, tgt_package=package,
person_name=user, person_role=opts.role)
r.description = cgi.escape(opts.message or '')
r.create(apiurl)
print r.reqid
@cmdln.option('-m', '--message', metavar='TEXT',
help='specify message TEXT')