summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2015-03-18 18:16:23 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2015-03-23 16:32:46 +0000
commitf0167fddfd909ed6b5f4252f55504288dcb16405 (patch)
treea21d282172af77bb42df62426b0c8da9db5c6674
parentc02108737c15651950cbf9e85e535be3800800a9 (diff)
downloadmorph-f0167fddfd909ed6b5f4252f55504288dcb16405.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 c8fe397d..654451f4 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()