qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 11/11] trace: [tracetool] Add error-reporting fun


From: Lluís Vilanova
Subject: [Qemu-devel] [PATCH v3 11/11] trace: [tracetool] Add error-reporting functions
Date: Fri, 10 Feb 2012 12:49:50 +0100
User-agent: StGit/0.15

Signed-off-by: Lluís Vilanova <address@hidden>
---
 scripts/tracetool.py |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 1134544..7053a74 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -12,6 +12,13 @@ import sys
 import getopt
 
 
+def error_write(*lines):
+    sys.stderr.writelines(lines)
+
+def error(*lines):
+    error_write(*lines)
+    sys.exit(1)
+
 
 ######################################################################
 # format auto-registration
@@ -443,14 +450,11 @@ def dtrace_nop_d(events):
 def trace_stap_begin(events):
     global probeprefix
     if binary == "":
-        print '--binary is required for SystemTAP tapset generator'
-        sys.exit(1)
+        error("--binary is required for SystemTAP tapset generator\n")
     if ((probeprefix == "") and (targettype == "")):
-        print '--target-type is required for SystemTAP tapset generator'
-        sys.exit(1)
+        error("--target-type is required for SystemTAP tapset generator\n")
     if ((probeprefix == "") and (targetarch == "")):
-        print '--target-arch is required for SystemTAP tapset generator'
-        sys.exit(1)
+        error("--target-arch is required for SystemTAP tapset generator\n")
     if probeprefix == "":
         probeprefix = 'qemu.' + targettype + '.' + targetarch
     print '/* This file is autogenerated by tracetool, do not edit. */'
@@ -601,8 +605,9 @@ def main():
     try:
         opts, args = getopt.getopt(sys.argv[1:], "", long_options)
     except getopt.GetoptError, err:
-        # print help information and exit:
-        print str(err) # will print something like "option -a not recognized"
+        # print help information and exit
+        # will print something like "option -a not recognized"
+        error_write(str(err)+"\n")
         usage()
         sys.exit(2)
     for opt, arg in opts:
@@ -631,12 +636,10 @@ def main():
             usage()
 
     if format_ not in _formats:
-        print "Unknown format: %s" % format_
-        print
+        error_write("Unknown format: %s\n\n" % format_)
         usage()
     if backend not in _backends:
-        print "Unknown backend: %s" % backend
-        print
+        error_write("Unknown backend: %s\n\n" % backend)
         usage()
 
     events = read_events(sys.stdin)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]