code: def main(arguments, output=None, testing_mode=None):
      
  
      def run_command(arguments, output, reactor):
          if output is None:
              output = sys.stdout
          try:
              command = get_command(arguments, output)
          except UsageError:
              print >>output, USAGE_MESSAGE.strip()
              if reactor:
                  reactor.callLater(0, reactor.stop)
          except Exception, e:
              print >>output, "ERROR:", str(e)
              if reactor:
                  reactor.callLater(0, reactor.stop)
          else:
              deferred = command.run()
              if reactor:
                  deferred.addCallback(lambda ignored: reactor.stop())
  
      if not testing_mode:
          from twisted.internet import reactor
          reactor.callLater(0, run_command, arguments, output, reactor)
          reactor.run()
      else:
          run_command(arguments, output, None)
docs: Entry point parses command-line arguments, runs the specified EC2 API
      method and prints the response to the screen.
  
      @param arguments: Command-line arguments, typically retrieved from
          C{sys.argv}.
      @param output: Optionally, a stream to write output to.
      @param testing_mode: Optionally, a condition that specifies whether or not
          to run in test mode.  When the value is true a reactor will not be run
          or stopped, to prevent interfering with the test suite.