/usr/lib/python2.7/dist-packages/examples/connecttoivrapp.py is in python-starpy 1.0.1.0.git.20140806-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Example script to generate a call to connect a remote channel to an IVR
This version of the script uses the utilapplication framework and is
pared down for presentation on a series of slides
"""
from starpy import manager
import utilapplication
from twisted.internet import reactor
import sys, logging
APPLICATION = utilapplication.UtilApplication()
def main( channel = 'sip/4167290048@testout', connectTo=('outgoing','s','1') ):
df = APPLICATION.amiSpecifier.login()
def onLogin( protocol ):
"""We've logged into the manager, generate a call and log off"""
context, extension, priority = connectTo
df = protocol.originate(
channel,
context,extension,priority,
)
def onFinished( result ):
return protocol.logoff()
df.addCallbacks( onFinished, onFinished )
return df
def onFailure( reason ):
print reason.getTraceback()
def onFinished( result ):
reactor.stop()
df.addCallbacks(
onLogin, onFailure
).addCallbacks( onFinished, onFinished )
return df
if __name__ == "__main__":
logging.basicConfig()
reactor.callWhenRunning( main )
reactor.run()
|