wnslib package

Submodules

wnslib.notificationManager module

wnslib.notificationManager.addNotification(name, func_path, interval, store=False)

Add new complex notification

Parameters:
  • name (str) – Name of the function
  • func_path (str) – path to the function
  • interval (int) – number of minutes how ofter the function is executed
  • store (bool) – flag, if true the system store the notification result default False
Raises:

Exception – raise exception if python function is wrong

wnslib.notificationManager.createSimpleNotification(name, service, params, cql, interval, period=None, store=False)

Create simple notifcation

Create new python script for simplenotification and add to notification.aps file

Parameters:
  • name (str) – Name of the function
  • service (str) – service
  • params (dict) – params to compose getObservation request
  • cql (str) – condition to reach to send notification
  • interval (int) – interval
  • period (str) – isodate period over witch the getObservation is executed
  • store (bool) – flag, if true the system store the notification result
Raises:

Exception – exception if something goes wrong

wnslib.notificationManager.delNotification(name)

Delete selected notification

remove notification from notification.aps, data-base and remove the function file

Parameters:name (str) – Name of the notification
wnslib.notificationManager.delete_script_file(name)

remove function_name.py and function_name.pyc files

Parameters:name (str) – function name
wnslib.notificationManager.write_script_file(code, name)

Create function python file

create a function_name.py in the wns/scripts folder

Parameters:
  • code (str) – python code
  • name (str) – name of the function
wnslib.notificationManager.write_to_aps(name, interval, store)

Add function call to notification.aps

Parameters:
  • name (str) – name of the function
  • interval (int) – interval, how often is performed the notification
  • store (bool) – True if the system must store the notification result

wnslib.notificationScheduler module

wnslib.notificationScheduler.notify(name, message, status=True)

Notify manager

check users subscription and raise notification

Parameters:
  • name (str) – name of the notification
  • message (dict) – dictionary with message to notify
  • status (bool) – if True update status on twitter

wnslib.notify module

class wnslib.notify.Notify(serviceconfig)

Bases: object

Notify class

send notifcation via email or twitter

alert(message, name)

alert notification with popup

Parameters:
  • message (str) – message to notify
  • name (str) – notification name
email(message, to)

Send notification via mail

Parameters:
  • message (dict) – dict with object and mail message
  • to (str) – mail where to send notification
fax(message, to, name)

Not implemented

ftp(ftp_params, message)
post_twitter_status(message, name)

Update status twitter

Parameters:
  • message (str) – tweet to send (remember max 140 char)
  • name (str) – name of the notification (to create hashtag)
sms(message, to, name)

not implemented

twitter(message, to, name)

Send a Twitter private message

Parameters:
  • message (str) – tweet to send (remember max 140 char)
  • to (str) – user twitter_id to send
  • name (str) – name of the notification (to create hashtag)

wnslib.operation module

class wnslib.operation.wnsOperation(wnsEnviron, loadjson=True)

Bases: object

Base class for istSOS WNS

executeDelete()

base method to execute DELETE request

executeGet()

base method to execute GET request

executePost()

base method to execute POST request

executePut()

base method to execute PUT request

getResponse()
setData(data)

Set data in response

setException(msg)

Set exception message in response

setLog(log)

set message in log

setMessage(msg)

Set message in response

validateDelete()

base method to validate DELETE request

validateGet()

base method to validate GET request

validatePost()

base method to validate POST request

validatePut()

base method to validate PUT request

wnslib.resourceFactory module

wnslib.resourceFactory.initResource(wnsEnviron)

resource factory

wnslib.setup module

Module contents