summaryrefslogtreecommitdiff
path: root/src/python/m5/util
diff options
context:
space:
mode:
authorSascha Bischoff <sascha.bischoff@arm.com>2013-02-15 17:40:10 -0500
committerSascha Bischoff <sascha.bischoff@arm.com>2013-02-15 17:40:10 -0500
commit2f3b322280a742069fd8965d723a2205a4a8cc00 (patch)
tree8c40a9c9397e5ffdb2a3382fd2b4766b6ac13977 /src/python/m5/util
parente88e7d88b9a9876ee040dad96acf3deabebe1fa7 (diff)
downloadgem5-2f3b322280a742069fd8965d723a2205a4a8cc00.tar.xz
base: Add warn() and inform() to m5.utils for use from python
This patch adds two fuctions to m5.util, warn and inform, which mirror those found in the C++ side of gem5. These are added in addition to the already existing m5.util.panic and m5.util.fatal which already mirror the C++ functionality. This ensures that warning and information messages generated by python are in the same format as those generated by C++. Occurrences of print "Warning: %s..." % name have been replaced with warn("%s...", name)
Diffstat (limited to 'src/python/m5/util')
-rw-r--r--src/python/m5/util/__init__.py11
-rw-r--r--src/python/m5/util/dot_writer.py3
2 files changed, 13 insertions, 1 deletions
diff --git a/src/python/m5/util/__init__.py b/src/python/m5/util/__init__.py
index 591781977..66ebb3cfe 100644
--- a/src/python/m5/util/__init__.py
+++ b/src/python/m5/util/__init__.py
@@ -56,6 +56,17 @@ def fatal(fmt, *args):
print >>sys.stderr, 'fatal:', fmt % args
sys.exit(1)
+# warn() should be called when the user should be warned about some condition
+# that may or may not be the user's fault, but that they should be made aware
+# of as it may affect the simulation or results.
+def warn(fmt, *args):
+ print >>sys.stderr, 'warn:', fmt % args
+
+# inform() should be called when the user should be informed about some
+# condition that they may be interested in.
+def inform(fmt, *args):
+ print >>sys.stdout, 'info:', fmt % args
+
class Singleton(type):
def __call__(cls, *args, **kwargs):
if hasattr(cls, '_instance'):
diff --git a/src/python/m5/util/dot_writer.py b/src/python/m5/util/dot_writer.py
index c1c5ff3ac..52d0b4b62 100644
--- a/src/python/m5/util/dot_writer.py
+++ b/src/python/m5/util/dot_writer.py
@@ -57,6 +57,7 @@
import m5, os, re
from m5.SimObject import isRoot, isSimObjectVector
+from m5.util import warn
try:
import pydot
except:
@@ -176,4 +177,4 @@ def do_dot(root, outdir, dotFilename):
# So avoid terminating simulation unnecessarily
callgraph.write_pdf(dot_filename + ".pdf")
except:
- print "warning: failed to generate pdf output from %s" % dot_filename
+ warn("failed to generate pdf output from %s", dot_filename)