summaryrefslogtreecommitdiff
path: root/src/py/examples/simple-capture.py
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2023-05-30 15:01:31 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-05-30 18:29:09 +0300
commit1fb31ac4f4c3e436aa3e8a647b5a4b912f0f45a3 (patch)
treef37214bf108a0b8d8548badf1eed12a15c5e55eb /src/py/examples/simple-capture.py
parent5b2f1ce5012fcb5af22ef3a97985bac11d9c4077 (diff)
py: Use exceptions instead of returning error codes
We have multiple methods which return an error code, mimicking the C++ API. Using exceptions is more natural in the Python API, so change all those methods to raise an Exception instead. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/py/examples/simple-capture.py')
-rwxr-xr-xsrc/py/examples/simple-capture.py21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/py/examples/simple-capture.py b/src/py/examples/simple-capture.py
index 5f93574f..4b85408f 100755
--- a/src/py/examples/simple-capture.py
+++ b/src/py/examples/simple-capture.py
@@ -43,8 +43,7 @@ def main():
# Acquire the camera for our use
- ret = cam.acquire()
- assert ret == 0
+ cam.acquire()
# Configure the camera
@@ -60,8 +59,7 @@ def main():
w, h = [int(v) for v in args.size.split('x')]
stream_config.size = libcam.Size(w, h)
- ret = cam.configure(cam_config)
- assert ret == 0
+ cam.configure(cam_config)
print(f'Capturing {TOTAL_FRAMES} frames with {stream_config}')
@@ -83,15 +81,13 @@ def main():
req = cam.create_request(i)
buffer = allocator.buffers(stream)[i]
- ret = req.add_buffer(stream, buffer)
- assert ret == 0
+ req.add_buffer(stream, buffer)
reqs.append(req)
# Start the camera
- ret = cam.start()
- assert ret == 0
+ cam.start()
# frames_queued and frames_done track the number of frames queued and done
@@ -101,8 +97,7 @@ def main():
# Queue the requests to the camera
for req in reqs:
- ret = cam.queue_request(req)
- assert ret == 0
+ cam.queue_request(req)
frames_queued += 1
# The main loop. Wait for the queued Requests to complete, process them,
@@ -155,13 +150,11 @@ def main():
# Stop the camera
- ret = cam.stop()
- assert ret == 0
+ cam.stop()
# Release the camera
- ret = cam.release()
- assert ret == 0
+ cam.release()
return 0