Skip to content

Commit fa37bba

Browse files
committed
pilint automated feedback addressed.
1 parent 9f70ca3 commit fa37bba

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

libraries/dl-streamer/samples/gstreamer/python/open_close_valve/open_close_valve_sample.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@
33
#
44
# SPDX-License-Identifier: MIT
55
# ==============================================================================
6+
import sys
7+
import time
8+
#from contextlib import contextmanager
69
import gi
710
gi.require_version('Gst', '1.0')
811
gi.require_version('GstAnalytics', '1.0')
912
from gi.repository import Gst, GLib, GstAnalytics
10-
import sys
11-
import sys
12-
import time
13-
from contextlib import contextmanager
14-
1513

1614

1715
class DualStreamController:
16+
"""Class to create and control dual GStreamer streams with a valve element."""
1817
def __init__(self, video_source):
1918
"""
2019
Initialize dual stream controller
21-
2220
"""
21+
2322
Gst.init(None)
2423
self.video_source = video_source
2524
self.pipeline = None
@@ -126,7 +125,7 @@ def create_pipeline(self):
126125
return False
127126
else:
128127
print("Found control_valve element")
129-
128+
130129
# Get pre_view_classify element from pipeline
131130
# Below we add a probe to the sink pad of pre_view_classify to monitor detected objects
132131
self.pre_view_classify = self.pipeline.get_by_name("pre_view_classify")
@@ -135,23 +134,22 @@ def create_pipeline(self):
135134
return False
136135
else:
137136
print("Found pre_view_classify element")
138-
137+
139138
# Get sink pad of pre_view_classify
140139
pre_view_classify_pad = self.pre_view_classify.get_static_pad("sink")
141140
if not pre_view_classify_pad:
142141
print("Unable to get sink pad of gvaclassify")
143142
return False
144143
else:
145144
print("Got sink pad of pre_view_classify")
146-
145+
147146
# and add probe/callback
148-
pre_view_classify_pad.add_probe(Gst.PadProbeType.BUFFER, self.object_detector_callback, 0)
149-
147+
pre_view_classify_pad.add_probe(Gst.PadProbeType.BUFFER,
148+
self.object_detector_callback, 0)
150149
print("All elements found and pipeline created successfully")
151150
except Exception as e:
152151
print(f"Error creating pipeline: {e}")
153152
return False
154-
155153
return True
156154

157155
def object_detector_callback(self, pad, info, u_data):
@@ -232,6 +230,7 @@ def close_valve(self):
232230

233231

234232
def display_header():
233+
"""Display the header information for the Open/Close Valve sample."""
235234
print("\n# ====================================== #")
236235
print("# Copyright (C) 2025 Intel Corporation #")
237236
print("# #")
@@ -241,14 +240,14 @@ def display_header():
241240
print("# ====================================== #\n")
242241

243242
def main():
243+
"""Main function to run the Open/Close Valve sample."""
244244
# Display header
245245
display_header()
246246

247247
# Create dual stream controller
248248
video_source = "./videos/cars_extended.mp4"
249249
controller = DualStreamController(video_source)
250250

251-
252251
# Create pipeline
253252
if not controller.create_pipeline():
254253
print("Failed to create pipeline. Exiting...")
@@ -261,14 +260,14 @@ def main():
261260
if not controller.start():
262261
print("Failed to start pipeline. Exiting...")
263262
return 1
264-
263+
265264
# Run until interrupted
266265
print("Running pipeline. Press Ctrl+C to stop...")
267-
controller.pipeline.set_state(Gst.State.PLAYING)
268266
terminate = False
269267
try:
270268
while not terminate:
271-
msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.EOS | Gst.MessageType.ERROR)
269+
msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE,
270+
Gst.MessageType.EOS | Gst.MessageType.ERROR)
272271
if msg:
273272
if msg.type == Gst.MessageType.ERROR:
274273
err, debug_info = msg.parse_error()
@@ -284,9 +283,9 @@ def main():
284283
terminate = True
285284
except Exception as e:
286285
print(f"Exception occurred: {e}")
287-
286+
288287
# Stop pipeline
289288
controller.pipeline.set_state(Gst.State.NULL)
290289

291290
if __name__ == "__main__":
292-
sys.exit(main())
291+
sys.exit(main())

0 commit comments

Comments
 (0)