# -------------------------------------------------------------------------
def evaluate_config(self, config, yaml_file):
+ self._evaluate_general_config(config, yaml_file)
+ self.__evaluate_mail_config(config, yaml_file)
+
+ # -------------------------------------------------------------------------
+ def _evaluate_general_config(self, config, yaml_file):
+
if 'verbose' in config:
try:
v = int(config['verbose'])
if 'simulate' in config and not self.simulate:
self.simulate = config['simulate']
- if 'no_error_mail' in config and not self.no_error_mail:
- self.no_error_mail = to_bool(config['no_error_mail'])
-
if 'do_sudo' in config:
self.do_sudo = to_bool(config['do_sudo'])
if 'log_dir' in config and config['log_dir']:
self._log_directory = config['log_dir']
- if 'default_email' in config and config['default_email']:
- self.default_email = config['default_email']
-
- if 'sender_address' in config and config['sender_address']:
- self.sender_address = config['sender_address']
-
- if 'smtp_server' in config and config['smtp_server'].strip():
- self.smtp_server = config['smtp_server'].strip()
-
- if 'smtp_port' in config and config['smtp_port']:
- msg = "Invalid port {p!r} for SMTP in {f!r} found.".format(
- p=config['smtp_port'], f=yaml_file)
- try:
- port = int(config['smtp_port'])
- if port > 0 and port < 2**16:
- self.smtp_port = port
- else:
- self.error_data.append(msg)
- except ValueError:
- self.error_data.append(msg)
-
if 'default_parent_dir' in config and config['default_parent_dir']:
pdir = config['default_parent_dir']
if os.path.isabs(pdir):
elif 'cache_file' in config:
self._cachefile = config['cache_file']
+ # -------------------------------------------------------------------------
+ def __evaluate_mail_config(self, config, yaml_file):
+
+ if 'no_error_mail' in config and not self.no_error_mail:
+ self.no_error_mail = to_bool(config['no_error_mail'])
+
+ if 'default_email' in config and config['default_email']:
+ self.default_email = config['default_email']
+
+ if 'sender_address' in config and config['sender_address']:
+ self.sender_address = config['sender_address']
+
+ if 'smtp_server' in config and config['smtp_server'].strip():
+ self.smtp_server = config['smtp_server'].strip()
+
+ if 'smtp_port' in config and config['smtp_port']:
+ msg = "Invalid port {p!r} for SMTP in {f!r} found.".format(
+ p=config['smtp_port'], f=yaml_file)
+ try:
+ port = int(config['smtp_port'])
+ if port > 0 and port < 2**16:
+ self.smtp_port = port
+ else:
+ self.error_data.append(msg)
+ except ValueError:
+ self.error_data.append(msg)
+
if 'mail_cc_addresses' in config:
if config['mail_cc_addresses'] is None:
self.mail_cc_addresses = []
return True
-# =============================================================================
+# =============================================================================
if __name__ == "__main__":
pass