# HG changeset patch # User catherine.devlin@gmail.com # Date 1210948815 14400 # Node ID e72eb9137a87937ba342a2c67f3e64c63b33f9c9 # Parent c8efa4369189af815ec8b96de8d9a64d07b0dc24 trying fix for IOError crash in redirect diff -r c8efa4369189 -r e72eb9137a87 cmd2.py --- a/cmd2.py Thu May 15 17:38:15 2008 -0400 +++ b/cmd2.py Fri May 16 10:40:15 2008 -0400 @@ -72,7 +72,7 @@ if sys.platform[:3] == 'win': editor = 'notepad' else: - for editor in ['gedit', 'kate', 'vim', 'emacs', 'nano', 'pico']: + for editor in ['gedit', 'kate', 'vim', 'emacs', 'nano', 'pico', 'vi']: if not os.system('which %s' % (editor)): break @@ -160,7 +160,11 @@ if redirect: if mode in ('w','a'): statekeeper = Statekeeper(self, ('stdout',)) - self.stdout = open(redirect, mode) + try: + self.stdout = open(redirect, mode) + except IOError, e: + print str(e) + return 0 else: statement = '%s %s' % (statement, self.fileimport(statement=statement, source=redirect)) stop = cmd.Cmd.onecmd(self, statement) @@ -520,4 +524,4 @@ setattr(self, attrib, getattr(self.obj, attrib)) def restore(self): for attrib in self.attribs: - setattr(self.obj, attrib, getattr(self, attrib)) + setattr(self.obj, attrib, getattr(self, attrib)) \ No newline at end of file