summaryrefslogtreecommitdiff
path: root/src/py/cam/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/cam/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/cam/cam.py')
-rwxr-xr-xsrc/py/cam/cam.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py
index 967a72f5..a2a115c1 100755
--- a/src/py/cam/cam.py
+++ b/src/py/cam/cam.py
@@ -158,9 +158,7 @@ class CameraContext:
print('Camera configuration adjusted')
- r = self.camera.configure(camconfig)
- if r != 0:
- raise Exception('Configure failed')
+ self.camera.configure(camconfig)
self.stream_names = {}
self.streams = []
@@ -175,12 +173,7 @@ class CameraContext:
allocator = libcam.FrameBufferAllocator(self.camera)
for stream in self.streams:
- ret = allocator.allocate(stream)
- if ret < 0:
- print('Cannot allocate buffers')
- exit(-1)
-
- allocated = len(allocator.buffers(stream))
+ allocated = allocator.allocate(stream)
print('{}-{}: Allocated {} buffers'.format(self.id, self.stream_names[stream], allocated))
@@ -205,10 +198,7 @@ class CameraContext:
buffers = self.allocator.buffers(stream)
buffer = buffers[buf_num]
- ret = request.add_buffer(stream, buffer)
- if ret < 0:
- print('Can not set buffer for request')
- exit(-1)
+ request.add_buffer(stream, buffer)
requests.append(request)