Beispiel #1
0
 def Process():
     toy = Robot()
     try:
         print("\n")
         print("Welcome to the Toy Robot application.\n")
         print("Proceed to enter commands. Press CTRL-C to exit.\n")
         # Loop until we receive a kill signal.
         while True:
             # BUG: Change to input() for Python 3.x
             line = raw_input("> ")
             try:
                 # Parse the command.
                 cmd = Command(line)
                 # Execute the validated command on the robot.
                 cmd.Execute(toy)
             except CommandException as ce:
                 print(ce)
             except RobotException as re:
                 print(re)
             except CompassHeadingException as he:
                 print(he)
     except KeyboardInterrupt as kb:
         print("Keyboard exit signal detected.")
         pass
     finally:
         print("Exit requested.")
         toy.Cleanup()
         print("Application successfully exited.")
     return