def register_empty_driver(self, driver_type, driver_name, add_cleanup=True): class SomeDriver(object): pass driver = SomeDriver() drivers.register_driver(driver_type, driver_name, driver) if add_cleanup: self.addCleanup(drivers.unregister_driver, driver_type, driver_name) return driver
Copyright (C) 2011 Linux2Go This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Fake SMS driver """ from surveilr import drivers class FakeMessaging(object): msgs = [] def send(self, recipient, info): self.msgs.append((recipient, info)) drivers.register_driver('sms', 'fake', FakeMessaging())
from surveilr import config from surveilr import drivers from clickatell.api import Clickatell from clickatell import constants as cc class ClickatellMessaging(object): def __init__(self): username = config.get_str('sms', 'username') password = config.get_str('sms', 'password') api_id = config.get_str('sms', 'api_id') self.client = Clickatell(username, password, api_id, sendmsg_defaults={ 'callback': cc.YES, 'msg_type': cc.SMS_DEFAULT, 'deliv_ack': cc.YES, 'req_feat': (cc.FEAT_ALPHA + cc.FEAT_NUMER + cc.FEAT_DELIVACK) }) def send(self, recipient, info): sender = config.get_str('sms', 'sender') self.client.sendmsg(recipients=[recipient.messaging_address], sender=sender, text=str(info)) drivers.register_driver('sms', 'clickatell', ClickatellMessaging())
from surveilr import config from surveilr import drivers from clickatell.api import Clickatell from clickatell import constants as cc class SMSMessaging(object): def __init__(self): username = config.get_str('sms', 'username') password = config.get_str('sms', 'password') api_id = config.get_str('sms', 'api_id') self.client = Clickatell(username, password, api_id, sendmsg_defaults={ 'callback': cc.YES, 'msg_type': cc.SMS_DEFAULT, 'deliv_ack': cc.YES, 'req_feat': (cc.FEAT_ALPHA + cc.FEAT_NUMER + cc.FEAT_DELIVACK) }) def send(self, recipient, info): sender = config.get_str('sms', 'sender') self.client.sendmsg(recipients=[recipient.messaging_address], sender=sender, text=str(info)) drivers.register_driver('messaging', 'sms', SMSMessaging())
<http://www.gnu.org/licenses/>. BulkSMS driver """ from surveilr import config from surveilr import drivers import BulkSMS class BulkSMSMessaging(object): def __init__(self): username = config.get_str('sms', 'username') password = config.get_str('sms', 'password') kwargs = {} try: kwargs['server'] = config.get_str('sms', 'server') except config.NoOptionError: pass self.client = BulkSMS.Server(username, password, **kwargs) def send(self, recipient, info): sender = config.get_str('sms', 'sender') self.client.send_sms(recipients=[recipient.messaging_address], sender=sender, text=str(info)) drivers.register_driver('sms', 'bulksms', BulkSMSMessaging())