Notificator

Notification

class notif.notificator.Notification[source]

Abstract class to define a notification. Force implementation of method send_notification and define how to send a notification error’

abstract send_notification(message: str) → None[source]

Abstract method to send a notification.

Parameters

message (str) – The message to send as a notification message threw the notificator.

send_notification_error(error: Exception) → None[source]

Send a notification error message threw to notificator.

Parameters

error (Exception) – The exception raised during the script execution.

Slack Notificator

class notif.notificator.SlackNotificator(webhook_url: str)[source]

Notificator to send a notification into a Slack channel.

Parameters

webhook_url (str) – a webhook url given by Slack to post content into a channel. See here for more detail.

webhook_url

The webhook url to push notification to.

Type

str

headers

The headers of the notification.

Type

dict

Example:

notif = SlackNotificator(webhook_url="webhook_url")
notif.send_notification("The script is finish")
send_notification(message: str) → None[source]

Send a notification message to the webhook url.

Parameters

message (str) – The message to send as a notification message to the webhook url.

Email Notificator

class notif.notificator.EmailNotificator(sender_email: str, sender_login_credential: str, destination_email: str, smtp_server: EmailPolicy(linesep='rn'))[source]

Notificator to send a notification email.

Parameters
  • sender_email (str) – The email of the sender.

  • sender_login_credential (str) – The login credential of the sender email.

  • destination_email (str) – The recipient of the email, can be the same as the sender_email.

  • smtp_server (SMTP) – The smtp server to relay the email.

sender_email

The email of the sender.

Type

str

sender_login_credential

The login credential of the sender.

Type

str

destination_email

The email of the recipient of the notification.

Type

str

smtp_server

The smtp server.

Type

SMTP

Example

Using gmail server:

sender_email = "my_email"
sender_login_credential = "my_password"
destination_email = sender_email
smtp_server = smtplib.SMTP('smtp.gmail.com',587)

notif = EmailNotificator(sender_email, sender_login_credential,
                               destination_email, smtp_server)
notif.send_notification(message="text")

Using hotmail server:

sender_email = "my_email"
sender_login_credential = "my_password"
destination_email = "other_email"
smtp_server = smtplib.SMTP('smtp.live.com',587)

notif = EmailNotificator(sender_email, sender_login_credential,
                               destination_email, smtp_server)
notif.send_notification(message="text")

Channel Notificator

class notif.notificator.ChannelNotificator(channel_url: str)[source]

Wrapper around notify_run to send a notification to a phone or a desktop. Can have multiple devices in the channel.

Parameters

channel_url (str) – A channel_rul created on notify.run <https://notify.run/>

notifier

A notify object to send notification.

Type

Notify

Example

notif = ChannelNotificator(endpoint="https://notify.run/some_channel_id")
notif.send_notification('Hi there!')

Facebook Messenger Notificator

class notif.notificator.FacebookMessengerNotificator(email_logging: str, logging_credential: str)[source]

Wrapper around fbchat to send a notification threw Facebook messenger to yourself.

Parameters
  • email_logging (str) – Your email to login into Facebook.

  • logging_credential (str) – Your login credential to login into Facebook.

fb_client

A fbchat client

Type

Client

Example

notif = FacebookMessengerNotificator('email', 'password')
notif.send_notification(message="test")