summaryrefslogtreecommitdiff
path: root/src/py/examples/simple-cam.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-cam.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-cam.py')
-rwxr-xr-xsrc/py/examples/simple-cam.py15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/py/examples/simple-cam.py b/src/py/examples/simple-cam.py
index b3e97ca7..1cd1019d 100755
--- a/src/py/examples/simple-cam.py
+++ b/src/py/examples/simple-cam.py
@@ -259,12 +259,7 @@ def main():
allocator = libcam.FrameBufferAllocator(camera)
for cfg in config:
- ret = allocator.allocate(cfg.stream)
- if ret < 0:
- print('Can\'t allocate buffers')
- return -1
-
- allocated = len(allocator.buffers(cfg.stream))
+ allocated = allocator.allocate(cfg.stream)
print(f'Allocated {allocated} buffers for stream')
# --------------------------------------------------------------------
@@ -289,15 +284,9 @@ def main():
requests = []
for i in range(len(buffers)):
request = camera.create_request()
- if not request:
- print('Can\'t create request')
- return -1
buffer = buffers[i]
- ret = request.add_buffer(stream, buffer)
- if ret < 0:
- print('Can\'t set buffer for request')
- return -1
+ request.add_buffer(stream, buffer)
# Controls can be added to a request on a per frame basis.
request.set_control(libcam.controls.Brightness, 0.5)