summaryrefslogtreecommitdiffstats
path: root/bin/kolab_smtp_access_policy.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2018-06-26 15:41:23 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2018-06-26 15:41:54 +0200
commit6107a8a7bfba971e4abcbd551b3d689250d91ac3 (patch)
tree0eed2cc5192a57772ed4003c064d9fd9d9076e5f /bin/kolab_smtp_access_policy.py
parentb0a8abbb4aacbb93cfba491ee58f6d1bb85d210e (diff)
downloadpykolab-6107a8a7bfba971e4abcbd551b3d689250d91ac3.tar.gz
Add option to drop the caching tables from the database and exit
Summary: This can be used to enforce the regeneration of the caching tables with the latest database schema - for instance, by the package manager when upgrading the PyKolab package. This patch complements D587 in an attempt to fix T2274. Reviewers: #pykolab_developers Maniphest Tasks: T2274 Differential Revision: https://git.kolab.org/D593
Diffstat (limited to 'bin/kolab_smtp_access_policy.py')
-rwxr-xr-xbin/kolab_smtp_access_policy.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/kolab_smtp_access_policy.py b/bin/kolab_smtp_access_policy.py
index be1681d..b351846 100755
--- a/bin/kolab_smtp_access_policy.py
+++ b/bin/kolab_smtp_access_policy.py
@@ -1219,6 +1219,12 @@ def cache_init():
else:
engine = create_engine(cache_uri, echo=False)
+ if conf.drop_tables:
+ log.info(_("Dropping caching tables from database"))
+ policy_result_table.drop(engine, checkfirst=True)
+ statistic_table.drop(engine, checkfirst=True)
+ return False
+
try:
metadata.create_all(engine)
except sqlalchemy.exc.OperationalError, e:
@@ -1594,6 +1600,13 @@ if __name__ == "__main__":
_("Access Policy Options")
)
+ access_policy_group.add_option( "--drop-tables",
+ dest = "drop_tables",
+ action = "store_true",
+ default = False,
+ help = _("Drop the caching tables from the " + \
+ "database and exit."))
+
access_policy_group.add_option( "--timeout",
dest = "timeout",
action = "store",
@@ -1626,6 +1639,9 @@ if __name__ == "__main__":
policy_requests = {}
+ if conf.drop_tables:
+ sys.exit(0)
+
# Start the work
while True:
policy_request = read_request_input()