Enclosed config changes in setActive/setIdle in try-catch-blocks to avoid crashes with Nikon cameras (fixes #55)
This commit is contained in:
@@ -136,15 +136,21 @@ class CameraGphoto2(CameraInterface):
|
||||
|
||||
def setActive(self):
|
||||
|
||||
config = self._cap.get_config()
|
||||
config.get_child_by_name('output').set_value('PC')
|
||||
self._cap.set_config(config)
|
||||
try:
|
||||
config = self._cap.get_config()
|
||||
config.get_child_by_name('output').set_value('PC')
|
||||
self._cap.set_config(config)
|
||||
except BaseException as e:
|
||||
logging.warn('Error while setting camera output to active: {}.'.format(e))
|
||||
|
||||
def setIdle(self):
|
||||
|
||||
config = self._cap.get_config()
|
||||
config.get_child_by_name('output').set_value('Off')
|
||||
self._cap.set_config(config)
|
||||
try:
|
||||
config = self._cap.get_config()
|
||||
config.get_child_by_name('output').set_value('Off')
|
||||
self._cap.set_config(config)
|
||||
except BaseException as e:
|
||||
logging.warn('Error while setting camera output to idle: {}.'.format(e))
|
||||
|
||||
def getPreview(self):
|
||||
|
||||
|
||||
@@ -106,13 +106,19 @@ class CameraGphoto2Cffi(CameraInterface):
|
||||
|
||||
def setActive(self):
|
||||
|
||||
self._cap._get_config()['actions']['viewfinder'].set(True)
|
||||
self._cap._get_config()['settings']['output'].set('PC')
|
||||
try:
|
||||
self._cap._get_config()['actions']['viewfinder'].set(True)
|
||||
self._cap._get_config()['settings']['output'].set('PC')
|
||||
except BaseException as e:
|
||||
logging.warn('Error while setting camera output to active: {}.'.format(e))
|
||||
|
||||
def setIdle(self):
|
||||
|
||||
self._cap._get_config()['actions']['viewfinder'].set(False)
|
||||
self._cap._get_config()['settings']['output'].set('Off')
|
||||
try:
|
||||
self._cap._get_config()['actions']['viewfinder'].set(False)
|
||||
self._cap._get_config()['settings']['output'].set('Off')
|
||||
except BaseException as e:
|
||||
logging.warn('Error while setting camera output to idle: {}.'.format(e))
|
||||
|
||||
def getPreview(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user