[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/12] trace: [tracetool] Add error-reporting functi
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH 12/12] trace: [tracetool] Add error-reporting functions |
Date: |
Tue, 13 Mar 2012 21:03:43 +0100 |
User-agent: |
StGit/0.16 |
Unifies the print+exit sequence into a single 'error' call.
Signed-off-by: Lluís Vilanova <address@hidden>
Signed-off-by: Harsh Prateek Bora <address@hidden>
---
scripts/tracetool.py | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 0f76b50..6714466 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -63,6 +63,13 @@ def get_format_descr(format_):
return ""
+def error_write(*lines):
+ sys.stderr.writelines(lines)
+
+def error(*lines):
+ error_write(*lines)
+ sys.exit(1)
+
######################################################################
# backend auto-registration and format compatibility
@@ -514,8 +521,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:
@@ -544,24 +552,19 @@ 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()
if format_ == 'stap':
if binary == "":
- print '--binary is required for SystemTAP tapset generator'
- sys.exit(1)
+ error("--binary is required for SystemTAP tapset generator\n")
if not probeprefix and not targettype:
- print '--target-type is required for SystemTAP tapset generator'
- sys.exit(1)
+ error("--target-type is required for SystemTAP tapset generator\n")
if not probeprefix and not 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
- [Qemu-devel] [PATCH 05/12] trace: [tracetool] Do not precompute the event number, (continued)
- [Qemu-devel] [PATCH 05/12] trace: [tracetool] Do not precompute the event number, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 06/12] trace: [tracetool] Add support for event properties, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 07/12] trace: [tracetool] Process the "disable" event property, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 03/12] trace: [tracetool] Do not rebuild event list in backend code, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 04/12] trace: [tracetool] Simplify event line parsing, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 08/12] trace: [tracetool] Rewrite event argument parsing, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 09/12] trace: [tracetool] Make format-specific code optional and with access to events, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 10/12] trace: [tracetool] Automatically establish available backends and formats, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 11/12] trace: Provide a per-event status define for conditional compilation, Lluís Vilanova, 2012/03/13
- [Qemu-devel] [PATCH 12/12] trace: [tracetool] Add error-reporting functions,
Lluís Vilanova <=
- Re: [Qemu-devel] [PATCH 00/12] Rewrite tracetool using python, Stefan Hajnoczi, 2012/03/20