Welcome to notify’s documentation!

notify

Build status Coverage Downloads Latest version Format Status License Support version

Notify process termination via email. It support Python 2.4 and later (Python 2.4 and Python 2.5 were manually tested, so it might not work).

Installation

Use pip like:

$ pip install notify

Additionally, if you would like to use a mail user agent which requires authentication, installing keyring is strongly recommended:

$ pip install keyring

Usage

  1. Running notify with the following command will start a setup wizard the first time.

    $ notify
    
  2. Follow the setup wizard instructions.

  3. Check with the following command (Only for Unix system)

    $ notify --check
    
  4. Sample usage of notify

    $ notify really_havy_process -a -b --options
    $ notify -t different@address.com really_havy_process -a -b --options
    

API documentation

notify Package

notify Package

arguments Module

notify.arguments.parse_arguments(args, config)[source]

Parse specified arguments via config

Parameters:

args : list

Command line arguments

config : object

ConfigParser instance which values are used as default values of options

Returns:

list : arguments, options

options indicate the return value of ArgumentParser and arguments indicate the execution command/arguments

notify.arguments.split_arguments(args)[source]

Split specified arguments to two list.

This is used to distinguish the options of the program and execution command/arguments.

Parameters:

args : list

Command line arguments

Returns:

list : options, arguments

options indicate the optional arguments for the program and arguments indicate the execution command/arguments

compat Module

Compatibility module

conf Module

notify.conf.config_to_options(config)[source]

Convert ConfigParser instance to argparse.Namespace

Parameters:

config : object

A ConfigParser instance

Returns:

object

An argparse.Namespace instance

notify.conf.create_default_config()[source]

Create default ConfigParser instance

notify.conf.get_user_config_filename(appname='notify')[source]

Get user config filename.

It will return operating system dependent config filename.

Parameters:

appname : string

An application name used for filename

Returns:

string

A filename of user configuration.

console Module

notify.console.main(args=None)[source]

executor Module

A terminal command executor module

notify.executor.call(args)[source]

Call terminal command and return exit_code and stdout

Parameters:

args : list

A command and arguments list

Returns:

list : [exit_code, stdout]

exit_code indicate the exit code of the command and stdout indicate the output of the command

notify.executor.from_unicode(x, e)
notify.executor.get_command_str(args)[source]

Get terminal command string from list of command and arguments

Parameters:

args : list

A command and arguments list (unicode list)

Returns:

str

A string indicate terminal command

mailer Module

Mailer module

notify.mailer.create_message(from_addr, to_addr, subject, body, encoding=None)[source]

Create message object for sending email

Parameters:

from_addr : string

An email address used for ‘From’ attribute

to_addr : string

An email address used for ‘To’ attribute

subject : string

An email subject string

body : string

An email body string

encoding : string

An email encoding string (Default: utf8)

Returns:

object

An instance of email.mime.text.MIMEText

notify.mailer.send_email(msg, host='localhost', port=25, username=None, password=None)[source]

Send an email (via TLS when username and password are specified)

Parameters:

msg : object

An instance of MIMEText. Create this with create_message() function.

host : string

A mail user agent host name (Default: localhost)

port : int

A mail user agent port number (Default: 25)

username : string

A username string used to login MUA via TLS authentication

password : string

A password string used to login MUA via TLS authentication

debug : boolean

True for displaying debug messages

notifier Module

notify.notifier.call_and_notificate(args, opts)[source]

Execute specified arguments and send notification email

Parameters:

args : list

A execution command/arguments list

opts : object

A option instance

wizard Module

A notify setup wizard module

exception notify.wizard.ValidationError[source]

Bases: exceptions.Exception

notify.wizard.console_input(default, validation=None, allow_empty=False)[source]

Get user input value from stdin

Parameters:

default : string

A default value. It will be used when user input nothing.

validation : callable

A validation function. The validation function must raise an error when validation has failed.

Returns:

string or any

A user input string or validated value

notify.wizard.setup_wizard(config)[source]
notify.wizard.validate_email(x)[source]
notify.wizard.validate_int(x)[source]

Subpackages

tests Package
test_conf Module
test_executor Module
utils Package
plaintext_keyring Module

Plaintext keyring module

class notify.utils.plaintext_keyring.PlaintextKeyring(filename=None)[source]

Bases: object

Methods

delete_password(service_name, username)[source]
get_password(service_name, username)[source]
set_password(service_name, username, password)[source]
terminalmsg Module
notify.utils.terminalmsg.termianlmsg(paragraphs, wallchar='*')[source]
terminalsize Module
notify.utils.terminalsize.get_terminal_size()[source]

getTerminalSize() - get width and height of console - works on linux,os x,windows,cygwin(windows) originally retrieved from: http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python

Indices and tables