Skip to content

Commit

Permalink
- added 'osc bugowner' as a more intelligent version of 'osc maintai…
Browse files Browse the repository at this point in the history
…ner -B'

 - added option '-B' to osc maintainer, prints bugowner OR maintainer.
 - added 'osc req help' as convenience alias to 'osc help req'.
 - 'osc in' to be done. Its usage just prints a suggested zypper command line.
 - Incompatible change: osc se now prints Project Package, instead of 
   Package Project for easier copy&paste.
 - give better hint how to use osc vc without network connectivity.
 - added printing of cache statistices to osc build
 - implemented 'osc ls .' to take proj/pack name from current directory.
   * Incompatible change: 'osc ls' now defaults to 'osc ls .',
   * Use 'osc ls /' if you really want to list all projects.
   * This is meant as a proof of concept. I intend to generalize this usage of '.'
     for all osc commands. Feedback welcome.
  • Loading branch information
Jürgen Weigert committed Oct 22, 2009
1 parent 889a2d5 commit bb6e27d
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 10 deletions.
13 changes: 13 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
0.124
- added 'osc bugowner' as a more intelligent version of 'osc maintainer -B'
- added option '-B' to osc maintainer, prints bugowner OR maintainer.
- added 'osc req help' as convenience alias to 'osc help req'.
- 'osc in' to be done. Its usage just prints a suggested zypper command line.
- Incompatible change: osc se now prints Project Package, instead of Package Project
for easier copy&paste.
- give better hint how to use osc vc without network connectivity.
- added printing of cache statistices to osc build
- implemented 'osc ls .' to take proj/pack name from current directory.
* Incompatible change: 'osc ls' now defaults to 'osc ls .',
* Use 'osc ls /' if you really want to list all projects.
* This is meant as a proof of concept. I intend to generalize this usage of '.'
for all osc commands. Feedback welcome.

0.123
- IMPORTANT: ssl certificate checks are actually performed now to
Expand Down
92 changes: 92 additions & 0 deletions PROJ_PACK.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
jw, Tue Oct 20 22:09:16 CEST 2009

This is a feature suggestion for easier osc commandline handling.
Many commands require specifying Project and/or Package names.

The current situation is not satisfying for the following reasons:
- inconsistent defaults. Some osc subcommands can take project
and/or package names from the current directory, if run inside a checkout
tree. If both project and package can use this default or only one, and if
one, which, depends on the command. Users have a hard time memorizing
which is which.
Examples as of osc version 0.123:
osc maintainer PRJ [PKG]
- does not look in the current directory.
- need at least PRJ.
osc list [PRJ [PKG]]
- Never looks at the current directory.
- lists all projects, if run without parameters.
osc checkout [PRJ] PKG
osc checkout PRJ
- takes project from current directory, if inside a checkout tree
- else operates on an entire project.
osc checkin [ARG]
- defaults to current project and package,
- if arg is a subdirectory, project is taken from current directory
- if arg is a file, both project and package are taken from current
directory.
osc results [PRJ PKG]
- takes either both or none from current directory.
- many commands do not look into the current directory,
they are cumbersome to use.
- sometimes PRJ/PKG can be used instead of PRJ PKG


Suggested solution
------------------

Instead of tuning (maybe optional) positional parameters.
We suggest to deprecate this syntax over time and instead favour an alternate
syntax:
osc CMD ... [--prj PRJ] [--pkg PKG] ...
osc CMD ... [--proj PRJ] [--pack PKG] ...
osc CMD ... [--project PRJ] [--package PKG] ...

These six options are new to osc, currently no existing command uses
them. Thus the new syntax is conflict free wit the old syntax, both can be
used in parallel.

--prj, --proj, --project are synonyms.
--pkg, --pack, --package are synonyms.

osc shall support aliases, to save typing. Some implicit aliases exist,
with well defined magic effects. Aliases substitution is literal.
They can replace options including their parameters, or just the option, or
just the parameters.
- (a dash) expands to --prj openSUSE:Factory
(or --prj followed by any other project as defined in
~/.oscrc:default_project )
--prj - is synonymous to just -, for consistency.

. (a dot) evaluates the current working directory, searching for
.osc/_apiurl, .osc/_project, and .osc/_package
Implicit --apiurl, --prj, or --pkg options are constructed as far
as available from the current directory and as far as not already
present in the command line.
If a dot is used as parameter to an option, it has a more
deterministic meaning.
--apiurl . Substitute only the current apiurl,
--prj . Substitute the current project name, and provides
a default for --apiurl unless given.
--pkg . Substitures current package name likewise.

./. expands to --prj . --pkg .
./PKG expands to --prj . --pkg PKG

Unless otherwise noted in the online help, magic aliases are only attempted onceper commandline, and will only apply to their respective options.
E.g. osc ci -m - will use a simple '-' as check in messages, and the absence of any project or package will default to the current project or package, just as
osc ci . -m - would do.

Additionally, user defined aliases can be added to ~/.oscrc
If an alias expansion has effect on the command line, the expanded line is
printed as debug output.

online help of osc commands shall refer to the above syntax like this:

osc CMD ... PROJ/PACK

An additional help entry

osc help 'PROJ/PACK'

shall explain the relevant details as presented herein.
4 changes: 4 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
JW:
- german umlaut characters ��� do not work in the message for osc submitpac.
404 not found, and no request sent.

CRITICAL:
- webpage can create a _link in a fully populated package.
Need to prevent his somehow.
Expand Down
59 changes: 53 additions & 6 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3370,9 +3370,44 @@ def do_api(self, subcmd, opts, url):
out = r.read()
sys.stdout.write(out)

@cmdln.option('-v', '--verbose', action='store_true',
help='show more information')
@cmdln.option('--nodevelproject', action='store_true',
help='do not follow a defined devel project ' \
'(primary project where a package is developed)')
@cmdln.option('-e', '--email', action='store_true',
help='show email addresses instead of user names')
def do_bugowner(self, subcmd, opts, *args):
"""${cmd_name}: Show bugowners of a project/package
@cmdln.option('-b', '--bugowner', action='store_true',
osc bugowner PRJ
osc bugowner PRJ PKG
Shortcut for osc maintainer -B [PRJ] PKG
PRJ defaults to '%(getpac_default_project)s'.
Prints bugowner if defined, or maintainer otherwise.
${cmd_option_list}
"""
opts.role = None
opts.bugowner = True
opts.bugowner_only = None
opts.add = None
opts.delete = None
opts.devel_project = None

if len(args) == 1:
print >>sys.stderr, 'defaulting to %s/%s' % (conf.config['getpac_default_project'], args[0])
# python has no args.unshift ???
args = [ conf.config['getpac_default_project'] , args[0] ]
return self.do_maintainer(subcmd, opts, *args)


@cmdln.option('-b', '--bugowner_only', action='store_true',
help='Show only the bugowner')
@cmdln.option('-B', '--bugowner', action='store_true',
help='Show only the bugowner if defined, or maintainer otherwise')
@cmdln.option('-e', '--email', action='store_true',
help='show email addresses instead of user names')
@cmdln.option('--nodevelproject', action='store_true',
Expand Down Expand Up @@ -3408,7 +3443,7 @@ def do_maintainer(self, subcmd, opts, *args):
roles = [ 'bugowner', 'maintainer' ]
else:
roles = [opts.role]
if opts.bugowner:
if opts.bugowner_only:
roles = [ 'bugowner' ]

if len(args) == 1:
Expand Down Expand Up @@ -3445,13 +3480,22 @@ def do_maintainer(self, subcmd, opts, *args):
setDevelProject(conf.config['apiurl'], prj, pac, opts.devel_project)
else:
# showing the maintainers
seen=0
for role in roles:
print ""
print role, ":"
if opts.bugowner:
if seen:
break;
for person in tree.findall('person'):
if person.get('role') == role:
seen += 1
maintainers.append(person.get('userid'))

if opts.bugowner:
if seen:
print role+":",
else:
print ""
print role, ":"

if opts.email:
emails = []
for maintainer in maintainers:
Expand Down Expand Up @@ -3836,7 +3880,10 @@ def do_vc(self, subcmd, opts, *args):
if conf.config['api_host_options'][apiurl].has_key('email'):
os.environ['mailaddr'] = conf.config['api_host_options'][apiurl]['email']
else:
os.environ['mailaddr'] = get_user_data(apiurl, user, 'email')[0]
try:
os.environ['mailaddr'] = get_user_data(apiurl, user, 'email')[0]
except Exception, e:
sys.exit('%s\nget_user_data(email) failed. Try env mailaddr=....\n' % e)

if opts.message:
cmd_list.append("-m")
Expand Down
23 changes: 19 additions & 4 deletions osc/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def failureReport(self, errobj):
raise errobj.exception


def fetch(self, pac):
def fetch(self, pac, prefix=''):
# for use by the failure callback
self.curpac = pac

Expand All @@ -83,7 +83,7 @@ def fetch(self, pac):
# it returns the filename
ret = mg.urlgrab(pac.filename,
filename = pac.fullpartname,
text = '(%s) %s' %(pac.project, pac.filename))
text = '%s(%s) %s' %(prefix, pac.project, pac.filename))

except URLGrabError, e:
print
Expand Down Expand Up @@ -123,22 +123,37 @@ def dirSetup(self, pac):


def run(self, buildinfo):
all = 0
cached = 0
for i in buildinfo.deps:
i.makeurls(self.cachedir, self.urllist)
all += 1
if os.path.exists(i.fullfilename):
cached += 1
miss = 0
if all:
miss = 100.0*(all-cached)/all
print "%.1f%% cache miss. %d/%d dependencies cached.\n" % (miss,cached,all)
needed = all-cached

done = 1
for i in buildinfo.deps:
i.makeurls(self.cachedir, self.urllist)
if not os.path.exists(i.fullfilename):
self.dirSetup(i)
try:
# if there isn't a progress bar, there is no output at all
if not self.progress_obj:
print '(%s) %s' % (i.project, i.filename)
self.fetch(i)
print '%d/%d (%s) %s' % (done, needed, i.project, i.filename)
self.fetch(i, "%d/%d " % (done,needed))
except KeyboardInterrupt:
print 'Cancelled by user (ctrl-c)'
print 'Exiting.'
if os.path.exists(i.fullpartname):
print 'Cleaning up incomplete file', i.fullpartname
os.unlink(i.fullpartname)
sys.exit(0)
done += 1



Expand Down
4 changes: 4 additions & 0 deletions osc_expand_link.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# 2006-12-15, jw, v0.2 -- {files}{error} gets printed if present.
# 2008-03-25, jw, v0.3 -- go via api using iChains and ~/.oscrc
# 2008-03-26, jw, v0.4 -- added linked file retrieval and usage.
# 2009-10-21, jw, added obsolete warning, in favour of osc co -e

use Data::Dumper;
use LWP::UserAgent;
Expand All @@ -16,6 +17,9 @@
my $version = '0.4';
my $verbose = 1;

print "This $0 is obsolete. Please use instead: osc co -e\n";
sleep 5;

# curl buildservice:5352/source/home:jnweiger/vim
# curl 'buildservice:5352/source/home:jnweiger/vim?rev=d90bfab4301f758e0d82cf09aa263d37'
# curl 'buildservice:5352/source/home:jnweiger/vim/vim.spec?rev=d90bfab4301f758e0d82cf09aa263d37'
Expand Down

0 comments on commit bb6e27d

Please sign in to comment.