Commits

Rob Lanphier committed 8073561

Helpful error messages in case urwid or simpleparse are missing

  • Participants
  • Parent commits 4976c49

Comments (0)

Files changed (3)

 Things to get done before version 0.1
 
 On deck:
-*  Graceful error on mismatched schema
 
 Roadmap
 0.1.0:
-*  Minimal check for urwid and simpleparse (and look for /etc/lsb-release to 
-   figure out the right error message)
 *  Improve documentation in __init__.py
 *  Put "Add field" over in the data area
 *  "Space" and "enter" should toggle expand/collapse on parent nodes
 *  Add alias for editing address books
 *  Remove hardcoded 20 character label column
 *  Remove hardcoded 13 character "Add field" button width
+*  Graceful error on mismatched schema
+*  Minimal check for urwid and simpleparse
 

jsonwidget/jsonorder.py

 # Licensed under BSD-style license.  See LICENSE.txt for details.
 
 
-import simpleparse
 import json
 
-from simpleparse.common import strings, numbers
+try:
+    import simpleparse
+    from simpleparse.common import strings, numbers
+except ImportError:
+    import sys
+    msg = """
+  jsonwidget.jsonorder requires simpleparse, which doesn't appear to be
+  installed.  
+  
+  The latest version of simpleparse for all systems can be found at:
+      http://simpleparse.sourceforge.net/
 
+  ...or in easy_install as "simpleparse"
+
+  On Debian and Ubuntu, simply install 'python-simpleparse'.
+
+"""
+    sys.stderr.writelines(msg)
+    sys.exit(2)
 
 class JsonOrderMapError(RuntimeError):
     pass

jsonwidget/termedit.py

     pass
 
 
-import json
-import urwid.curses_display
-import urwid
 import threading
 import sys
 import os
 import re
+import json
+
+try:
+    import urwid.curses_display
+    import urwid
+except ImportError:
+    msg = """
+  jsonwidget.termedit requires urwid 0.98 or higher, which doesn't appear to be
+  installed.  
+  
+  The latest version of urwid for all systems can be found at:
+    http://excess.org/urwid/
+
+  ...or in easy_install as "urwid"
+
+  On Debian and Ubuntu, simply install 'python-urwid' (and install 
+  'python-simpleparse' while you're at it).
+
+"""
+    sys.stderr.writelines(msg)
+    sys.exit(2)
 
 from jsonwidget.floatedit import FloatEdit
 from jsonwidget.schema import *