[Freeswitch-svn] [commit] r5957 - freeswitch/trunk/scripts/socket/freepy
Freeswitch SVN
greenlizard at freeswitch.org
Wed Oct 17 21:38:17 EDT 2007
Author: greenlizard
Date: Wed Oct 17 21:38:17 2007
New Revision: 5957
Modified:
freeswitch/trunk/scripts/socket/freepy/fseventlistener.py
freeswitch/trunk/scripts/socket/freepy/fshelper.py
Log:
add some tests,examples to fshelper, clean up the reconnect error message in fseventlistener
Modified: freeswitch/trunk/scripts/socket/freepy/fseventlistener.py
==============================================================================
--- freeswitch/trunk/scripts/socket/freepy/fseventlistener.py (original)
+++ freeswitch/trunk/scripts/socket/freepy/fseventlistener.py Wed Oct 17 21:38:17 2007
@@ -213,13 +213,17 @@
self.protocol = None
def clientConnectionFailed(self, connector, reason):
- print "clientConnectionFailed! conn=%s, reason=%s" % (connector,
- reason)
- #self.protocol = None
+
if self.num_attempts < 100:
- self.num_attempts += 1
+ self.num_attempts += 1
+ print "Connection refused, retrying attempt #%s in 5 seconds" % \
+ (self.num_attempts)
return reactor.callLater(5, self.connect)
else:
+ print "clientConnectionFailed! conn=%s, reason=%s" % (connector,
+ reason)
+ print ("Retry attempts exhausted, total attempts: %s" %
+ self.num_attempts)
deferred2callback = self.connection_deferred
deferred2callback.errback(reason)
Modified: freeswitch/trunk/scripts/socket/freepy/fshelper.py
==============================================================================
--- freeswitch/trunk/scripts/socket/freepy/fshelper.py (original)
+++ freeswitch/trunk/scripts/socket/freepy/fshelper.py Wed Oct 17 21:38:17 2007
@@ -321,6 +321,10 @@
def test_dialconf(self):
+ # the following parties will be dialed out from the conference
+ # 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 at conference.freeswitch.org'},
{'name':'mouselike',
@@ -333,7 +337,6 @@
d.addErrback(failed)
def worked(*args):
print "Worked! Dialed user result: %s" % str(args)
- #reactor.stop()
d.addCallback(worked)
return d
@@ -366,7 +369,9 @@
def test1():
kick_everyone = False
- fshelper = FsHelper("mydomain.com")
+ fshelper = FsHelper(host="127.0.0.1",
+ passwd="ClueCon",
+ port=8021)
fsht = FsHelperTest(fshelper)
fsht.test_dialconf()
d = fsht.test_listconf()
@@ -391,10 +396,113 @@
reactor.run()
def test2():
- fshelper = FsHelper("mydomain.com")
+ fshelper = FsHelper(host="127.0.0.1",
+ passwd="ClueCon",
+ port=8021)
fshelper.sofia_profile_restart("mydomain.com")
reactor.run()
+
+def test3():
+ fshelper = FsHelper(host="127.0.0.1",
+ passwd="ClueCon",
+ port=8021)
+ print "Calling originate.."
+ party2dial="sofia/foo/600 at 192.168.1.202:5080"
+ d = fshelper.originate(party2dial=party2dial,
+ dest_ext_app="101",
+ bgapi=True)
+
+ def worked(result):
+ print "Originate succeeded: %s" % result
+ reactor.stop()
+
+ def failed(failure):
+ print "failed: %s" % str(failure)
+ reactor.stop()
+
+ d.addCallback(worked)
+ d.addErrback(failed)
+ reactor.run()
+
+
+def test4():
+ fshelper = FsHelper(host="127.0.0.1",
+ passwd="ClueCon",
+ port=8021)
+
+ def worked(result):
+ print "Originate succeeded: %s" % result
+ #reactor.stop()
+
+ def failed(failure):
+ print "failed: %s" % str(failure)
+ #reactor.stop()
+
+
+ dest_ext_app = "101"
+ party2dial="sofia/foo/600 at 192.168.1.202:5080"
+ d = fshelper.originate(party2dial=party2dial,
+ dest_ext_app=dest_ext_app,
+ bgapi=True)
+ d.addCallback(worked)
+ d.addErrback(failed)
+ party2dial="sofia/foo/someone at bar.com"
+ d2 = fshelper.originate(party2dial=party2dial,
+ dest_ext_app=dest_ext_app,
+ bgapi=True)
+
+ d2.addCallback(worked)
+ d2.addErrback(failed)
+ reactor.run()
+
+
+def test5():
+ fshelper = FsHelper(host="127.0.0.1",
+ passwd="ClueCon",
+ port=8021)
+
+ def worked(result):
+ print "Originate succeeded: %s" % result
+ #reactor.stop()
+
+ def failed(failure):
+ print "failed: %s" % str(failure)
+ #reactor.stop()
+
+ for i in xrange(20):
+
+ party2dial="sofia/foo/600 at 192.168.1.202:5080"
+ d = fshelper.originate(party2dial=party2dial,
+ dest_ext_app="700",
+ bgapi=True)
+ d.addCallback(worked)
+ d.addErrback(failed)
+
+ reactor.run()
+
+def test6():
+ """
+ show channels for a given sofia profile
+ """
+ fshelper = FsHelper(host="127.0.0.1",
+ passwd="ClueCon",
+ port=8021)
+ from wikipbx import channelsutil
+ def show_chanels(raw_xml):
+ print raw_xml
+ def failure(failure):
+ print failure
+
+ d = fshelper.showchannels(bgapi=False)
+ d.addCallback(show_chanels)
+ d.addErrback(failure)
+ reactor.run()
+
+
if __name__=="__main__":
#test1()
- test2()
+ #test2()
+ #test3()
+ test4()
+ #test5()
More information about the Freeswitch-svn
mailing list