.gitignore: ignore local vscode workspace settings file
[lttng-tools.git] / extras / bindings / swig / python / tests / example.py
index 97031703524ea6c366ae2972432a9a76b6ea2683..56835625b2fc24348817e766bfbb35659cabf7f0 100644 (file)
@@ -1,19 +1,27 @@
-#This example shows basically how to use the lttng-tools python module
+#
+# Copyright (C) 2012 Danny Serres <danny.serres@efficios.com>
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This example shows basically how to use the lttng-tools python module
 
 from lttng import *
 
+
 # This error will be raised is something goes wrong
 class LTTngError(Exception):
-       def __init__(self, value):
-               self.value = value
-       def __str__(self):
-               return repr(self.value)
+    def __init__(self, value):
+        self.value = value
+
+    def __str__(self):
+        return repr(self.value)
+
 
-#Setting up the domain to use
+# Setting up the domain to use
 dom = Domain()
 dom.type = DOMAIN_KERNEL
 
-#Setting up a channel to use
+# Setting up a channel to use
 channel = Channel()
 channel.name = "mychan"
 channel.attr.overwrite = 0
@@ -23,7 +31,7 @@ channel.attr.switch_timer_interval = 0
 channel.attr.read_timer_interval = 200
 channel.attr.output = EVENT_SPLICE
 
-#Setting up some events that will be used
+# Setting up some events that will be used
 event = Event()
 event.type = EVENT_TRACEPOINT
 event.loglevel_type = EVENT_LOGLEVEL_ALL
@@ -44,66 +52,66 @@ sched_process_free.type = EVENT_TRACEPOINT
 sched_process_free.loglevel_type = EVENT_LOGLEVEL_ALL
 
 
-#Creating a new session
-res = create("test","/lttng-traces/test")
-if res<0:
-       raise LTTngError(strerror(res))
+# Creating a new session
+res = create("test", "/lttng-traces/test")
+if res < 0:
+    raise LTTngError(strerror(res))
 
-#Creating handle
+# Creating handle
 han = None
 han = Handle("test", dom)
 if han is None:
-       raise LTTngError("Handle not created")
+    raise LTTngError("Handle not created")
 
-#Enabling the kernel channel
+# Enabling the kernel channel
 res = enable_channel(han, channel)
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
-#Enabling some events in given channel
-#To enable all events in default channel, use
-#enable_event(han, event, None)
+# Enabling some events in given channel
+# To enable all events in default channel, use
+# enable_event(han, event, None)
 res = enable_event(han, sched_switch, channel.name)
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
 res = enable_event(han, sched_process_exit, channel.name)
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
 res = enable_event(han, sched_process_free, channel.name)
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
-#Disabling an event
+# Disabling an event
 res = disable_event(han, sched_switch.name, channel.name)
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
-#Getting a list of the channels
+# Getting a list of the channels
 l = list_channels(han)
 if type(l) is int:
-               raise LTTngError(strerror(l))
+    raise LTTngError(strerror(l))
 
-#Starting the trace
+# Starting the trace
 res = start("test")
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
-#Stopping the trace
+# Stopping the trace
 res = stop("test")
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
-#Disabling a channel
+# Disabling a channel
 res = disable_channel(han, channel.name)
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
 
-#Destroying the handle
+# Destroying the handle
 del han
 
-#Destroying the session
+# Destroying the session
 res = destroy("test")
-if res<0:
-       raise LTTngError(strerror(res))
+if res < 0:
+    raise LTTngError(strerror(res))
This page took 0.026979 seconds and 4 git commands to generate.