From e976f230da31301ab16531caf9997fa6216f7ff3 Mon Sep 17 00:00:00 2001 From: Martyn Alberts Date: Thu, 11 Jul 2019 15:28:41 +0200 Subject: [PATCH] WebApp Admin: Add polling interval injection --- webapp_admin/README.md | 2 +- webapp_admin/webapp_admin.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/webapp_admin/README.md b/webapp_admin/README.md index 9f24f8d..378a379 100644 --- a/webapp_admin/README.md +++ b/webapp_admin/README.md @@ -1,6 +1,6 @@ # WebApp Admin ->**This tool is under contruction. Use caution on a live server. Always make a backup of the user settings and test first before modifing** +>**Always make a backup of the user settings and test the new settings afterwards** WebApp admin is a command-line interface to modify, inject and export WebApp settings. diff --git a/webapp_admin/webapp_admin.py b/webapp_admin/webapp_admin.py index a40e4a5..aeb2d04 100755 --- a/webapp_admin/webapp_admin.py +++ b/webapp_admin/webapp_admin.py @@ -26,8 +26,7 @@ from optparse import OptionGroup try: from dotty_dict import dotty except ImportError: - pass - + pass """ @@ -83,6 +82,7 @@ def opt_args(print_help=None): group.add_option("--htmleditor", dest="htmleditor", action="store", help="Change the HTML editor (e.g. full_tinymce)") group.add_option("--remove-state", dest="remove_state", action="store_true", help="Remove all the state settings") group.add_option("--add-safesender", dest="addsender", action="store", help="Add domain to safe sender list") + group.add_option("--polling-interval", dest="pollinginterval", action="store", help="Change the polling interval (seconds)") parser.add_option_group(group) # Advanced option group @@ -578,6 +578,18 @@ def main(): advanced_inject(user, setting, 'list') print('{}'.format(options.addsender), 'Added to safe sender list') + # Polling interval + if options.pollinginterval: + try: + value = int(options.pollinginterval) + except ValueError: + print('Invalid number used. Please specify the value in seconds') + sys.exit(1) + settings = read_settings(user) + setting = 'settings.zarafa.v1.main.reminder.polling_interval = {}'.format(options.pollinginterval) + advanced_inject(user, setting) + print('Polling interval changed to', '{}'.format(options.pollinginterval)) + # Always at last!!! if options.reset: reset_settings(user)