summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2015-03-11 15:40:06 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2015-03-11 15:40:06 +0000
commit5153c068d02a31b23629b0cc383e85ef71bbf5cb (patch)
treeafd14e04988c301915d1740b58958ddb0a90bc44
parent956a0a2e73fc8f06e289788c22ed3f8ed574fb65 (diff)
downloadmorph-5153c068d02a31b23629b0cc383e85ef71bbf5cb.tar.gz
Make warning messages more user friendly.
Printing the file and line number of the warning's origin makes the warning itself harder to spot, and can make it appear as if something has actually gone wrong.
-rw-r--r--morphlib/app.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index b8bae850..fd4a3516 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -21,6 +21,7 @@ import pipes
import sys
import time
import urlparse
+import warnings
import extensions
import morphlib
@@ -214,6 +215,12 @@ class Morph(cliapp.Application):
with morphlib.util.hide_password_environment_variables(os.environ):
cliapp.Application.log_config(self)
+ def pretty_warnings(message, category, filename, lineno,
+ file=None, line=None):
+ return 'WARNING: %s' % (message)
+
+ warnings.formatwarning = pretty_warnings
+
def process_args(self, args):
self.check_time()