diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2010-05-14 17:20:06 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-05-17 21:33:46 -0400 |
commit | 14dea24186809bbe8c0cce696c5f8298c794ae98 (patch) | |
tree | 791de59a9f99441ecc1fc8c8f24c98b400200160 | |
parent | 034e298681d014e082b351f7d4f389662ad29a70 (diff) |
python module: Add error checking
The exception catching is not useful,
we need to propagate exceptions. And
functions that just return an integer
will do so in python as well, error
checking is needed.
Acked-by: Darren Hart <dvhltc@us.ibm.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | tracecmd.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tracecmd.py b/tracecmd.py index e7ea5f6..6b05e23 100644 --- a/tracecmd.py +++ b/tracecmd.py | |||
@@ -75,6 +75,9 @@ class Event(object): | |||
75 | return val | 75 | return val |
76 | 76 | ||
77 | 77 | ||
78 | class FileFormatError(Exception): | ||
79 | pass | ||
80 | |||
78 | class Trace(object): | 81 | class Trace(object): |
79 | """ | 82 | """ |
80 | Trace object represents the trace file it is created with. | 83 | Trace object represents the trace file it is created with. |
@@ -83,18 +86,15 @@ class Trace(object): | |||
83 | used to manage the trace and extract events from it. | 86 | used to manage the trace and extract events from it. |
84 | """ | 87 | """ |
85 | def __init__(self, filename): | 88 | def __init__(self, filename): |
86 | self.handle = None | 89 | self.handle = tracecmd_open(filename) |
87 | self.pe = None | 90 | |
88 | 91 | if tracecmd_read_headers(self.handle): | |
89 | try: | 92 | raise FileFormatError("Invalid headers") |
90 | self.handle = tracecmd_open(filename) | 93 | |
91 | #FIXME: check if these throw exceptions automatically or if we have | 94 | if tracecmd_init_data(self.handle): |
92 | # to check return codes manually | 95 | raise FileFormatError("Failed to init data") |
93 | tracecmd_read_headers(self.handle) | 96 | |
94 | tracecmd_init_data(self.handle) | 97 | self.pe = tracecmd_get_pevent(self.handle) |
95 | self.pe = tracecmd_get_pevent(self.handle) | ||
96 | except: | ||
97 | return None | ||
98 | 98 | ||
99 | @property | 99 | @property |
100 | def cpus(self): | 100 | def cpus(self): |