Configuration¶
Available notification methods¶
Currently, The Noterator supports email, HipChat, Twilio (SMS), and desktop notifications.
Desktop notifications are only supported on Mac & Linux. On Linux, the notify-send
binary must be on your $PATH
.
Here is the full set of configuration options available for all notification methods:
[desktop]
sound = false
[email]
from_mail = The Noterator <noterator@example.org>
recipient = you@example.org
host = smtp.example.org
port = 25
username = postmaster@example.org
password = password123
[hipchat]
token = abc123
room_id = 123456
from_name = The Noterator
message_colour = green
[twilio]
account_sid = abc123
token = abc123
from_number = +123456
to_number = +456789
The only settings that have a default are:
email.port
:25
hipchat.from_name
:The Noterator
hipchat.message_colour
:green
desktop.sound
:false
Configuration in .ini
files¶
By default, noterator
will look in $HOME/.config/noterator/config.ini
for configuration.
See config.example.ini to get started.
If you want to keep your configuration file somewhere else, you can pass the config_file
parameter to noterator
:
>>> from noterator import noterate, EMAIL
>>> for obj in noterate(my_objects, method=EMAIL, config_file='/path/to/config.ini'):
... do_something_slow(obj)
...
>>>
Configuration in code¶
If you set up a Noterator
class, you can override your file-based configuration per iteration:
>>> from noterator import Noterator, EMAIL
>>> noterator = Noterator(method=EMAIL, every_n=100, start=True)
>>> noterator.configure_plugin('email', recipient='someone@example.org')
>>> for obj in noterator(my_objects)
... do_something_slow(obj)
...
>>> noterator.configure_plugin('email', recipient='someone_else@example.org')
>>> for obj in noterator(my_other_objects)
... do_something_slow(obj)
...
>>>
You can go a step further and avoid using files at all. The following code would work even if no configuration file could be found:
>>> from noterator import Noterator, EMAIL
>>> noterator = Noterator(my_objects, method=EMAIL, every_n=100, start=True)
>>> noterator.configure_plugin('email', recipient='you@example.org', from_mail='postmaster@example.org', host='smtp.example.org')
>>> for obj in noterator:
... do_something_slow(obj)
...
>>>