summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2015-03-18 18:16:23 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-04-01 17:57:19 +0000
commit06b4db06f3e5c29c10953cde04bccd97f09087cd (patch)
tree456e2269b67e66a826a74b96be6e1172d41d1eae
parentdadd9da92ca890705f65f3199e3ae740d9563a39 (diff)
downloadmorph-06b4db06f3e5c29c10953cde04bccd97f09087cd.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. Change-Id: Ie77357d9a061d31e234e6e434521d2d274409773
-rw-r--r--morphlib/app.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index b12b87de..42a346a1 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -20,6 +20,7 @@ import pipes
import sys
import time
import urlparse
+import warnings
import extensions
import morphlib
@@ -213,6 +214,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()