async def run(self) -> None:
"""Run camera."""
camera = picamera.PiCamera()
- stream = io.BytesIO()
camera.resolution = self._resolution
camera.iso = self._iso
try:
filepath = os.path.join(self.conf['path'],
filename)
await aiofiles.os.remove(filepath)
+ stream = io.BytesIO()
camera.capture(stream, 'jpeg', resize=self._resize)
filename = (datetime.datetime.utcnow()
.strftime('%Y%m%d%H%M%S%f') + '.jpg')
filepath = os.path.join(self.conf['path'], filename)
async with aiofiles.open(filepath, 'wb') as f:
await f.write(stream.getvalue())
+ stream.close()
self._images.append(filename)
await self.bus.send(Message(self.name,
{'event': 'new image',