diff options
author | 2015-05-15 22:10:54 -0400 | |
---|---|---|
committer | 2015-06-19 15:50:52 -0400 | |
commit | 24a6f7413e784513d432451b92fa799980b09b1d (patch) | |
tree | 5594de0c3fd22e2703188e25e689f09f2119a223 | |
parent | webapp.eclass: Changes order of command line flags (diff) | |
download | webapp-config-24a6f7413e784513d432451b92fa799980b09b1d.tar.gz webapp-config-24a6f7413e784513d432451b92fa799980b09b1d.tar.bz2 webapp-config-24a6f7413e784513d432451b92fa799980b09b1d.zip |
{config, db}.py: Adds proper support for list-installs command
The webapp-config man page says that the --list-installs flag
can be the package name, and/or version, or "*". So changes
needed to be made to allow for this functionality.
-rw-r--r-- | WebappConfig/config.py | 43 | ||||
-rw-r--r-- | WebappConfig/db.py | 2 |
2 files changed, 28 insertions, 17 deletions
diff --git a/WebappConfig/config.py b/WebappConfig/config.py index c87b93b..2c14baa 100644 --- a/WebappConfig/config.py +++ b/WebappConfig/config.py @@ -579,7 +579,7 @@ class Config: info_opts.add_argument('-li', '--list-installs', - nargs = 2, + nargs = '*', help = 'List all current virtual installs for <a' 'pplication>. Use * for the package name and/or ' 'version number to list more than one package / ' @@ -972,32 +972,43 @@ class Config: OUT.debug('Checking command line arguments', 1) - if self.work in ['install', 'clean', 'query', 'show_postinst', - 'show_postupgrade', 'upgrade']: + if self.work in ['install', 'clean', 'query', 'list_installs', + 'show_postinst', 'show_postupgrade', 'upgrade']: # get cat / pn args = options[self.work] + m = args[0].split('/') + + if self.work == 'list_installs' and len(args) > 2: + msg = os.path.basename(sys.argv[0]) + ': error: argument -li/'\ + '--list-installs: expected up to 2 arguments' - m = args[0].split('/') + self.parser.print_usage() + print(msg) + sys.exit() if len(m) == 1: - self.config.set('USER', 'pn', m[0]) + if '*' not in m: + self.config.set('USER', 'pn', m[0]) elif len(m) == 2: self.config.set('USER', 'cat', m[0]) - self.config.set('USER', 'pn', m[1]) + if '*' not in m: + self.config.set('USER', 'pn', m[1]) else: OUT.die('Invalid package name') - argsvr = args[1].split('.') - if len(argsvr) == 1: - OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]}) + if len(args) > 1: + argsvr = args[1].split('.') + if len(argsvr) == 1: + OUT.die('Invalid package version: %(pvr)s' % {'pvr': args[1]}) + + pvr = '' + for i in range(0, len(argsvr)): + if not i == len(argsvr) - 1: + pvr += argsvr[i] + '.' + else: + pvr += argsvr[i] + self.config.set('USER', 'pvr', pvr) - pvr = '' - for i in range(0, len(argsvr)): - if not i == len(argsvr) - 1: - pvr += argsvr[i] + '.' - else: - pvr += argsvr[i] - self.config.set('USER', 'pvr', pvr) # -------------------------------------------------------------------- # Helper functions diff --git a/WebappConfig/db.py b/WebappConfig/db.py index 0fbd34a..06d9e04 100644 --- a/WebappConfig/db.py +++ b/WebappConfig/db.py @@ -403,7 +403,7 @@ class WebappDB(AppHierarchy): OUT.info(' ' + i[3].strip(), 1) else: # This is a simplified form for the webapp.eclass - print(i[3].strip()) + OUT.info(i[3].strip(), 1) # ======================================================================== # Handler for /usr/share/webapps |