From fee23499de6f2628bf81a8a73aa3e9d1c3fbafdc Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 10 Aug 2010 15:49:48 -0400 Subject: [PATCH] Add --command-no-exit to bin/hooke, making hardcoded testing calls to execute_command() in gui superfluous. --- hooke/hooke.py | 14 +++++++++----- hooke/ui/gui/__init__.py | 13 ------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/hooke/hooke.py b/hooke/hooke.py index 52834df..54f0f0f 100644 --- a/hooke/hooke.py +++ b/hooke/hooke.py @@ -182,6 +182,10 @@ def main(): '-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' \ @@ -196,15 +200,15 @@ def main(): print version() sys.exit(0) if options.script != None: - f = open(os.path.expanduser(options.script), 'r') - options.commands.extend(f.readlines()) - f.close + with open(os.path.expanduser(options.script), 'r') as f: + options.commands.extend(f.readlines()) if len(options.commands) > 0: try: hooke = runner.run_lines(hooke, options.commands) finally: - hooke.close() - sys.exit(0) + if options.command_exit == True: + hooke.close() + sys.exit(0) try: hooke = runner.run(hooke) diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index 1c646f4..38bf191 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -114,19 +114,6 @@ class HookeFrame (wx.Frame): self._setup_perspectives() self._bind_events() - - self.execute_command( - command=self._command_by_name('load playlist'), - args={'input':'test/data/test'},#vclamp_picoforce/playlist'}, - ) - self.execute_command( - command=self._command_by_name('load playlist'), - args={'input':'test/data/vclamp_picoforce/playlist'}, - ) - self.execute_command( - command=self._command_by_name('polymer fit'), - args={'block':1, 'bounds':[918, 1103]}, - ) return # TODO: cleanup self.playlists = self._c['playlist'].Playlists self._displayed_plot = None -- 2.26.2