misc of python pep8 fixes
This commit is contained in:
parent
39200cd13b
commit
b0e86e65cf
|
@ -31,6 +31,7 @@ from twisted.internet import reactor, defer
|
|||
from twisted.internet.protocol import ClientFactory
|
||||
import freepy
|
||||
|
||||
|
||||
class FsHelper(ClientFactory):
|
||||
|
||||
def __init__(self, host=None, passwd=None, port=None):
|
||||
|
@ -72,7 +73,6 @@ class FsHelper(ClientFactory):
|
|||
self.connection_deferred = None
|
||||
deferred2callback.callback("Connected")
|
||||
|
||||
|
||||
def generalError(self, failure):
|
||||
print "General error: %s" % failure
|
||||
return failure
|
||||
|
@ -128,9 +128,6 @@ class FsHelper(ClientFactory):
|
|||
d.addCallback(originate_inner)
|
||||
return d
|
||||
|
||||
|
||||
|
||||
|
||||
def dialconf(self, people2dial, conf_name, bgapi=True):
|
||||
"""
|
||||
conf_name - name of conf TODO: change to match db
|
||||
|
@ -215,7 +212,6 @@ class FsHelper(ClientFactory):
|
|||
d.addCallback(confdtmf_inner)
|
||||
return d
|
||||
|
||||
|
||||
def confsay(self, conf_name, text2speak, bgapi=True):
|
||||
"""
|
||||
conf_name - name of conf
|
||||
|
@ -268,7 +264,6 @@ class FsHelper(ClientFactory):
|
|||
d.addCallback(confstop_inner)
|
||||
return d
|
||||
|
||||
|
||||
def showchannels(self, bgapi=True):
|
||||
|
||||
def showchannels_inner(ignored):
|
||||
|
@ -289,7 +284,6 @@ class FsHelper(ClientFactory):
|
|||
d.addCallback(killchan_inner)
|
||||
return d
|
||||
|
||||
|
||||
def broadcast(self, uuid, path, legs="both", bgapi=True):
|
||||
"""
|
||||
@legs - one of the following strings: aleg|bleg|both
|
||||
|
@ -325,12 +319,10 @@ class FsHelper(ClientFactory):
|
|||
d.addCallback(sofia_profile_restart_inner)
|
||||
return d
|
||||
|
||||
|
||||
def sofia_status_profile(self, profile_name, bgapi=True):
|
||||
|
||||
def sofia_status_profile_inner(ignored):
|
||||
df = self.freepyd.sofia_status_profile(profile_name,
|
||||
bgapi)
|
||||
df = self.freepyd.sofia_status_profile(profile_name, bgapi)
|
||||
return df
|
||||
|
||||
d = self.connect()
|
||||
|
@ -340,7 +332,7 @@ class FsHelper(ClientFactory):
|
|||
|
||||
class FsHelperTest:
|
||||
def __init__(self, fshelper):
|
||||
self.fshelper=fshelper
|
||||
self.fshelper = fshelper
|
||||
pass
|
||||
|
||||
def test_dialconf(self):
|
||||
|
@ -349,10 +341,16 @@ class FsHelperTest:
|
|||
# called "freeswitch" on the local freeswitch instance.
|
||||
# one party is actually another conference, just to make
|
||||
# the example more confusing.
|
||||
people2dial = [{'name':'freeswitch',
|
||||
'number':'888@conference.freeswitch.org'},
|
||||
{'name':'mouselike',
|
||||
'number':'904@mouselike.org'}]
|
||||
people2dial = [
|
||||
{
|
||||
'name': 'freeswitch',
|
||||
'number': '888@conference.freeswitch.org'
|
||||
},
|
||||
{
|
||||
'name': 'mouselike',
|
||||
'number': ' 904@mouselike.org'
|
||||
}
|
||||
]
|
||||
d = self.fshelper.dialconf(people2dial, "freeswitch", bgapi=False)
|
||||
def failed(error):
|
||||
print "Failed to dial users!"
|
||||
|
@ -494,8 +492,7 @@ def test5():
|
|||
#reactor.stop()
|
||||
|
||||
for i in xrange(20):
|
||||
|
||||
party2dial="sofia/foo/600@192.168.1.202:5080"
|
||||
party2dial = "sofia/foo/600@192.168.1.202:5080"
|
||||
d = fshelper.originate(party2dial=party2dial,
|
||||
dest_ext_app="700",
|
||||
bgapi=True)
|
||||
|
@ -504,6 +501,7 @@ def test5():
|
|||
|
||||
reactor.run()
|
||||
|
||||
|
||||
def test6():
|
||||
"""
|
||||
show channels for a given sofia profile
|
||||
|
@ -524,7 +522,7 @@ def test6():
|
|||
reactor.run()
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
if __name__ == "__main__":
|
||||
#test1()
|
||||
#test2()
|
||||
#test3()
|
||||
|
|
|
@ -30,6 +30,7 @@ Data models for objects inside freeswitch
|
|||
|
||||
import re
|
||||
|
||||
|
||||
class ConfMember:
|
||||
|
||||
def __init__(self, rawstring):
|
||||
|
|
|
@ -2,24 +2,24 @@
|
|||
# http://wiki.freeswitch.org/wiki/Mod_python
|
||||
# before reporting errors
|
||||
|
||||
import sys, time
|
||||
from freeswitch import *
|
||||
|
||||
|
||||
def onDTMF(input, itype, funcargs):
|
||||
console_log("1","\n\nonDTMF input: %s\n" % input)
|
||||
console_log("1", "\n\nonDTMF input: %s\n" % input)
|
||||
if input == "5":
|
||||
return "pause"
|
||||
return "pause"
|
||||
if input == "3":
|
||||
return "seek:+60000"
|
||||
return "seek:+60000"
|
||||
if input == "1":
|
||||
return "seek:-60000"
|
||||
return "seek:-60000"
|
||||
if input == "0":
|
||||
return "stop"
|
||||
return None # will make the streamfile audio stop
|
||||
return "stop"
|
||||
return None # will make the streamfile audio stop
|
||||
|
||||
|
||||
def handler(uuid):
|
||||
|
||||
console_log("1","... test from my python program\n")
|
||||
console_log("1", "... test from my python program\n")
|
||||
session = PySession(uuid)
|
||||
session.answer()
|
||||
session.setDTMFCallback(onDTMF, "")
|
||||
|
@ -27,13 +27,12 @@ def handler(uuid):
|
|||
session.playFile("/path/to/your.mp3", "")
|
||||
session.speak("Please enter telephone number with area code and press pound sign. ")
|
||||
input = session.getDigits("", 11, "*#", "#", 10000)
|
||||
console_log("1","result from get digits is %s\n" % input)
|
||||
console_log("1", "result from get digits is %s\n" % input)
|
||||
phone_number = session.playAndGetDigits(5, 11, 3, 10000, "*#",
|
||||
"/sounds/test.gsm",
|
||||
"/sounds/invalid.gsm",
|
||||
"",
|
||||
"^17771112222$");
|
||||
console_log("1","result from play_and_get_digits is %s\n" % phone_number)
|
||||
"^17771112222$")
|
||||
console_log("1", "result from play_and_get_digits is %s\n" % phone_number)
|
||||
session.transfer("1000", "XML", "default")
|
||||
session.hangup("1")
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ from freeswitch import *
|
|||
from py_modules.speechtools import Grammar, SpeechDetect
|
||||
from py_modules.speechtools import SpeechObtainer
|
||||
|
||||
import time, os
|
||||
import os
|
||||
|
||||
VOICE_ENGINE = "cepstral"
|
||||
VOICE = "William"
|
||||
|
@ -20,24 +20,24 @@ How to make this work:
|
|||
|
||||
"""
|
||||
|
||||
|
||||
class RecipeWizard:
|
||||
|
||||
def __init__(self, session):
|
||||
self.session=session
|
||||
self.session = session
|
||||
self.session.set_tts_parms(VOICE_ENGINE, VOICE)
|
||||
self.main()
|
||||
|
||||
def main(self):
|
||||
|
||||
console_log("debug", "recipe wizard main()\n")
|
||||
self.speechdetect = SpeechDetect(self.session, "openmrcp", "127.0.0.1");
|
||||
self.speechdetect = SpeechDetect(self.session, "openmrcp", "127.0.0.1")
|
||||
self.speechobtainer = SpeechObtainer(speech_detect=self.speechdetect,
|
||||
required_phrases=1,
|
||||
wait_time=5000,
|
||||
max_tries=3)
|
||||
gfile = os.path.join(GRAMMAR_ROOT, "mainmenu.xml")
|
||||
self.grammar = Grammar("mainmenu", gfile,"input",80,90)
|
||||
self.speechobtainer.setGrammar(self.grammar);
|
||||
self.grammar = Grammar("mainmenu", gfile, "input", 80, 90)
|
||||
self.speechobtainer.setGrammar(self.grammar)
|
||||
console_log("debug", "calling speechobtainer.run()\n")
|
||||
self.speechobtainer.detectSpeech()
|
||||
self.session.speak("Hello. Welcome to the recipe wizard. Drinks or food?")
|
||||
|
@ -50,6 +50,7 @@ class RecipeWizard:
|
|||
|
||||
console_log("debug", "speechobtainer.run() finished\n")
|
||||
|
||||
|
||||
def mainmenu():
|
||||
"""
|
||||
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
||||
|
@ -78,10 +79,9 @@ def mainmenu():
|
|||
"""
|
||||
pass
|
||||
|
||||
|
||||
def handler(uuid):
|
||||
session = PySession(uuid)
|
||||
session.answer()
|
||||
rw = RecipeWizard(session)
|
||||
session.hangup("1")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue