PyNotificator Reference

Reference

exception pynotificator.NotificationError

Bases: Exception

Notification Error

class pynotificator.BaseNotification

Bases: object

Notification Superclass

set_typed_variable(value, specified_type)

Check the type and return it.

Parameters
  • value (Object) – Value to check

  • specified_type (Object) – Specified type of value

Returns

Checked value

Return type

Object

Raises

NotificationError – When the types don’t match.

Examples

>>> number = set_typed_variable(3, int)
>>> number
3
>>> string = set_typed_variable('3', int)
NotificationError: can only set int (not "str")
notify()

Executing the notification

Raises

NotImplementedError – When there is no implementation

class pynotificator.OSSpecificNotification

Bases: pynotificator.BaseNotification

OS-specific notifications

system

OS you are using

Type

str

darwin_notify()

Executing macOS notification

Raises

NotImplementedError – When there is no implementation

linux_notify()

Executing Linux notification

Raises

NotImplementedError – When there is no implementation

windows_notify()

Executing Windows notification

Raises

NotImplementedError – When there is no implementation

notify()

Executing the notification

Raises

NotificationError – When you use an unsupported OS

class pynotificator.MessageNotification(message)

Bases: pynotificator.BaseNotification

Notification with message

Parameters

message (str) – Message body

get_message()
set_message(message)
property message

Message body

Type

str

class pynotificator.WebhookNotification(message, url)

Bases: pynotificator.MessageNotification

Webhook notification

Parameters
  • message (str) – Message body

  • url (str) – Webhook URL

get_url()
set_url(url)
property url

Webhook URL

Type

str

class pynotificator.TokenNotification(message, token)

Bases: pynotificator.MessageNotification

Token notification

Parameters
  • message (str) – Message body

  • token (str) – Token

get_token()
set_token(token)
property token

Token

Type

str

class pynotificator.BeepNotification(times)

Bases: pynotificator.OSSpecificNotification

Beep notification

Parameters

times (int) – times of beep sound

Examples

Usage
>>> bn = BeepNotification(3)
>>> bn.notify()
Change the times of beep sound
>>> bn.times = 1
>>> bn.notify()
Command Line Tools

$ beep-notify [-h] [--times TIMES]

get_times()
set_times(times)
property times

times of beep sound

Type

int

darwin_notify()

Executing macOS notification

Raises

NotImplementedError – When there is no implementation

linux_notify()

Executing Linux notification

Raises

NotImplementedError – When there is no implementation

windows_notify()

Executing Windows notification

Raises

NotImplementedError – When there is no implementation

class pynotificator.DesktopNotification(message, title=None, subtitle=None, icon=None, sound=True)

Bases: pynotificator.MessageNotification, pynotificator.OSSpecificNotification

Desktop Notification

Parameters
  • message (str) – Message body

  • title (str) – Title

  • subtitle (str) – Subtitle

  • icon (str) – Icon

  • sound (bool) – Presence of sound

Examples

Usage
>>> dn = DesktopNotification('Hello', title='PyNotificator')
>>> dn.notify()
Change the message body
>>> dn.message = 'Change Body'
>>> dn.notify()
Command Line Tools

$ desktop-notify [-h] [--message MESSAGE] [--title TITLE] [--subtitle SUBTITLE] [--nosound]

get_title()
set_title(title)
get_subtitle()
set_subtitle(subtitle)
get_icon()
set_icon(icon)
get_sound()
set_sound(sound)
property title

Title

Type

str

property subtitle

Subtitle

Type

str

property icon

Icon

Type

str

property sound

Presence of sound

Type

bool

darwin_notify()

Executing macOS notification

Raises

NotImplementedError – When there is no implementation

linux_notify()

Executing Linux notification

Raises

NotImplementedError – When there is no implementation

windows_notify()

Executing Windows notification

Raises

NotImplementedError – When there is no implementation

class pynotificator.SlackNotification(message, url)

Bases: pynotificator.WebhookNotification

Slack Notification

Examples

Usage
>>> sn = SlackNotification('Hello', 'https://hooks.slack.com/xxx')
>>> sn.notify()
Change the message body
>>> sn.message = 'Change Body'
>>> sn.notify()
Command Line Tools

$ slack-notify [-h] [--message MESSAGE] url

notify()

Executing the notification

class pynotificator.DiscordNotification(message, url)

Bases: pynotificator.WebhookNotification

Discord Notification

Examples

Usage
>>> dn = DiscordNotification('Hello', 'https://discordapp.com/xxx')
>>> dn.notify()
Change the message body
>>> dn.message = 'Change Body'
>>> dn.notify()
Command Line Tools

$ discord-notify [-h] [--message MESSAGE] url

notify()

Executing the notification

class pynotificator.LineNotification(message, token)

Bases: pynotificator.TokenNotification

LINE Notification

Parameters
  • message (str) – Message body

  • token (str) – LINE Notify token

Examples

Usage
>>> ln = LineNotification('Hello', 'xxx')
>>> ln.notify()
Change the message body
>>> ln.message = 'Change Body'
>>> ln.notify()
Command Line Tools

$ line-notify [-h] [--message MESSAGE] token

notify()

Executing the notification