From b3accd584673200f2d816a5022be141f67bfd4a4 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Fri, 6 Jul 2012 17:35:10 +0200 Subject: [PATCH] Ability to enable the update mode via the config file This is better for Windows as running python scripts with command line arguments is no fun. --- src/fix_imap_internaldate.py | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/fix_imap_internaldate.py b/src/fix_imap_internaldate.py index 43f9c5b..30ae4ff 100644 --- a/src/fix_imap_internaldate.py +++ b/src/fix_imap_internaldate.py @@ -49,6 +49,11 @@ def main(): config = load_configuration() prepare_logger(config) args = parser.parse_args() + + # check for update mode in the config + if config.getboolean('basic_settings', 'update_mode_i_know_what_i_am_doing'): + args.test_mode = False + if(args.test_mode): logging.info("Testing mode initiated. No message will be modified on the server.") else: @@ -78,6 +83,7 @@ def load_configuration(): config.set('basic_settings', 'tolerance_mins', 30) config.set('basic_settings', 'skip_shared_folders', "True") config.set('basic_settings', 'fallback_to_date_header', "False") + config.set('basic_settings', 'update_mode_i_know_what_i_am_doing', "False") with open(CONFIG_FILENAME, 'w') as configfile: config.write(configfile) configfile.write("# 0 NOTSET, 10 DEBUG, 20 INFO, 30 WARNING, 40 ERROR, 50 CRITICAL\n") @@ -90,6 +96,7 @@ def load_configuration(): config.getint('basic_settings', 'tolerance_mins') config.getboolean('basic_settings', 'skip_shared_folders') config.getboolean('basic_settings', 'fallback_to_date_header') + config.getboolean('basic_settings', 'update_mode_i_know_what_i_am_doing') except (configparser.NoSectionError, configparser.NoOptionError, ValueError) as ex: print("Could not read config file '%s': %s." % (CONFIG_FILENAME, ex)) print("Please change or remove the config file.") -- 1.7.1