bgapirequest_sm.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. # DO NOT EDIT.
  2. # generated by smc (http://smc.sourceforge.net/)
  3. # from file : bgapirequest.sm
  4. import statemap
  5. class BgApiRequestState(statemap.State):
  6. def Entry(self, fsm):
  7. pass
  8. def Exit(self, fsm):
  9. pass
  10. def BlankLine(self, fsm):
  11. self.Default(fsm)
  12. def CommandReply(self, fsm):
  13. self.Default(fsm)
  14. def JobUuid(self, fsm):
  15. self.Default(fsm)
  16. def ProcessLine(self, fsm, line):
  17. self.Default(fsm)
  18. def ReplyText(self, fsm):
  19. self.Default(fsm)
  20. def Default(self, fsm):
  21. if fsm.getDebugFlag() == True:
  22. fsm.getDebugStream().write('TRANSITION : Default\n')
  23. msg = "\n\tState: %s\n\tTransition: %s" % (
  24. fsm.getState().getName(), fsm.getTransition())
  25. raise statemap.TransitionUndefinedException, msg
  26. class MainMap_Default(BgApiRequestState):
  27. def BlankLine(self, fsm):
  28. ctxt = fsm.getOwner()
  29. if fsm.getDebugFlag() == True:
  30. fsm.getDebugStream().write("TRANSITION : MainMap.Default.BlankLine()\n")
  31. endState = fsm.getState()
  32. fsm.clearState()
  33. try:
  34. ctxt.setRequestFinished()
  35. ctxt.errbackDeferred("Protocol failure - was not expecting blank line")
  36. finally:
  37. fsm.setState(endState)
  38. def CommandReply(self, fsm):
  39. ctxt = fsm.getOwner()
  40. if fsm.getDebugFlag() == True:
  41. fsm.getDebugStream().write("TRANSITION : MainMap.Default.CommandReply()\n")
  42. endState = fsm.getState()
  43. fsm.clearState()
  44. try:
  45. ctxt.setRequestFinished()
  46. ctxt.errbackDeferred("Protocol failure - was not expecting command reply")
  47. finally:
  48. fsm.setState(endState)
  49. def ReplyText(self, fsm):
  50. ctxt = fsm.getOwner()
  51. if fsm.getDebugFlag() == True:
  52. fsm.getDebugStream().write("TRANSITION : MainMap.Default.ReplyText()\n")
  53. endState = fsm.getState()
  54. fsm.clearState()
  55. try:
  56. ctxt.setRequestFinished()
  57. ctxt.errbackDeferred("Protocol failure - was not expecting reply text")
  58. finally:
  59. fsm.setState(endState)
  60. def ProcessLine(self, fsm, line):
  61. ctxt = fsm.getOwner()
  62. if fsm.getDebugFlag() == True:
  63. fsm.getDebugStream().write("TRANSITION : MainMap.Default.ProcessLine(line)\n")
  64. endState = fsm.getState()
  65. fsm.clearState()
  66. try:
  67. ctxt.setRequestFinished()
  68. ctxt.errbackDeferred("Protocol failure handling bgapi response - was not expecting line needing to be processed")
  69. finally:
  70. fsm.setState(endState)
  71. class MainMap_Startup(MainMap_Default):
  72. def CommandReply(self, fsm):
  73. if fsm.getDebugFlag() == True:
  74. fsm.getDebugStream().write("TRANSITION : MainMap.Startup.CommandReply()\n")
  75. fsm.getState().Exit(fsm)
  76. fsm.setState(MainMap.ApiResponseStarted)
  77. fsm.getState().Entry(fsm)
  78. class MainMap_ApiResponseStarted(MainMap_Default):
  79. def ReplyText(self, fsm):
  80. if fsm.getDebugFlag() == True:
  81. fsm.getDebugStream().write("TRANSITION : MainMap.ApiResponseStarted.ReplyText()\n")
  82. fsm.getState().Exit(fsm)
  83. fsm.setState(MainMap.GotReplyText)
  84. fsm.getState().Entry(fsm)
  85. class MainMap_GotReplyText(MainMap_Default):
  86. def BlankLine(self, fsm):
  87. if fsm.getDebugFlag() == True:
  88. fsm.getDebugStream().write("TRANSITION : MainMap.GotReplyText.BlankLine()\n")
  89. def JobUuid(self, fsm):
  90. ctxt = fsm.getOwner()
  91. if fsm.getDebugFlag() == True:
  92. fsm.getDebugStream().write("TRANSITION : MainMap.GotReplyText.JobUuid()\n")
  93. fsm.getState().Exit(fsm)
  94. fsm.clearState()
  95. try:
  96. ctxt.setRequestFinished()
  97. ctxt.callOrErrback()
  98. finally:
  99. fsm.setState(MainMap.Startup)
  100. fsm.getState().Entry(fsm)
  101. class MainMap:
  102. Startup = MainMap_Startup('MainMap.Startup', 0)
  103. ApiResponseStarted = MainMap_ApiResponseStarted('MainMap.ApiResponseStarted', 1)
  104. GotReplyText = MainMap_GotReplyText('MainMap.GotReplyText', 2)
  105. Default = MainMap_Default('MainMap.Default', -1)
  106. class BgApiRequest_sm(statemap.FSMContext):
  107. def __init__(self, owner):
  108. statemap.FSMContext.__init__(self)
  109. self._owner = owner
  110. self.setState(MainMap.Startup)
  111. MainMap.Startup.Entry(self)
  112. def BlankLine(self):
  113. self._transition = 'BlankLine'
  114. self.getState().BlankLine(self)
  115. self._transition = None
  116. def CommandReply(self):
  117. self._transition = 'CommandReply'
  118. self.getState().CommandReply(self)
  119. self._transition = None
  120. def JobUuid(self):
  121. self._transition = 'JobUuid'
  122. self.getState().JobUuid(self)
  123. self._transition = None
  124. def ProcessLine(self, *arglist):
  125. self._transition = 'ProcessLine'
  126. self.getState().ProcessLine(self, *arglist)
  127. self._transition = None
  128. def ReplyText(self):
  129. self._transition = 'ReplyText'
  130. self.getState().ReplyText(self)
  131. self._transition = None
  132. def getState(self):
  133. if self._state == None:
  134. raise statemap.StateUndefinedException
  135. return self._state
  136. def getOwner(self):
  137. return self._owner