controller Package

pool Module

class iro.controller.pool.Pool(name, maxthreads)[source]

wrapper class to handles a twisted threadpool

Parameters:
  • name (string) – name of the threadpool
  • maxthreads (integer) – how many thread a allowed at maximum
run(f, *args, **kwargs)[source]

run a function in Twisted’s thread pool

start(reactor)[source]

stats the pool and adds the pool.stop function to the stop procedure.

Parameters:reactor – a valid twisted reactor
iro.controller.pool.startPool(reactor)[source]

run start function for all items in pools

iro.controller.pool.dbPool = <iro.controller.pool.Pool instance at 0x2ac0a28>

pool to handle database connection via sqlalchemy

iro.controller.pool.taskPool = <iro.controller.pool.Pool instance at 0x2991e18>

taskpool to handle sending data

iro.controller.pool.pools = [<iro.controller.pool.Pool instance at 0x2991e18>, <iro.controller.pool.Pool instance at 0x2ac0a28>]

all available pools

task Module

class iro.controller.task.Task(recipient, job)[source]

A Task is one message to one recipient and is a part of one iro.model.job.ExJob.

Parameters:
setError(error)[source]

errback to set error of task

setStatus(status)[source]

callback, to set status of task

start()[source]

Starting to send message to recipient.

Returns:a defer, that is fired, when message is sended successfully over any offer.
iro.controller.task.createJob(*args, **kwargs)[source]

Creates a iro.model.job.ExJob and start for all recipients one task.

Parameters:
  • user (iro.model.schema.User) – the sender
  • msg (iro.model.message.Message) – the message
  • offers (list) – a list of possible offer and provider names, to try to send the message over. The first entry will be tried first.
  • info (string) – a bill group name
Returns:

the new iro.model.job.ExJob object.

viewinterface Module

class iro.controller.viewinterface.Interface[source]

Bases: object

Interface for views.

bill(user, session=None)[source]

Returns the bill, of not paid messages.

Parameters:

user (string) – apikey of a user

Return dict:
  • route – one offer name ; “total” complete sum
  • [route][info][anz] – Number of sended messages in one billing group
  • [route][info][price] – Price for one billing group
  • [route | total][anz] – Number of sended messages for one offer
  • [route | total][price] – Price for one offer
>>> bill(APIKEY)
{"route1": {"info1":{"anz":1,"price":2.00},
            "info2":{"anz":2,"price":5.00},
            "anz":3,"price":7.00},
"route2":  {"info1":{"anz":3, "price":1.00},
            "info3":{"anz":4, "price":8.00},
            "anz":7, "price":9.00},
"total":   {"anz":10, "price":16.00}
}
defaultRoute(user, typ, session=None)[source]

Returns all default offernames.

Parameters:
  • user (string) – apikey of a user
  • typ (string) – a typ of message – one of in this list [“sms”,”fax”,”mail”]
Return list:

a list of all possible offer names for a typ

email(recipients)[source]

Return True, if all mailadresses a valid.

Parameters:recipients (list) – a list of mailadresses
Return boolean:True – all addresses are valid
fax(user, subject, fax, recipients, route='default', info='')[source]

Send a fax.

Parameters:
  • user (string) – apikey of a user
  • subject (string) – subject
  • fax (string) – content (base64 encoded)
  • recipients (list) – a list of telefon numbers (use ITU-T E.123)
  • route (string|list) – route to use to send, or a list of routes as fallback
  • info (string) – a name, to combine different jobs to one billing group
Return integer:

the job id

mail(user, subject, body, recipients, frm=None, route='default', info='')[source]

Send a mail.

Parameters:
  • user (string) – apikey of a user
  • subject (string) – subject
  • body (string) – mail body
  • recipients (list) – a list of email addresses
  • route (string|list) – route to use to send, or a list of routes as fallback
  • info (string) – a name, to combine different jobs to one billing group
  • frm (string) – sender mail address
Return integer:

the job id

routes(user, typ, session=None)[source]

Returns a list of all possible offernames.

Parameters:
  • user (string) – apikey of a user
  • typ (string) – a typ of message – one of in this list [“sms”,”fax”,”mail”]
Return list:

a list of all possible offer names for a typ

sms(user, message, recipients, route='default', info='')[source]

Send a sms.

Parameters:
  • user (string) – apikey of a user
  • message (string) – message
  • recipients (list) – a list of telefon numbers (use ITU-T E.123)
  • route (string|list) – route to use to send, or a list of routes as fallback
  • info (string) – a name, to combine different jobs to one billing group
Return integer:

the job id

status(user, id=None, detailed=False, session=None)[source]

Returns the status of one or more jobs.

Parameters:
  • user (string) – apikey of a user
  • id (integer) – one job id
  • detailed (boolean) – return more details about the status
Return dict:
  • key – is the job id
  • [key][‘status’] – status of the job

Warning

detailed is not used yet.

>>> status(APIKEY)
{"1":  {"status":"sended"},
 "2":  {"status":"error"},
 "10": {"status":"sending"}}
>>> status(APIKEY,10)
{"10": {"status":"sending"}}
telnumber(recipients)[source]

Return True, if all telnumbers a vaild.

Parameters:recipients (list) – a list of telnumbers (use ITU-T E.123)
Return boolean:True – all numbers are valid

Table Of Contents

This Page