--- a/src/pyams_utils/scripts/zodb.py Mon Apr 11 17:37:23 2016 +0200
+++ b/src/pyams_utils/scripts/zodb.py Mon Apr 11 17:37:52 2016 +0200
@@ -14,7 +14,7 @@
# import standard library
-import optparse
+import argparse
import sys
import textwrap
@@ -27,17 +27,16 @@
def upgrade_site():
"""Check for site upgrade"""
- usage = "usage: %prog config_uri"
+ usage = "usage: {0} config_uri".format(sys.argv[0])
description = """Check for database upgrade.
Usage: pyams_upgrade production.ini
"""
- parser = optparse.OptionParser(usage=usage,
- description=textwrap.dedent(description))
- options, args = parser.parse_args(sys.argv[1:])
- if not len(args) >= 1:
- print("You must provide at least one configuration file")
- return 2
- config_uri = args[0]
+ parser = argparse.ArgumentParser(usage=usage,
+ description=textwrap.dedent(description))
+ parser.add_argument('config_uri', help='Name of configuration file')
+ args = parser.parse_args()
+
+ config_uri = args.config_uri
env = bootstrap(config_uri)
settings, closer = env['registry'].settings, env['closer']
try: