Mailinglist Archive: opensuse-buildservice (239 mails)

< Previous Next >
[opensuse-buildservice] osc submitreq list [-M|--mine]
  • From: "Dominique Leuenberger" <Dominique.Leuenberger@xxxxxxxxxxxxx>
  • Date: Thu, 14 May 2009 23:17:40 +0200
  • Message-id: <4A0CA69402000029000189DD@xxxxxxxxxxxxxxxxxxx>
Hi,

Inspired by the fact that OBS Webclient can show me 'my' submitreqs I hacked up
a bit on osc and added the parameter -M to the sr list command.

Examples:
osc sr list
guesses if $pwd is a prj / pkg and shows SR's against it.

PRJ and PKG can both be defined on the cmdline. All this is unchanged.

NEW:
if you start
osc sr list -M
it will show ALL SRs created by YOU, in state NEW
I think this can be very handy to keep an overview.

Of course, constructs like
osc sr list -M PRJ
shows me all MY SR's of the specified project

It can even be extended with -s (for the state).

Any comments on it?

Best regards,
Dominique
Index: osc/core.py
===================================================================
--- osc/core.py (revision 7327)
+++ osc/core.py (working copy)
@@ -2052,12 +2052,20 @@
return f.read()


-def get_submit_request_list(apiurl, project, package, req_state=('new',)):
- match = 'submit/target/@project=\'%s\'' % quote_plus(project)
+def get_submit_request_list(apiurl, project, package, req_who,
req_state=('new',) ):
+ match = ''
+ if project:
+ if len(match): match += '%20and%20'
+ match += 'submit/target/@project=\'%s\'' % quote_plus(project)
if package:
- match += '%20and%20' + 'submit/target/@package=\'%s\'' %
quote_plus(package)
+ if len(match): match += '%20and%20'
+ match += 'submit/target/@package=\'%s\'' % quote_plus(package)
for state in req_state:
- match += '%20and%20' + 'state/@name=\'%s\'' % quote_plus(state)
+ if len(match): match += '%20and%20'
+ match += 'state/@name=\'%s\'' % quote_plus(state)
+ if req_who:
+ if len(match): match += '%20and%20'
+ match += 'state/@who=\'%s\'' % quote_plus(req_who)

u = makeurl(apiurl, ['search', 'request'], ['match=%s' % match])
f = http_GET(u)
Index: osc/commandline.py
===================================================================
--- osc/commandline.py (revision 7327)
+++ osc/commandline.py (working copy)
@@ -482,6 +482,8 @@
help='only list requests in one of the comma separated
given states [default=new]')
@cmdln.option('-b', '--brief', action='store_true', default=False,
help='print output in list view as list subcommand')
+ @cmdln.option('-M', '--mine', action='store_true',
+ help='only show requests created by yourself')
@cmdln.alias("sr")
@cmdln.alias("submitrequest")
def do_submitreq(self, subcmd, opts, *args):
@@ -526,7 +528,7 @@
osc submitreq create [-m TEXT]
osc submitreq create [-m TEXT] DESTPRJ [DESTPKG]
osc submitreq create [-m TEXT] SOURCEPRJ SOURCEPKG DESTPRJ
[DESTPKG]
- osc submitreq list [PRJ [PKG]]
+ osc submitreq list [-M] [PRJ [PKG]]
osc submitreq log ID
osc submitreq show [-d] [-b] ID
osc submitreq accept [-m TEXT] ID
@@ -603,12 +605,13 @@
if len(args) > 0:
project = args[0]
else:
- project = store_read_project(os.curdir)
- apiurl = store_read_apiurl(os.curdir)
- try:
- package = store_read_package(os.curdir)
- except oscerr.NoWorkingCopy:
- pass
+ if not opts.mine:
+ project = store_read_project(os.curdir)
+ apiurl = store_read_apiurl(os.curdir)
+ try:
+ package = store_read_package(os.curdir)
+ except oscerr.NoWorkingCopy:
+ pass

if len(args) > 1:
package = args[1]
@@ -661,9 +664,10 @@
# list
elif cmd == 'list':
state_list = opts.state.split(',')
-
+ who = conf.get_apiurl_usr(apiurl) if opts.mine else ''
+
results = get_submit_request_list(apiurl,
- project, package, state_list)
+ project, package, who, state_list)

results.sort(reverse=True)

< Previous Next >
Follow Ups