Logging added

This commit is contained in:
Balthasar Reuter
2018-05-14 21:13:56 +02:00
parent e341fbc052
commit 5e2739bec8
13 changed files with 122 additions and 75 deletions

View File

@@ -20,6 +20,8 @@ class CameraGphoto2(Camera):
self.hasIdle = False
self._isActive = False
logging.info('Using python-gphoto2 bindings')
self._setupLogging()
self._setupCamera()
@@ -27,14 +29,10 @@ class CameraGphoto2(Camera):
def cleanup(self):
self._cap.exit(self._ctxt)
# self.setIdle()
def _setupLogging(self):
logging.basicConfig(
format='%(levelname)s: %(name)s: %(message)s',
level=logging.ERROR)
gp.check_result(gp.use_python_logging())
@@ -67,9 +65,7 @@ class CameraGphoto2(Camera):
# self.setActive()
text = self._cap.get_summary(self._ctxt)
print('Summary')
print('=======')
print(str(text))
logging.info('Camera summary: %s', str(text))
# self.setIdle()

View File

@@ -19,10 +19,7 @@ class CameraGphoto2Cffi(Camera):
self.hasPreview = True
self.hasIdle = True
# Avoid output cluttered
logging.basicConfig(
format='%(levelname)s: %(name)s: %(message)s',
level=logging.CRITICAL)
logging.info('Using gphoto2-cffi bindings')
self._setupCamera()
@@ -30,7 +27,7 @@ class CameraGphoto2Cffi(Camera):
def _setupCamera(self):
self._cap = gp.Camera()
print(self._cap.supported_operations)
logging.info('Supported operations: %s', self._cap.supported_operations)
if 'raw' in self._cap.config['imgsettings']['imageformat'].value.lower():
raise RuntimeError('Camera file format is set to RAW')

View File

@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from PIL import Image
import os, subprocess
import os, subprocess, logging
from . import Camera
@@ -15,9 +15,13 @@ class CameraGphoto2CommandLine(Camera):
self.hasPreview = False
self.hasIdle = False
logging.info('Using gphoto2 via command line')
if os.access('/dev/shm', os.W_OK):
logging.debug('Storing temp files to "/dev/shm/photobooth.jpg"')
self._tmp_filename = '/dev/shm/photobooth.jpg'
else:
logging.debug('Storing temp files to "/tmp/photobooth.jpg"')
self._tmp_filename = '/tmp/photobooth.jpg'
self.setActive()

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
from PIL import Image
import cv2
@@ -16,6 +18,8 @@ class CameraOpenCV(Camera):
self.hasPreview = True
self.hasIdle = True
logging.info('Using OpenCV')
self._cap = cv2.VideoCapture()