From 8a488d3b6d9c5ed68e2e1e210a80d6a4bdd36dee Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Tue, 25 Jan 2011 21:06:28 +0100 Subject: [PATCH] - reworked do_requestmaintainership() --- osc/commandline.py | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 0ce9dd9d..42faf1e3 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1459,20 +1459,11 @@ 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()): - project = store_read_project(os.curdir) - package = store_read_package(os.curdir) - if len(args) == 0: - user = conf.get_apiurl_usr(apiurl) - else: - user = args[0] - else: - raise oscerr.WrongArgs('Wrong number of arguments.') - elif len(args) == 2: + + if len(args) == 2: project = args[0] package = args[1] user = conf.get_apiurl_usr(apiurl) @@ -1480,27 +1471,27 @@ Please submit there instead, or use --nodevelproject to force direct submission. 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: + user = conf.get_apiurl_usr(apiurl) + else: + user = args[0] 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 = """ %s %s """ % \ - (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')