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):
|
||||||
|
|
||||||
config = self._cap.get_config()
|
try:
|
||||||
config.get_child_by_name('imageformat').set_value(self._imageformat)
|
config = self._cap.get_config()
|
||||||
config.get_child_by_name('imageformatsd').set_value(self._imageformat)
|
config.get_child_by_name('imageformat').set_value(
|
||||||
# config.get_child_by_name('autopoweroff').set_value(self._autopoweroff)
|
self._imageformat)
|
||||||
self._cap.set_config(config)
|
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)
|
||||||
|
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,29 +71,33 @@ 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)))
|
||||||
|
|
||||||
# get configuration tree
|
try:
|
||||||
config = self._cap.get_config()
|
# get configuration tree
|
||||||
|
config = self._cap.get_config()
|
||||||
|
|
||||||
# make sure camera format is not set to raw
|
# make sure camera format is not set to raw
|
||||||
imageformat = config.get_child_by_name('imageformat')
|
imageformat = config.get_child_by_name('imageformat')
|
||||||
self._imageformat = imageformat.get_value()
|
self._imageformat = imageformat.get_value()
|
||||||
if 'raw' in self._imageformat.lower():
|
if 'raw' in self._imageformat.lower():
|
||||||
imageformat.set_value('Large Fine JPEG')
|
imageformat.set_value('Large Fine JPEG')
|
||||||
imageformatsd = config.get_child_by_name('imageformatsd')
|
imageformatsd = config.get_child_by_name('imageformatsd')
|
||||||
self._imageformatsd = imageformatsd.get_value()
|
self._imageformatsd = imageformatsd.get_value()
|
||||||
if 'raw' in self._imageformatsd.lower():
|
if 'raw' in self._imageformatsd.lower():
|
||||||
imageformatsd.set_value('Large Fine JPEG')
|
imageformatsd.set_value('Large Fine JPEG')
|
||||||
|
|
||||||
# make sure autopoweroff is disabled
|
# make sure autopoweroff is disabled
|
||||||
# this doesn't seem to work
|
# this doesn't seem to work
|
||||||
# autopoweroff = config.get_child_by_name('autopoweroff')
|
# autopoweroff = config.get_child_by_name('autopoweroff')
|
||||||
# self._autopoweroff = autopoweroff.get_value()
|
# self._autopoweroff = autopoweroff.get_value()
|
||||||
# logging.info('autopoweroff: {}'.format(self._autopoweroff))
|
# logging.info('autopoweroff: {}'.format(self._autopoweroff))
|
||||||
# if int(self._autopoweroff) > 0:
|
# if int(self._autopoweroff) > 0:
|
||||||
# autopoweroff.set_value('0')
|
# autopoweroff.set_value('0')
|
||||||
|
|
||||||
|
# apply configuration and print current config
|
||||||
|
self._cap.set_config(config)
|
||||||
|
except BaseException as e:
|
||||||
|
logging.warn('Error while changing camera settings: {}.'.format(e))
|
||||||
|
|
||||||
# apply configuration and print current config
|
|
||||||
self._cap.set_config(config)
|
|
||||||
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):
|
||||||
|
|
||||||
self._cap.config['imgsettings']['imageformat'].set(self._imgfmt)
|
try:
|
||||||
self._cap.config['imgsettings']['imageformatsd'].set(self._imgfmtsd)
|
self._cap.config['imgsettings']['imageformat'].set(self._imgfmt)
|
||||||
# self._cap.config['settings']['autopoweroff'].set(self._autopoweroff)
|
self._cap.config['imgsettings']['imageformatsd'].set(
|
||||||
|
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,21 +57,25 @@ class CameraGphoto2Cffi(CameraInterface):
|
|||||||
logging.info('Supported operations: %s',
|
logging.info('Supported operations: %s',
|
||||||
self._cap.supported_operations)
|
self._cap.supported_operations)
|
||||||
|
|
||||||
# make sure camera format is not set to raw
|
try:
|
||||||
imgfmt = 'Large Fine JPEG'
|
# make sure camera format is not set to raw
|
||||||
self._imgfmt = self._cap.config['imgsettings']['imageformat'].value
|
imgfmt = 'Large Fine JPEG'
|
||||||
if 'raw' in self._imgfmt.lower():
|
self._imgfmt = self._cap.config['imgsettings']['imageformat'].value
|
||||||
self._cap.config['imgsettings']['imageformat'].set(imgfmt)
|
if 'raw' in self._imgfmt.lower():
|
||||||
self._imgfmtsd = self._cap.config['imgsettings']['imageformatsd'].value
|
self._cap.config['imgsettings']['imageformat'].set(imgfmt)
|
||||||
if 'raw' in self._imgfmtsd.lower():
|
self._imgfmtsd = (
|
||||||
self._cap.config['imgsettings']['imageformatsd'].set(imgfmt)
|
self._cap.config['imgsettings']['imageformatsd'].value)
|
||||||
|
if 'raw' in self._imgfmtsd.lower():
|
||||||
|
self._cap.config['imgsettings']['imageformatsd'].set(imgfmt)
|
||||||
|
|
||||||
# make sure autopoweroff is disabled
|
# make sure autopoweroff is disabled
|
||||||
# this doesn't seem to work
|
# this doesn't seem to work
|
||||||
# self._autopoweroff = int(
|
# self._autopoweroff = int(
|
||||||
# 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