[Zope-CVS] CVS: Products/ExternalEditor - zopeedit.py:1.16

Casey Duncan casey@zope.com
Tue, 11 Jun 2002 17:01:18 -0400


Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv6946

Modified Files:
	zopeedit.py 
Log Message:
Added useful usage error message
Re-enabled asking for editor on Unix
Always print tracebacks on errors


=== Products/ExternalEditor/zopeedit.py 1.15 => 1.16 ===
             # Read the configuration file
             if win32:
-                config_path = path.expanduser('~\ZopeExternalEdit.ini')
+                config_path = path.expanduser('~\ZopeEdit.ini')
             else:
                 config_path = path.expanduser('~/.zope-external-edit')
                 
@@ -176,15 +176,15 @@
     def getEditorCommand(self):
         """Return the editor command"""
         editor = self.options.get('editor')
-        """
-        if not editor and has_tk():
+
+        if not editor and not win32 and has_tk():
             from tkSimpleDialog import askstring
             editor = askstring('Zope External Editor', 
                                'Enter the command to launch the default editor')
             if not editor: sys.exit(0)
             self.config.set('general', 'editor', path)
             self.config.save()
-        """ 
+
         if editor is not None:            
             return editor
         else:
@@ -391,6 +391,7 @@
 
     def errorDialog(message):
         MessageBox(message, title, 16)
+        sys.stderr.write(message + '\n')
 
     def askRetryCancel(message):
         return MessageBox(message, title, 53) == 4
@@ -443,7 +444,7 @@
                 showerror(title, message)
                 has_tk()
         finally:
-            sys.stderr.write(message)
+            sys.stderr.write(message + '\n')
 
     def askRetryCancel(message):
         if has_tk():
@@ -481,6 +482,7 @@
 def fatalError(message, exit=1):
     """Show error message and exit"""
     errorDialog('FATAL ERROR: %s' % message)
+    traceback.print_exc(file=sys.stderr)
     if exit: 
         sys.exit(0)
 
@@ -567,11 +569,15 @@
 
 if __name__ == '__main__':
     try:
-        ExternalEditor(sys.argv[1]).launch()
+        input_file = sys.argv[1]
+    except IndexError:
+        fatalError('Input file name missing.\n'
+                   'Usage: zopeedit.py inputfile')
+    try:
+        ExternalEditor(input_file).launch()
     except KeyboardInterrupt:
         pass
     except SystemExit:
         pass
     except:
-        fatalError(sys.exc_info()[1],0)
-        raise
+        fatalError(sys.exc_info()[1])