def test_spool_no_time_no_user(self): """Ensure `spool` works when no `time` attribute is supplied, and no `user` attribute exists. """ c = CallFile(self.call, self.action, spool_dir=self.spool_dir) c.spool() ok_((path(c.spool_dir) / path(c.filename)).abspath().exists())
def test_spool_no_time_no_user_error(self): """Ensure that `spool` raises `NoUserError` if the user attribute is not a real system user. """ c = CallFile(self.call, self.action, spool_dir=self.spool_dir, user='******') c.spool()
def test_spool_no_time_user(self): """Ensure that `spool` works when no `time` attribute is specified, and a valid `user` attribute exists. """ c = CallFile(self.call, self.action, spool_dir=self.spool_dir, user=getuser()) c.spool()
def test_spool_time_no_user(self): """Ensure that `spool` works when given a valid `time` parameter.""" c = CallFile(self.call, self.action, spool_dir=self.spool_dir) d = datetime.now() c.spool(d) eq_((path(c.tempdir) / path(c.filename)).abspath().atime, mktime(d.timetuple()))
def test_spool_no_time_no_user_permission_error(self): """Ensure that `spool` raises `NoUserPermissionError` if the user specified does not have permissions to write to the Asterisk spooling directory. """ c = CallFile(self.call, self.action, spool_dir='/', user='******') c.spool()
def test_spool_time_no_user_invalid_time_error(self): """Ensure that `spool` raises `InvalidTimeError` if the user doesn't specify a valid `time` parameter. """ c = CallFile(self.call, self.action, spool_dir=self.spool_dir) with self.assertRaises(InvalidTimeError): c.spool(666)
def test_spool_no_time_no_spool_permission_error(self): """Ensure that `spool` raises `NoSpoolPermissionError` if the user doesn't have permissions to write to `spool_dir`. NOTE: This test WILL fail if the user account you run this test under has write access to the / directory on your local filesystem. """ c = CallFile(self.call, self.action, spool_dir='/') c.spool()
def dialout(): call_from = request.args.get('from', '') call_to = request.args.get('to', '') cfrom = 'SIP/{}@hotvoip'.format(call_from) cto = 'SIP/{}@hotvoip'.format(call_to) c = Call(cfrom) a = Application('Dial', cto) cf = CallFile(c, a) cf.spool() return 'dialed'
def localcall(): call_from = request.args.get('from', '') call_to = request.args.get('to', '') if call_from and call_to: cfrom = 'SIP/{}'.format(call_from) logging.debug(cfrom) cto = 'SIP/{}'.format(call_to) logging.debug(cto) c = Call(cfrom) a = Application('Dial', cto) cf = CallFile(c, a) cf.spool() else: return "no call made" return "call made"
def send_command(self, action: str, access_code: str) -> None: """ Send control sequence via Asterisk call file """ call = Call(f"SIP/{self.extension}", wait_time=self.wait_time, retry_time=self.retry_time, max_retries=self.max_retries) seq = self._build_dtmf_sequence(action, access_code) logger.debug("Sending action '%s' (DTMF: '%s') to alarm", action, seq) action = Application("SendDTMF", seq) callfile_args = {"archive": True, "spool_dir": self.spool_dir} if self.asterisk_user: callfile_args["user"] = self.asterisk_user c = CallFile(call, action, **callfile_args) c.spool()
from pycall import CallFile, Call, Application call = Call('SIP/flowroute/89257651079') action = Application('Playback', 'hello-world') c = CallFile(call, action) c.spool()
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: Joshua # @E-Mail: [email protected] # @Date: 2015-04-29 17:52:36 # @About test.py from pycall import CallFile, Call, Application call = Call('SIP/flowroute/13694182569') action = Application('Playback', 'hello-world') c = CallFile(call, action) c.spool()
def call(number, time=None): c = Call('SIP/flowroute/%s' % number) a = Application('Playback', 'hello-world') cf = CallFile(c, a) cf.spool(time)