Python bindings: Make examples PEP8 compliant
[babeltrace.git] / bindings / python / examples / sched_switch.py
index 8c475565ce7e56981036d20fe3e56d3db9fb38ad..99e818e290de8de98f1f30b23a85ef821ea52a60 100644 (file)
@@ -29,41 +29,41 @@ import sys
 from babeltrace import *
 
 if len(sys.argv) < 2 or len(sys.argv) > 3:
-       raise TypeError("Usage: python sched_switch.py [pid] path/to/trace")
+    raise TypeError("Usage: python sched_switch.py [pid] path/to/trace")
 elif len(sys.argv) == 3:
-       filterPID = True
+    filterPID = True
 else:
-       filterPID = False
+    filterPID = False
 
 traces = TraceCollection()
-ret = traces.add_trace(sys.argv[len(sys.argv)-1], "ctf")
+ret = traces.add_trace(sys.argv[len(sys.argv) - 1], "ctf")
 if ret is None:
-       raise IOError("Error adding trace")
+    raise IOError("Error adding trace")
 
 for event in traces.events:
-       if event.name != "sched_switch":
-               continue
+    if event.name != "sched_switch":
+        continue
 
-       # Getting PID
-       pid = event.field_with_scope("pid", CTFScope.STREAM_EVENT_CONTEXT)
-       if pid is None:
-               print("ERROR: Missing PID info for sched_switch")
-               continue # Next event
+    # Getting PID
+    pid = event.field_with_scope("pid", CTFScope.STREAM_EVENT_CONTEXT)
+    if pid is None:
+        print("ERROR: Missing PID info for sched_switch")
+        continue  # Next event
 
-       if filterPID and (pid != long(sys.argv[1])):
-               continue # Next event
+    if filterPID and (pid != long(sys.argv[1])):
+        continue  # Next event
 
-       prev_comm = event["prev_comm"]
-       prev_tid = event["prev_tid"]
-       prev_prio = event["prev_prio"]
-       prev_state = event["prev_state"]
-       next_comm = event["next_comm"]
-       next_tid = event["next_tid"]
-       next_prio = event["next_prio"]
+    prev_comm = event["prev_comm"]
+    prev_tid = event["prev_tid"]
+    prev_prio = event["prev_prio"]
+    prev_state = event["prev_state"]
+    next_comm = event["next_comm"]
+    next_tid = event["next_tid"]
+    next_prio = event["next_prio"]
 
-       # Output
-       print("sched_switch, pid = {}, TS = {}, prev_comm = {},\n\t"
-               "prev_tid = {}, prev_prio = {}, prev_state = {},\n\t"
-               "next_comm = {}, next_tid = {}, next_prio = {}".format(
-               pid, event.timestamp, prev_comm, prev_tid,
-               prev_prio, prev_state, next_comm, next_tid, next_prio))
+    # Output
+    print("sched_switch, pid = {}, TS = {}, prev_comm = {},\n\t"
+          "prev_tid = {}, prev_prio = {}, prev_state = {},\n\t"
+          "next_comm = {}, next_tid = {}, next_prio = {}".format(
+              pid, event.timestamp, prev_comm, prev_tid,
+              prev_prio, prev_state, next_comm, next_tid, next_prio))
This page took 0.02456 seconds and 4 git commands to generate.