src/pyams_utils/scripts/zodb.py
changeset 289 c8e21d7dd685
child 292 b338586588ad
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/scripts/zodb.py	Wed Dec 05 12:45:56 2018 +0100
@@ -0,0 +1,45 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+import argparse
+import sys
+import textwrap
+
+# import interfaces
+
+# import packages
+from pyams_utils.site import site_upgrade
+from pyramid.paster import bootstrap
+
+
+def upgrade_site():
+    """Check for site upgrade"""
+    usage = "usage: {0} config_uri".format(sys.argv[0])
+    description = """Check for database upgrade.
+                  Usage: pyams_upgrade production.ini
+                  """
+    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:
+        site_upgrade(env['request'])
+    finally:
+        closer()