Deal with EnvironmentErrors in handle_cli_exception too

This commit is contained in:
Garrett Holmstrom
2013-03-02 19:07:37 -08:00
parent 34d4635caf
commit 4f6c20171f
2 changed files with 10 additions and 1 deletions

View File

@@ -276,7 +276,15 @@ class BaseCommand(object):
return False
def handle_cli_exception(self, err):
print >> sys.stderr, 'error:', err.message
if isinstance(err, EnvironmentError):
# These don't have regular 'message' attributes, and they occur
# frequently enough they we handle them specially.
if hasattr(err, 'filename'):
print >> sys.stderr, 'error:', err.strerror + ':', err.filename
else:
print >> sys.stderr, 'error:', err.strerror
else:
print >> sys.stderr, 'error:', err.message or str(err)
if self.debug:
raise
sys.exit(1)

View File

@@ -14,6 +14,7 @@
from __future__ import absolute_import
import argparse
from functools import partial
import logging
import platform