Enclosed changes to camera settings in try-catch block. Fixes #55
This commit is contained in:
@@ -43,11 +43,18 @@ class CameraGphoto2(CameraInterface):
|
|||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
|
||||||
|
try:
|
||||||
config = self._cap.get_config()
|
config = self._cap.get_config()
|
||||||
config.get_child_by_name('imageformat').set_value(self._imageformat)
|
config.get_child_by_name('imageformat').set_value(
|
||||||
config.get_child_by_name('imageformatsd').set_value(self._imageformat)
|
self._imageformat)
|
||||||
# config.get_child_by_name('autopoweroff').set_value(self._autopoweroff)
|
config.get_child_by_name('imageformatsd').set_value(
|
||||||
|
self._imageformat)
|
||||||
|
# config.get_child_by_name('autopoweroff').set_value(
|
||||||
|
# self._autopoweroff)
|
||||||
self._cap.set_config(config)
|
self._cap.set_config(config)
|
||||||
|
except BaseException as e:
|
||||||
|
logging.warn('Error while changing camera settings: {}.'.format(e))
|
||||||
|
|
||||||
self._cap.exit(self._ctxt)
|
self._cap.exit(self._ctxt)
|
||||||
|
|
||||||
def _setupLogging(self):
|
def _setupLogging(self):
|
||||||
@@ -64,6 +71,7 @@ class CameraGphoto2(CameraInterface):
|
|||||||
logging.info('Camera summary: %s',
|
logging.info('Camera summary: %s',
|
||||||
str(self._cap.get_summary(self._ctxt)))
|
str(self._cap.get_summary(self._ctxt)))
|
||||||
|
|
||||||
|
try:
|
||||||
# get configuration tree
|
# get configuration tree
|
||||||
config = self._cap.get_config()
|
config = self._cap.get_config()
|
||||||
|
|
||||||
@@ -87,6 +95,9 @@ class CameraGphoto2(CameraInterface):
|
|||||||
|
|
||||||
# apply configuration and print current config
|
# apply configuration and print current config
|
||||||
self._cap.set_config(config)
|
self._cap.set_config(config)
|
||||||
|
except BaseException as e:
|
||||||
|
logging.warn('Error while changing camera settings: {}.'.format(e))
|
||||||
|
|
||||||
self._printConfig(self._cap.get_config())
|
self._printConfig(self._cap.get_config())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -42,9 +42,14 @@ class CameraGphoto2Cffi(CameraInterface):
|
|||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
|
||||||
|
try:
|
||||||
self._cap.config['imgsettings']['imageformat'].set(self._imgfmt)
|
self._cap.config['imgsettings']['imageformat'].set(self._imgfmt)
|
||||||
self._cap.config['imgsettings']['imageformatsd'].set(self._imgfmtsd)
|
self._cap.config['imgsettings']['imageformatsd'].set(
|
||||||
# self._cap.config['settings']['autopoweroff'].set(self._autopoweroff)
|
self._imgfmtsd)
|
||||||
|
# self._cap.config['settings']['autopoweroff'].set(
|
||||||
|
# self._autopoweroff)
|
||||||
|
except BaseException as e:
|
||||||
|
logging.warn('Error while changing camera settings: {}.'.format(e))
|
||||||
|
|
||||||
def _setupCamera(self):
|
def _setupCamera(self):
|
||||||
|
|
||||||
@@ -52,12 +57,14 @@ class CameraGphoto2Cffi(CameraInterface):
|
|||||||
logging.info('Supported operations: %s',
|
logging.info('Supported operations: %s',
|
||||||
self._cap.supported_operations)
|
self._cap.supported_operations)
|
||||||
|
|
||||||
|
try:
|
||||||
# make sure camera format is not set to raw
|
# make sure camera format is not set to raw
|
||||||
imgfmt = 'Large Fine JPEG'
|
imgfmt = 'Large Fine JPEG'
|
||||||
self._imgfmt = self._cap.config['imgsettings']['imageformat'].value
|
self._imgfmt = self._cap.config['imgsettings']['imageformat'].value
|
||||||
if 'raw' in self._imgfmt.lower():
|
if 'raw' in self._imgfmt.lower():
|
||||||
self._cap.config['imgsettings']['imageformat'].set(imgfmt)
|
self._cap.config['imgsettings']['imageformat'].set(imgfmt)
|
||||||
self._imgfmtsd = self._cap.config['imgsettings']['imageformatsd'].value
|
self._imgfmtsd = (
|
||||||
|
self._cap.config['imgsettings']['imageformatsd'].value)
|
||||||
if 'raw' in self._imgfmtsd.lower():
|
if 'raw' in self._imgfmtsd.lower():
|
||||||
self._cap.config['imgsettings']['imageformatsd'].set(imgfmt)
|
self._cap.config['imgsettings']['imageformatsd'].set(imgfmt)
|
||||||
|
|
||||||
@@ -67,6 +74,8 @@ class CameraGphoto2Cffi(CameraInterface):
|
|||||||
# self._cap.config['settings']['autopoweroff'].value)
|
# self._cap.config['settings']['autopoweroff'].value)
|
||||||
# if self._autopoweroff > 0:
|
# if self._autopoweroff > 0:
|
||||||
# self._cap.config['settings']['autopoweroff'].set("0")
|
# self._cap.config['settings']['autopoweroff'].set("0")
|
||||||
|
except BaseException as e:
|
||||||
|
logging.warn('Error while changing camera settings: {}.'.format(e))
|
||||||
|
|
||||||
# print current config
|
# print current config
|
||||||
self._printConfig(self._cap.config)
|
self._printConfig(self._cap.config)
|
||||||
|
|||||||
Reference in New Issue
Block a user