Move panic() up to allow using it earlier during config parsing
Simon Volpert
8 years ago
44 | 44 | |
45 | 45 | # Those are local scripts put in the same directory |
46 | 46 | import clearmime |
47 | ||
48 | # Abort the execution leaving sending the list owner a backtrace | |
49 | def panic(error): | |
50 | logging.error('Panicking: %s' % error) | |
51 | debug_file = '%s.eml' % time.time() | |
52 | df = open(debug_file, 'w') | |
53 | df.write(raw_email) | |
54 | df.close() | |
55 | logging.error('Offending message saved to "%s"' % debug_file) | |
56 | sys.exit() | |
47 | 57 | |
48 | 58 | # Configuration file parsing and validation |
49 | 59 | # The simplicity of this implementation does not warrant employing a ConfigParser |
61 | 71 | for s in ['backend', 'server', 'login', 'passwd', 'allowed_senders', 'list_owner', 'gnupg_file']: |
62 | 72 | if s not in conf: |
63 | 73 | panic('`%s` key is missing from configuration file' % s) |
64 | ||
65 | # Abort the execution leaving sending the list owner a backtrace | |
66 | def panic(error): | |
67 | logging.error('Panicking: %s' % error) | |
68 | debug_file = '%s.eml' % time.time() | |
69 | df = open(debug_file, 'w') | |
70 | df.write(raw_email) | |
71 | df.close() | |
72 | logging.error('Offending message saved to "%s"' % debug_file) | |
73 | sys.exit() | |
74 | 74 | |
75 | 75 | # Send one or more pre-constructed emails |
76 | 76 | def sendmail(message_list): |