diff options
author | VG <vg@devys.org> | 2016-06-10 17:39:59 +0200 |
---|---|---|
committer | VG <vg@devys.org> | 2016-06-10 17:39:59 +0200 |
commit | 6e7f287497e0dc9aec33c5cda1428cea2637ba79 (patch) | |
tree | 31ba17505999f1c3b8a8ed929bbd8e576ed97e63 | |
parent | f168bde66cbbabe1fcec9b123a5be8e2cdf6ba38 (diff) | |
download | climl-6e7f287497e0dc9aec33c5cda1428cea2637ba79.tar.gz climl-6e7f287497e0dc9aec33c5cda1428cea2637ba79.tar.bz2 climl-6e7f287497e0dc9aec33c5cda1428cea2637ba79.zip |
fix ref to moved content variable and fix arg appening to exception
-rw-r--r-- | climl/__init__.py | 2 | ||||
-rw-r--r-- | climl/hooks.py | 15 | ||||
-rw-r--r-- | climl/interface.py | 5 |
3 files changed, 11 insertions, 11 deletions
diff --git a/climl/__init__.py b/climl/__init__.py index e46baab..8924ebf 100644 --- a/climl/__init__.py +++ b/climl/__init__.py @@ -10,7 +10,7 @@ def on_email(content, hooks, conf): context = dict( conf=conf, - rawcontent=content, + content=content, ) try: diff --git a/climl/hooks.py b/climl/hooks.py index fcc43f4..a521376 100644 --- a/climl/hooks.py +++ b/climl/hooks.py @@ -3,7 +3,7 @@ from . import interface def hook_extract_listname(context): - lines = content.split(b'\n') + lines = context['content'].split(b'\n') for line in lines: print('line: ', line) if line.startswith(b'Delivered-To: '): @@ -27,23 +27,18 @@ def hook_process_subscribe_queries(context): def hook_generate_rcpt_list(context): - print(1) listname = context.get('listname', None) - print(2) if not listname: raise interface.HookStopIteration('list name not found') - print(3) recipients_filename = ''.join([listname, '-recipents.txt']) - print(4) try: with open(recipients_filename, encoding='utf8') as fi: recipients = [recipient for recipient in fi] context['recipients'] = recipients - print(5) except FileNotFoundError as e: n = interface.HookAbortError('recipients list not found') - n.args.append({'listname': listname, - 'recipients_filename': recipients_filename}) + n.args += ({'listname': listname, + 'recipients_filename': recipients_filename}, ) raise n from e @@ -58,5 +53,7 @@ def hook_send_all(context): smtp_server = smtplib.SMTP(context.conf.get('smtp.server')) #smtp_server.set_debuglevel(1) - smtp_server.sendmail(listaddress, context['recipients'], content) + smtp_server.sendmail(listaddress, + context['recipients'], + context['content']) smtp_server.quit() diff --git a/climl/interface.py b/climl/interface.py index 5bafa2b..a42faac 100644 --- a/climl/interface.py +++ b/climl/interface.py @@ -3,7 +3,10 @@ This file defines symbols used to make communication between hooks/plugins/extensions and core of climl. ''' -class HookError(Exception): +class Error(Exception): + ''' Base class for exceptions in this package ''' + +class HookError(Error): ''' Base class for hooks exception, they should not use this directly ''' |