mirror of https://github.com/sipwise/sems.git
git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@177 8eb893ce-cfd4-0310-b710-fb5ebe64c474
parent
1552290ddb
commit
68466deda1
@ -0,0 +1,54 @@
|
||||
|
||||
NAME=pincollect
|
||||
VERSION=2.3.0-1
|
||||
|
||||
PYTHON_VERSION=2.3
|
||||
|
||||
LIBDIR=.
|
||||
LIB_INSTALLDIR="/usr/lib/sems/ivr"
|
||||
TARBALL_PREFIX=sems-app-${NAME}
|
||||
TARBALL="${TARBALL_PREFIX}-${VERSION}.tar.gz"
|
||||
|
||||
BASEDIR?=${basedir}
|
||||
|
||||
GROUP="root"
|
||||
OWNER="root"
|
||||
|
||||
BIN_PERMISSIONS="755"
|
||||
LIB_PERMISSIONS="644"
|
||||
|
||||
PYCHECKERARGS = --stdlib
|
||||
PYCHECKERDOCARGS = --classdoc --funcdoc
|
||||
|
||||
.PHONY: all
|
||||
all: clean compile
|
||||
|
||||
clean:
|
||||
find . -iname "*\.pyc" -o -iname "*\.py~" | xargs rm -f
|
||||
rm -f ${TARBALL_PREFIX}*.tar.gz
|
||||
|
||||
compile:
|
||||
/usr/bin/python${PYTHON_VERSION} /usr/lib/python${PYTHON_VERSION}/compileall.py -q ${LIBDIR}
|
||||
|
||||
install: all
|
||||
install -d ${BASEDIR}/${LIB_INSTALLDIR}
|
||||
install -m ${LIB_PERMISSIONS} -o ${OWNER} -g ${GROUP} ${LIBDIR}/*.pyc ${BASEDIR}/${LIB_INSTALLDIR}
|
||||
|
||||
uninstall:
|
||||
@echo "please remove the files from ${LIB_INSTALLDIR} manually."
|
||||
|
||||
fulltest:
|
||||
find | grep /Test | grep -v ".svn" | grep \\.py$$ | sed -e "s#^./##g" | bash -e -
|
||||
|
||||
check:
|
||||
find ${LIBDIR}/ | grep \\.py$$ | grep -v Test | PYTHONPATH=$(PYTHONPATH):../ivr/moc xargs pychecker ${PYCHECKERARGS}
|
||||
|
||||
doccheck:
|
||||
find ${LIBDIR}/ | grep \\.py$$ | grep -v Test | xargs pychecker ${PYCHECKERARGS} ${PYCHECKERDOCARGS}
|
||||
|
||||
dist: all
|
||||
tar -cvzf ${TARBALL} . --exclude=*.tar.gz \
|
||||
--exclude=.svn \
|
||||
--exclude=*~
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
welcome_msg=/usr/lib/sems/audio/pincollect/welcome.wav
|
||||
pin_msg=/usr/lib/sems/audio/pincollect/enter_pin.wav
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
from log import *
|
||||
from ivr import *
|
||||
|
||||
collect = 0
|
||||
connect = 1
|
||||
connected = 2
|
||||
|
||||
HINT_TIMER = 1
|
||||
HINT_TIMEOUT = 10 # seconds until hint msg is played
|
||||
|
||||
CONF_TIMER = 2
|
||||
|
||||
# def loopedTTS(str):
|
||||
# af = IvrAudioFile.tts(str)
|
||||
# af.loop = True
|
||||
# return af
|
||||
|
||||
class IvrDialog(IvrDialogBase):
|
||||
|
||||
welcome_msg = None
|
||||
auth_ok_msg = None
|
||||
auth_fail_msg = None
|
||||
pin_msg = None
|
||||
|
||||
state = collect
|
||||
keys = ''
|
||||
|
||||
conf_to = ''
|
||||
conf_uri = ''
|
||||
conf_duration = 0
|
||||
conf_participants = 0
|
||||
|
||||
def sessionInfo(self):
|
||||
debug("IVR Session info:")
|
||||
debug(" user: " + self.dialog.user)
|
||||
debug(" domain: " + self.dialog.domain)
|
||||
debug(" sip_ip: " + self.dialog.sip_ip)
|
||||
debug(" sip_port: " + self.dialog.sip_port)
|
||||
debug(" local_uri: " + self.dialog.local_uri)
|
||||
debug(" remote_uri: " + self.dialog.remote_uri)
|
||||
debug(" contact_uri: " + self.dialog.contact_uri)
|
||||
debug(" callid: " + self.dialog.callid)
|
||||
debug(" remote_tag: " + self.dialog.remote_tag)
|
||||
debug(" local_tag: " + self.dialog.local_tag)
|
||||
debug(" remote_party:" + self.dialog.remote_party)
|
||||
debug(" local_party: " + self.dialog.local_party)
|
||||
debug(" route: " + self.dialog.route)
|
||||
debug(" next_hop: " + self.dialog.next_hop)
|
||||
debug(" cseq: " + str(self.dialog.cseq))
|
||||
|
||||
def onSessionStart(self,hdrs):
|
||||
self.sessionInfo()
|
||||
self.setNoRelayonly()
|
||||
|
||||
self.welcome_msg = IvrAudioFile()
|
||||
self.welcome_msg.open(config['welcome_msg'],AUDIO_READ)
|
||||
|
||||
self.pin_msg = IvrAudioFile()
|
||||
self.pin_msg.open(config['pin_msg'],AUDIO_READ)
|
||||
|
||||
self.enqueue(self.welcome_msg,None)
|
||||
self.enqueue(self.pin_msg,None)
|
||||
|
||||
def onBye(self):
|
||||
self.stopSession()
|
||||
|
||||
def onDtmf(self,key,duration):
|
||||
if self.state == collect:
|
||||
if key < 10:
|
||||
self.keys += str(key)
|
||||
debug("added key, PIN = " + self.keys)
|
||||
self.setTimer(HINT_TIMER, HINT_TIMEOUT)
|
||||
elif key == 10:
|
||||
self.state = connect
|
||||
self.removeTimer(HINT_TIMER)
|
||||
self.redirect("sip:" + self.dialog.user + \
|
||||
self.keys + "@" + \
|
||||
self.dialog.domain)
|
||||
self.stopSession()
|
||||
|
||||
def onEmptyQueue(self):
|
||||
if self.state == collect:
|
||||
self.setTimer(HINT_TIMER, HINT_TIMEOUT)
|
||||
|
||||
def onTimer(self, id):
|
||||
if id == HINT_TIMER and self.state == collect:
|
||||
self.enqueue(self.pin_msg, None)
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue