Example #1
0
 def quit(self):
     """Stops the view and the model by calling their 'stop' methods.
     Then wait for one second to let every procces stop and return to the
     'main' from where were started."""
     try:
         self.logger.debug("Stopping Guido van Robot...")
         self.View.stop()
     except:
         trace_error()
         pass
     try:
         self.Model.stop()
         time.sleep(1)
         self.logger.debug("Done")
     except:
         self.logger.exception("Failed to quit properly")
         pass
     return True
Example #2
0
 def quit(self):
     """Stops the view and the model by calling their 'stop' methods.
     Then wait for one second to let every procces stop and return to the
     'main' from where were started."""
     try:
         self.logger.debug("Stopping Guido van Robot...")
         self.View.stop()
     except:
         trace_error()
         pass
     try:
         self.Model.stop()
         time.sleep(1)
         self.logger.debug("Done")
     except:
         self.logger.exception("Failed to quit properly")
         pass
     return True
Example #3
0
 def on_code_execute(self, gui=None, step=None):
     """The controller calls this when the user hits the 'execute' button.
     When step is True the timer isn't started.
     This is the point from where the whole show starts."""
     self.logger.debug("on_code_execute called")
     worldlines = self.controller.get_worldwin_text()
     if _DEBUG > 1: print self.__class__, "worldlines", worldlines
     codelines = self.controller.get_codewin_text()
     if len(worldlines) == 0 or len(codelines) == 0:
         self.controller.give_warning(
             _("Please load a world and program before executing."))
         return None
     codestring = "\n".join(codelines)
     if _DEBUG > 1: print self.__class__, "codestring", codestring
     logicworld = self.on_world_reload(worldlines)
     if not logicworld:  # on_world_reload gives signals the controller in case of error
         return None
     # logicworld is made a class member because stepper doesn't pass the
     # logicworld object when it calls updateWorldBitmapAfterMove.
     # Because we want all the logic to use the same logicworld object we
     # made it a class member so that updateWorldBitmapAfterMove uses the
     # self.logicworld to pass on to the controller.
     # see also updateWorldBitmapAfterMove and GvrController.word_state_changed
     self.logicworld = logicworld
     # GuiWorld gets a GvrModel reference because it expects a object with a
     # updateWorldBitmapAfterMove(oldcoords) method which it calls when the
     # world state is changed.
     myGuiWorld = guiWorld.GuiWorld(self, logicworld)
     try:
         # stepper can be passed a object to highlight the current line of code
         # This object is 'debugger' which just provides the method stepper
         # calls: setLine
         # See stepper.Stepper.step
         self.myStepper = stepper.Stepper(codestring, myGuiWorld,
                                          self.controller)
     except gvrparser.BadCommand, info:
         utils.trace_error()
         self.controller.give_error(str(info))
Example #4
0
 def on_code_execute(self, gui=None, step=None):
     """The controller calls this when the user hits the 'execute' button.
     When step is True the timer isn't started.
     This is the point from where the whole show starts."""
     self.logger.debug("on_code_execute called")
     worldlines = self.controller.get_worldwin_text()
     if _DEBUG > 1:
         print self.__class__, "worldlines", worldlines
     codelines = self.controller.get_codewin_text()
     if len(worldlines) == 0 or len(codelines) == 0:
         self.controller.give_warning(_("Please load a world and program before executing."))
         return None
     codestring = "\n".join(codelines)
     if _DEBUG > 1:
         print self.__class__, "codestring", codestring
     logicworld = self.on_world_reload(worldlines)
     if not logicworld:  # on_world_reload gives signals the controller in case of error
         return None
     # logicworld is made a class member because stepper doesn't pass the
     # logicworld object when it calls updateWorldBitmapAfterMove.
     # Because we want all the logic to use the same logicworld object we
     # made it a class member so that updateWorldBitmapAfterMove uses the
     # self.logicworld to pass on to the controller.
     # see also updateWorldBitmapAfterMove and GvrController.word_state_changed
     self.logicworld = logicworld
     # GuiWorld gets a GvrModel reference because it expects a object with a
     # updateWorldBitmapAfterMove(oldcoords) method which it calls when the
     # world state is changed.
     myGuiWorld = guiWorld.GuiWorld(self, logicworld)
     try:
         # stepper can be passed a object to highlight the current line of code
         # This object is 'debugger' which just provides the method stepper
         # calls: setLine
         # See stepper.Stepper.step
         self.myStepper = stepper.Stepper(codestring, myGuiWorld, self.controller)
     except gvrparser.BadCommand, info:
         utils.trace_error()
         self.controller.give_error(str(info))