Permalink
Browse files

Pull in wolever traceback improvements for jinja2, paramiko

Re #450
  • Loading branch information...
1 parent e5ad1a7 commit a822145e91627b397e3b739f954c6ccaea9e7b44 @bitprophet bitprophet committed Nov 23, 2011
Showing with 13 additions and 7 deletions.
  1. +1 −0 AUTHORS
  2. +2 −0 docs/changelog.rst
  3. +4 −2 fabric/contrib/files.py
  4. +6 −5 fabric/network.py
View
@@ -46,3 +46,4 @@ Matt Chisholm
Mark Merritt
Max Arnold
Szymon Reichmann
+David Wolever
View
@@ -25,6 +25,8 @@ would have also been included in the 1.2 line.
Changelog
=========
+* :bug:`450` Improve traceback display when handling ``ImportError``s for
+ dependencies. Thanks to David Wolever for the patches.
* :bug:`446` Add QNX to list of secondary-case `~fabric.contrib.files.sed`
targets. Thanks to Rodrigo Madruga for the tip.
* :bug:`443` `~fabric.contrib.files.exists` didn't expand tildes; now it does.
View
@@ -101,8 +101,10 @@ def upload_template(filename, destination, context=None, use_jinja=False,
from jinja2 import Environment, FileSystemLoader
jenv = Environment(loader=FileSystemLoader(template_dir or '.'))
text = jenv.get_template(filename).render(**context or {})
- except ImportError, e:
- abort("tried to use Jinja2 but was unable to import: %s" % e)
+ except ImportError:
+ import traceback
+ tb = traceback.format_exc()
+ abort(tb + "\nUnable to import Jinja2 -- see above.")
else:
with open(filename) as inputfile:
text = inputfile.read()
View
@@ -18,11 +18,12 @@
warnings.simplefilter('ignore', DeprecationWarning)
import paramiko as ssh
except ImportError, e:
- print >> sys.stderr, """There was a problem importing our SSH library. Specifically:
-
- %s
-
-Please make sure all dependencies are installed and importable.""" % e
+ import traceback
+ traceback.print_exc()
+ print >> sys.stderr, """
+There was a problem importing our SSH library (see traceback above).
+Please make sure all dependencies are installed and importable.
+""".rstrip()
sys.exit(1)

0 comments on commit a822145

Please sign in to comment.