+ return (ui_to_command, command_to_ui, command)
+
+ def _cleanup_run(self, ui_to_command, command_to_ui, command):
+ log = logging.getLogger('hooke')
+ log.debug('cleanup sending CloseEngine')
+ ui_to_command.put(ui.CloseEngine())
+ hooke = None
+ while not isinstance(hooke, Hooke):
+ log.debug('cleanup waiting for Hooke instance from the engine.')
+ hooke = command_to_ui.get(block=True)
+ log.debug('cleanup got %s instance' % type(hooke))
+ command.join()
+ return hooke
+
+
+def main():
+ p = optparse.OptionParser()
+ p.add_option(
+ '--version', dest='version', default=False, action='store_true',
+ help="Print Hooke's version information and exit.")
+ p.add_option(
+ '-s', '--script', dest='script', metavar='FILE',
+ help='Script of command line Hooke commands to run.')
+ p.add_option(
+ '-c', '--command', dest='commands', metavar='COMMAND',
+ action='append', default=[],
+ help='Add a command line Hooke command to run.')
+ p.add_option(
+ '--command-no-exit', dest='command_exit',
+ action='store_false', default=True,
+ help="Don't exit after running a script or commands.")
+ options,arguments = p.parse_args()
+ if len(arguments) > 0:
+ print >> sys.stderr, 'More than 0 arguments to %s: %s' \
+ % (sys.argv[0], arguments)
+ p.print_help(sys.stderr)
+ sys.exit(1)
+
+ hooke = Hooke(debug=__debug__)
+ runner = HookeRunner()
+
+ if options.version == True:
+ print version()
+ sys.exit(0)
+ if options.script != None:
+ with open(os.path.expanduser(options.script), 'r') as f:
+ options.commands.extend(f.readlines())
+ if len(options.commands) > 0: