summaryrefslogtreecommitdiffstats
path: root/update.py
diff options
context:
space:
mode:
authorKiall Mac Innes <kiall@managedit.ie>2012-11-18 11:16:05 +0000
committerMark McLoughlin <markmc@redhat.com>2012-11-23 07:07:16 +0000
commite990b9853187b44535f66fd9d48cb67971f19051 (patch)
treec7e95e13891e5f0945e11e0d991862024e173dac /update.py
parentb4c0767e5529eb5d58aed90643354dbee83efefe (diff)
downloadoslo-e990b9853187b44535f66fd9d48cb67971f19051.tar.gz
oslo-e990b9853187b44535f66fd9d48cb67971f19051.tar.xz
oslo-e990b9853187b44535f66fd9d48cb67971f19051.zip
Fixup update.py after argparse breakage
Commit 5b9cb4148 changed the way cfg support's positional arguments and broke update.py. Use the new positional argument infrastructure. Change-Id: I0dc8b5ec445daaf3b437eb524c6eb4b684e5a695
Diffstat (limited to 'update.py')
-rw-r--r--update.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/update.py b/update.py
index 624143e..849b9b7 100644
--- a/update.py
+++ b/update.py
@@ -78,34 +78,31 @@ opts = [
cfg.StrOpt('dest-dir',
default=None,
help='Destination project directory'),
+ cfg.StrOpt('configfile_or_destdir',
+ default=None,
+ help='A config file or destination project directory',
+ positional=True),
]
def _parse_args(argv):
conf = cfg.ConfigOpts()
conf.register_cli_opts(opts)
- args = conf(argv, usage='Usage: %(prog)s [config-file|dest-dir]')
+ conf(argv, usage='Usage: %(prog)s [config-file|dest-dir]')
- if len(args) == 1:
+ if conf.configfile_or_destdir:
def def_config_file(dest_dir):
return os.path.join(dest_dir, 'openstack-common.conf')
- i = argv.index(args[0])
-
config_file = None
- if os.path.isfile(argv[i]):
- config_file = argv[i]
- elif (os.path.isdir(argv[i])
- and os.path.isfile(def_config_file(argv[i]))):
- config_file = def_config_file(argv[i])
+ if os.path.isfile(conf.configfile_or_destdir):
+ config_file = conf.configfile_or_destdir
+ elif (os.path.isdir(conf.configfile_or_destdir)
+ and os.path.isfile(def_config_file(conf.configfile_or_destdir))):
+ config_file = def_config_file(conf.configfile_or_destdir)
if config_file:
- argv[i:i + 1] = ['--config-file', config_file]
- args = conf(argv)
-
- if args:
- conf.print_usage(file=sys.stderr)
- sys.exit(1)
+ conf(argv + ['--config-file', config_file])
return conf