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