aboutsummaryrefslogtreecommitdiffstats
path: root/mini-dinstall
diff options
context:
space:
mode:
authorLibravatarKrytarik Raido <krytarik@gmail.com>2023-06-28 16:04:04 +0200
committerLibravatarKrytarik Raido <krytarik@gmail.com>2023-06-28 16:04:04 +0200
commitd1d92b57e634b8fc740d1665bb0de0a9081a11c2 (patch)
tree5591371820457eb158a809bd795b1ef43ea42cd2 /mini-dinstall
parentb56220db336b26b8bb0252aae9ca6dd55f32cba3 (diff)
Improve handling of mail features.
Closes: #1027267, #1027268
Diffstat (limited to 'mini-dinstall')
-rwxr-xr-xmini-dinstall46
1 files changed, 26 insertions, 20 deletions
diff --git a/mini-dinstall b/mini-dinstall
index 60a29dc..e5e7d36 100755
--- a/mini-dinstall
+++ b/mini-dinstall
@@ -56,9 +56,9 @@ mail_on_success = True
tweet_on_success = False
default_poll_time = 30
default_max_retry_time = 60 * 60 * 24 * 2
-default_mail_log_level = logging.ERROR
trigger_reindex = True
-mail_log_flush_level = logging.ERROR
+mail_log_level = 'ERROR'
+mail_log_flush_level = 'ERROR'
mail_log_flush_count = 10
mail_to = getpass.getuser()
mail_server = 'localhost'
@@ -223,24 +223,27 @@ class SubjectSpecifyingLoggingSMTPHandler(logging.handlers.SMTPHandler):
def getSubject(self, record):
return re.sub('%l', record.levelname, self._subject)
-if not (configp.has_option('DEFAULT', 'mail_log_level') and configp.get('DEFAULT', 'mail_log_level') == 'NONE'):
- if configp.has_option('DEFAULT', 'mail_log_level'):
- mail_log_level = logging.__dict__[configp.get('DEFAULT', 'mail_log_level')]
- else:
- mail_log_level = default_mail_log_level
+if configp.has_option('DEFAULT', 'mail_log_level'):
+ mail_log_level = configp.get('DEFAULT', 'mail_log_level')
+if configp.has_option('DEFAULT', 'mail_on_success'):
+ mail_on_success = configp.get('DEFAULT', 'mail_on_success')
+if mail_log_level != 'NONE' or mail_on_success:
if configp.has_option('DEFAULT', 'mail_to'):
mail_to = configp.get('DEFAULT', 'mail_to')
if configp.has_option('DEFAULT', 'mail_server'):
mail_server = configp.get('DEFAULT', 'mail_server')
- if configp.has_option('DEFAULT', 'mail_log_flush_count'):
- mail_log_flush_count = configp.getint('DEFAULT', 'mail_log_flush_count')
- if configp.has_option('DEFAULT', 'mail_log_flush_level'):
- mail_log_flush_level = logging.__dict__[configp.get('DEFAULT', 'mail_log_flush_level')]
- mail_smtp_handler = SubjectSpecifyingLoggingSMTPHandler(mail_server, 'Mini-Dinstall <%s@%s>' % (getpass.getuser(), socket.getfqdn()), [mail_to])
- mail_smtp_handler.setSubject('mini-dinstall log notice (%l)')
- mail_handler = logging.handlers.MemoryHandler(mail_log_flush_count, flushLevel=mail_log_flush_level, target=mail_smtp_handler)
- mail_handler.setLevel(mail_log_level)
- logger.addHandler(mail_handler)
+ if mail_log_level != 'NONE':
+ if configp.has_option('DEFAULT', 'mail_log_flush_count'):
+ mail_log_flush_count = configp.getint('DEFAULT', 'mail_log_flush_count')
+ if configp.has_option('DEFAULT', 'mail_log_flush_level'):
+ mail_log_flush_level = configp.get('DEFAULT', 'mail_log_flush_level')
+ mail_smtp_handler = SubjectSpecifyingLoggingSMTPHandler(mail_server, 'Mini-Dinstall <%s@%s>' % (
+ getpass.getuser(), socket.getfqdn()), [mail_to])
+ mail_smtp_handler.setSubject('mini-dinstall log notice (%l)')
+ mail_handler = logging.handlers.MemoryHandler(mail_log_flush_count,
+ flushLevel=logging.__dict__[mail_log_flush_level], target=mail_smtp_handler)
+ mail_handler.setLevel(logging.__dict__[mail_log_level])
+ logger.addHandler(mail_handler)
if args:
toplevel_directory = args[0]
@@ -363,6 +366,8 @@ if configp.has_option('DEFAULT', 'mail_subject_template'):
mail_subject_template = configp.get('DEFAULT', 'mail_subject_template')
if configp.has_option('DEFAULT', 'mail_body_template'):
mail_body_template = configp.get('DEFAULT', 'mail_body_template')
+if configp.has_option('DEFAULT', 'tweet_on_success'):
+ tweet_on_success = configp.get('DEFAULT', 'tweet_on_success')
if configp.has_option('DEFAULT', 'tweet_template'):
tweet_template = configp.get('DEFAULT', 'tweet_template')
if configp.has_option('DEFAULT', 'tweet_server'):
@@ -399,8 +404,8 @@ class DistOptionHandler:
'restrict_changes_files': ['bool', None],
'chown_changes_files': ['bool', None],
'keep_old': ['bool', False],
- 'mail_on_success': ['bool', True],
- 'tweet_on_success': ['bool', False],
+ 'mail_on_success': ['bool', mail_on_success],
+ 'tweet_on_success': ['bool', tweet_on_success],
'archive_style': ['str', None],
'override_file': ['str', None],
# Release file stuff
@@ -764,7 +769,8 @@ class ArchiveDir:
if self._mail_on_success:
self._success_logger = logging.Logger("mini-dinstall." + self._name)
self._success_logger.setLevel(logging.DEBUG)
- self.mailHandler = SubjectSpecifyingLoggingSMTPHandler(mail_server, 'Mini-Dinstall <%s@%s>' % (getpass.getuser(), socket.getfqdn()), [mail_to])
+ self.mailHandler = SubjectSpecifyingLoggingSMTPHandler(mail_server, 'Mini-Dinstall <%s@%s>' % (
+ getpass.getuser(), socket.getfqdn()), [mail_to])
self.mailHandler.setLevel(logging.DEBUG)
self._success_logger.addHandler(self.mailHandler)
self._clean_targets = []
@@ -833,7 +839,7 @@ class ArchiveDir:
done = False
missing_fields = []
if 'changes' in changefile:
- changefile['changes_without_dot'] = misc.format_changes(changefile['changes'])
+ changefile['changes_without_dot'] = misc.format_changes(changefile['changes'].splitlines())
while not done:
try:
mail_subject = mail_subject_template % changefile