offer Package

offer Package

Package all about providers. This packages handles the code for sending a message through a provider.

offer Module

class iro.offer.offer.Offer(name, provider, route, typ)[source]

One Offer for sending. This class is used to send a message via a provider.

Constructor for Offer class.

Parameters:
__call__(recipient, message)[source]

send a message to a recipient. This method uses iro.offer.provider.Provider.send()

Parameters:
__eq__(o)[source]

return True, if o is equal.

__neq__(o)[source]

return True, if o is not equal (see __eq__()).

__repr__()[source]

string representation of this class for debugging purpose.

Returns:<Offer(name, provider, route, typ)>

provider Module

class iro.offer.provider.Provider(name, typs={}, options=[])[source]

Bases: iro.config.Config

Base class for Providerbackends.

Constructor for Provider class.

Parameters:
  • name (string) – Name of the Provider.
  • typs (dict) – A Dictonary with typs and routes.
  • options (items) – [(“name”,Option(...)),...]
>>> p = Provider("myProvider",{"sms":["route1","route2"]})
getSendFunc(typ, route)[source]

Returns the actually send function for a given typ and route.

Normally it returns the send function with typ and route bound.

Raises :NoRoute, NoTyp
send(typ, route, recipient, message)[source]

Main send function, that is called, for every single message.

Note

This function is not used directly. Normally getSendFunc() return this function with typ and route bound.

testmode = False
  • True – no message to external provider should be send.
  • False (default) – message are send to external provider.
iro.offer.provider.getProvider(name, typ, config)[source]

creates a provider object and init this with config.

Parameters:
  • config (dict) – The Configuration dict. Normally you use configParser.items("section").
  • typ (string) – A valid typ
Raises :

NoProvider

iro.offer.provider.providers = {'sipgate': <class iro.offer.sipgate.Sipgate at 0x31edbb0>, 'smstrade': <class iro.offer.smstrade.Smstrade at 0x31ed870>, 'smtp': <class iro.offer.smtp.SMTP at 0x31ed1f0>}
Avalable Providers.
  • key – typ of provider (see configuration typ field).
  • value – class to handle specific Providertyp.

To extend provider typs, just add this new typ to this dict. see Creating a new Providerbackend for Iro

iro.offer.provider.vProvider(typ, field)[source]

validator to test the existence of the typ.

Parameters:
  • typ (string) – A typ
  • field (string) – A field name used for the Exception.
Returns:

Raises :

ValidateException

sipgate Module

class iro.offer.sipgate.Sipgate(name)[source]

Bases: iro.offer.provider.Provider

s. auch http.tuxad.com/sipgate.html und http://lists.sipgate.net/pipermail/sipgate-developers/2007-September/000016.html

http://www.sipgate.de/beta/public/static/downloads/basic/api/sipgate_api_documentation.pdf

See Creating a new Providerbackend for Iro for a tutorial, how to create a new provider backend. This turorial implements this provider.

clientIdentify()[source]

identificaton of client to sipgate server.

fax(recipient, fax)[source]

send one fax to recimpient.

Parameters:
Returns:

a deferrer.

getSendFunc(typ, route)[source]

returns send() method with bound typ, if typ and route is valid.

load(cfg)[source]

Loads configuration into object.

Parameters:cfg (dict) – The Configuration dict. Normally you use configParser.items("section").
proxy()[source]

returns a XML-RPC proxy object to sipgate API.

send(typ, recipient, msg)[source]

send msg to recipient.

Parameters:
Returns:

a deferrer, that returns a Status object

Raises :

iro.error.NoTyp

sms(recipient, sms)[source]

send one SMS to recimpient.

Parameters:
Returns:

a deferrer

url = 'https://%s:%s@samurai.sipgate.net/RPC2'

XML-RPC url for sipgate

smstrade Module

class iro.offer.smstrade.Smstrade(name)[source]

Bases: iro.offer.provider.Provider

A Provider to send SMS to recipients using smstrade. Smstrade only supports to send SMS and four diffrent routes: ["basic","economy","gold","direct"].

It needs a smstrade Gateway Key https://login.smstrade.de/index.php?gateway in configuration file.

smstrade API documentation: http://kundencenter.smstrade.de/sites/smstrade.de.kundencenter/__pdf/SMS-Gateway_HTTP_API_v2.pdf

The smstrade API supports a debug mode, that can be set with testmode.

getSendFunc(typ, route)[source]

returns a partial send() methed with bounded route, if typ and route is valid.

send(route, recipient, sms)[source]

send one SMS to recipient via route

Parameters:
Returns:

exception iro.offer.smstrade.SmstradeException(status)[source]

Bases: iro.error.ExternalException

An excetion that connects the status code with the excetion string (see statusCodes)

class iro.offer.smstrade.StatusCode(code, exID=None, costs=Decimal('0.0'), count=0)[source]

Class that represents the output of one smstrade request.

iro.offer.smstrade.statusCodes = {70: 'Netz wird von Route nicht abgedeckt.', 71: 'Feature nicht ueber diese Route moeglich.', 10: 'Empfaengernummer nicht korrekt.', 80: 'Uebergabe an SMS-C fehlgeschlagen.', 20: 'Absenderkennung nicht korrekt.', 90: 'Versand nicht moeglich.', 30: 'Nachrichtentext nicht korrekt.', 31: 'Messagetyp nicht korrekt.', 100: 'SMS wurde versendet.', 40: 'SMS Route nicht korrekt.', 50: 'Identifikation fehlgeschlagen.', 60: 'nicht genuegend Guthaben.'}

statuscodes of external smstrade API

smtp Module

class iro.offer.smtp.SMTP(name)[source]

Bases: iro.offer.provider.Provider

A SMTP Provider to send emails. This Provider has only one typ "mail" and one route None.

If testmode is True no mail will be send, only a connection is created to server.

getSendFunc(typ, route)[source]

returns send() method, if typ and route is valid.

send(recipient, mail)[source]

sends a mail to recipient

Parameters:
Returns:

Table Of Contents

This Page