From f01fde034c8395620565eaa5eb481e09d85f15f4 Mon Sep 17 00:00:00 2001 From: Traun Leyden Date: Sun, 13 Jul 2008 03:14:44 +0000 Subject: [PATCH] add debugging information git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9008 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- scripts/socket/freepy/README | 23 ++++++++++++++++++++++- scripts/socket/freepy/apirequest.sm | 10 +++++----- scripts/socket/freepy/apirequest_sm.py | 18 ++++++++++-------- scripts/socket/freepy/bgapirequest.sm | 8 ++++---- scripts/socket/freepy/bgapirequest_sm.py | 16 +++++++++------- scripts/socket/freepy/loginrequest.sm | 10 +++++----- scripts/socket/freepy/loginrequest_sm.py | 17 +++++++++-------- scripts/socket/freepy/request.py | 2 +- 8 files changed, 65 insertions(+), 39 deletions(-) diff --git a/scripts/socket/freepy/README b/scripts/socket/freepy/README index 9782c4b868..dae9520bdb 100644 --- a/scripts/socket/freepy/README +++ b/scripts/socket/freepy/README @@ -1,3 +1,24 @@ -Socket library to interface w/ freeswitch mod_event_socket from Twisted python applications. +DESCRIPTION +=========== + +Socket library to interface w/ freeswitch mod_event_socket from Twisted python applications. Used by WikiPBX for all non-http communication w/ Freeswitch. + +Install +======= + +See INSTALL + +Rebulding State Machines +======================== +for each .sm file: + +java -jar /usr/src/smc/bin/Smc.jar -python -g THE.sm + +and loginrequest.sm -> loginrequest_sm.py with the state machine. + +TODO: create a Makefile to do this stuff +TODO: use Miro Samek's HSM framework instead of SMC + + diff --git a/scripts/socket/freepy/apirequest.sm b/scripts/socket/freepy/apirequest.sm index b8575aa92d..dd04a6b9cb 100644 --- a/scripts/socket/freepy/apirequest.sm +++ b/scripts/socket/freepy/apirequest.sm @@ -61,35 +61,35 @@ Default nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting blank line"); } ContentFinished nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting content to be finished"); } ContentLength nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting content-length header"); } ApiResponse nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting api response"); } ProcessLine(line) nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting needing to process a line"); } } diff --git a/scripts/socket/freepy/apirequest_sm.py b/scripts/socket/freepy/apirequest_sm.py index 4be3787f4e..6b5b4147fe 100644 --- a/scripts/socket/freepy/apirequest_sm.py +++ b/scripts/socket/freepy/apirequest_sm.py @@ -1,8 +1,10 @@ - -# DO NOT MODIFY THIS CODE - AUTOMATICALLY GENERATED BY SMC +# DO NOT EDIT. +# generated by smc (http://smc.sourceforge.net/) +# from file : apirequest.sm import statemap + class ApiRequestState(statemap.State): def Entry(self, fsm): @@ -31,7 +33,7 @@ class ApiRequestState(statemap.State): fsm.getDebugStream().write('TRANSITION : Default\n') msg = "\n\tState: %s\n\tTransition: %s" % ( fsm.getState().getName(), fsm.getTransition()) - raise TransitionUndefinedException, msg + raise statemap.TransitionUndefinedException, msg class MainMap_Default(ApiRequestState): @@ -44,7 +46,7 @@ class MainMap_Default(ApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting blank line") finally: fsm.setState(endState) @@ -57,7 +59,7 @@ class MainMap_Default(ApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting content to be finished") finally: fsm.setState(endState) @@ -70,7 +72,7 @@ class MainMap_Default(ApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting content-length header") finally: fsm.setState(endState) @@ -83,7 +85,7 @@ class MainMap_Default(ApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting api response") finally: fsm.setState(endState) @@ -96,7 +98,7 @@ class MainMap_Default(ApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting needing to process a line") finally: fsm.setState(endState) diff --git a/scripts/socket/freepy/bgapirequest.sm b/scripts/socket/freepy/bgapirequest.sm index 5a8d4c17e6..258dabd112 100644 --- a/scripts/socket/freepy/bgapirequest.sm +++ b/scripts/socket/freepy/bgapirequest.sm @@ -43,28 +43,28 @@ Default nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting blank line"); } CommandReply nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting command reply"); } ReplyText nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting reply text"); } ProcessLine(line) nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting line needing to be processed"); } } diff --git a/scripts/socket/freepy/bgapirequest_sm.py b/scripts/socket/freepy/bgapirequest_sm.py index 1efde2f45b..c50076e700 100644 --- a/scripts/socket/freepy/bgapirequest_sm.py +++ b/scripts/socket/freepy/bgapirequest_sm.py @@ -1,8 +1,10 @@ - -# DO NOT MODIFY THIS CODE - AUTOMATICALLY GENERATED BY SMC +# DO NOT EDIT. +# generated by smc (http://smc.sourceforge.net/) +# from file : bgapirequest.sm import statemap + class BgApiRequestState(statemap.State): def Entry(self, fsm): @@ -28,7 +30,7 @@ class BgApiRequestState(statemap.State): fsm.getDebugStream().write('TRANSITION : Default\n') msg = "\n\tState: %s\n\tTransition: %s" % ( fsm.getState().getName(), fsm.getTransition()) - raise TransitionUndefinedException, msg + raise statemap.TransitionUndefinedException, msg class MainMap_Default(BgApiRequestState): @@ -41,7 +43,7 @@ class MainMap_Default(BgApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting blank line") finally: fsm.setState(endState) @@ -54,7 +56,7 @@ class MainMap_Default(BgApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting command reply") finally: fsm.setState(endState) @@ -67,7 +69,7 @@ class MainMap_Default(BgApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting reply text") finally: fsm.setState(endState) @@ -80,7 +82,7 @@ class MainMap_Default(BgApiRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting line needing to be processed") finally: fsm.setState(endState) diff --git a/scripts/socket/freepy/loginrequest.sm b/scripts/socket/freepy/loginrequest.sm index 245bbdd99e..64c3e98b99 100644 --- a/scripts/socket/freepy/loginrequest.sm +++ b/scripts/socket/freepy/loginrequest.sm @@ -57,35 +57,35 @@ Default nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - Was not expecting a blank line"); } AuthRequest nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - Was not expecting auth request"); } CommandReply nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting a command reply"); } ReplyText nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting reply text"); } ProcessLine(line) nil { setRequestFinished(); - errbackDeferred("Protocol failure"); + errbackDeferred("Protocol failure - was not expecting need to receive a line that needs to be processed"); } } diff --git a/scripts/socket/freepy/loginrequest_sm.py b/scripts/socket/freepy/loginrequest_sm.py index 70fa16e93c..2ebff4c084 100644 --- a/scripts/socket/freepy/loginrequest_sm.py +++ b/scripts/socket/freepy/loginrequest_sm.py @@ -1,5 +1,6 @@ - -# DO NOT MODIFY THIS CODE - AUTOMATICALLY GENERATED BY SMC +# DO NOT EDIT. +# generated by smc (http://smc.sourceforge.net/) +# from file : loginrequest.sm import statemap @@ -32,7 +33,7 @@ class LoginRequestState(statemap.State): fsm.getDebugStream().write('TRANSITION : Default\n') msg = "\n\tState: %s\n\tTransition: %s" % ( fsm.getState().getName(), fsm.getTransition()) - raise TransitionUndefinedException, msg + raise statemap.TransitionUndefinedException, msg class MainMap_Default(LoginRequestState): @@ -45,7 +46,7 @@ class MainMap_Default(LoginRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - Was not expecting a blank line") finally: fsm.setState(endState) @@ -58,7 +59,7 @@ class MainMap_Default(LoginRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - Was not expecting auth request") finally: fsm.setState(endState) @@ -71,7 +72,7 @@ class MainMap_Default(LoginRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting a command reply") finally: fsm.setState(endState) @@ -84,7 +85,7 @@ class MainMap_Default(LoginRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting reply text") finally: fsm.setState(endState) @@ -97,7 +98,7 @@ class MainMap_Default(LoginRequestState): fsm.clearState() try: ctxt.setRequestFinished() - ctxt.errbackDeferred("Protocol failure") + ctxt.errbackDeferred("Protocol failure - was not expecting need to receive a line that needs to be processed") finally: fsm.setState(endState) diff --git a/scripts/socket/freepy/request.py b/scripts/socket/freepy/request.py index 58a2c6a3ac..9f00a58fea 100644 --- a/scripts/socket/freepy/request.py +++ b/scripts/socket/freepy/request.py @@ -70,7 +70,7 @@ class FreepyRequest(object): self.deferred.callback(cbval) def errbackDeferred(self, result): - self.deferred.errback(result) + self.deferred.errback(Exception(str(result))) def process(self, line): """