From e54da78499aa1999faad34d1ff6f2844a5f01485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 26 Jan 2012 12:04:55 +0100 Subject: [PATCH] - add "osc my work" which works in same way as webui --- NEWS | 2 ++ osc/commandline.py | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 26899a5b..7d3f9c71 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ - 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 + - "osc my patchinfos" is showing patchinfos where any open bug is assigned to user + - "osc my" or "osc my work" is including assigned patchinfos 0.133 - add --meta option also to "list", "cat" and "less" commands diff --git a/osc/commandline.py b/osc/commandline.py index dde539c4..6b606788 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -5669,10 +5669,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='verbose listing') @cmdln.option('--maintained', action='store_true', help='limit search results to packages with maintained attribute set.') - def do_my(self, subcmd, opts, type): - """${cmd_name}: show packages, projects or requests involving yourself + def do_my(self, subcmd, opts, *args): + """${cmd_name}: show waiting work, packages, projects or requests involving yourself Examples: + # list all tasks where it is expected to work on + osc ${cmd_name} [work] # list packages where I am bugowner osc ${cmd_name} pkg -b # list projects where I am maintainer @@ -5697,10 +5699,11 @@ Please submit there instead, or use --nodevelproject to force direct submission. # The usage above indicates, that sr would be a subset of rq, which is no the case with my tests. # jw. - args_rq = ('requests', 'request', 'req', 'rq') + args_rq = ('requests', 'request', 'req', 'rq', 'work') args_sr = ('submitrequests', 'submitrequest', 'submitreq', 'submit', 'sr') args_prj = ('projects', 'project', 'projs', 'proj', 'prj') args_pkg = ('packages', 'package', 'pack', 'pkgs', 'pkg') + args_patchinfos = ('patchinfos', 'work') if opts.bugowner and opts.maintainer: raise oscerr.WrongOptions('Sorry, \'--bugowner\' and \'maintainer\' are mutually exclusive') @@ -5721,8 +5724,14 @@ Please submit there instead, or use --nodevelproject to force direct submission. else: user = opts.user - list_requests = False what = {'project': '', 'package': ''} + type="work" + if len(args) > 0: + type=args[0] + + list_patchinfos = list_requests = False + if type in args_patchinfos: + list_patchinfos = True if type in args_rq: list_requests = True elif type in args_prj: @@ -5745,6 +5754,35 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.all: role_filter = '' + if list_patchinfos: + u = makeurl(apiurl, ['/search/package'], { + 'match' : "([kind='patchinfo' and issue/[@state='OPEN' and owner/@login='%s']])" % user + }) + f = http_GET(u) + root = ET.parse(f).getroot() + if root.findall('package'): + print "Patchinfos with open bugs assigned to you:\n" + for node in root.findall('package'): + project = node.get('project') + package = node.get('name') + print project, "/", package, '\n' + p = makeurl(apiurl, ['source', project, package], { 'view': 'issues' }) + fp = http_GET(p) + issues = ET.parse(fp).findall('issue') + for issue in issues: + if issue.find('state') == None or issue.find('state').text != "OPEN": + continue + if issue.find('owner') == None or issue.find('owner').find('login').text != user: + continue + print " #", issue.find('long_name').text, ': ', + desc = issue.find('description') + if desc != None: + print desc.text + else: + print "\n" + print "" + + if list_requests: # try api side search as supported since OBS 2.2 try: