Skip to content

Commit

Permalink
Catch exceptions when Comsol preference does not exist.
Browse files Browse the repository at this point in the history
This should fix start-up failure with older Comsol installations.
See issue #50.
  • Loading branch information
john-hen committed Oct 18, 2021
1 parent a2f491f commit 5b5dca3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions mph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,18 @@ def __init__(self, cores=None, version=None, port=None, host='localhost'):
java.loadPreferences()

# Override certain settings not useful in headless operation.
java.setPreference('updates.update.check', 'off')
java.setPreference('tempfiles.saving.warnifoverwriteolder', 'off')
java.setPreference('tempfiles.recovery.autosave', 'off')
try:
# Preference not defined on certain systems, see issue #39.
java.setPreference('tempfiles.recovery.checkforrecoveries',
'off')
except Exception:
log.debug('Could not turn off check for recovery files.')
java.setPreference('tempfiles.saving.optimize', 'filesize')
preferences = (
('updates.update.check', 'off'),
('tempfiles.saving.warnifoverwriteolder', 'off'), # issue #50
('tempfiles.recovery.autosave', 'off'),
('tempfiles.recovery.checkforrecoveries', 'off'), # issue #39
('tempfiles.saving.optimize', 'filesize'),
)
for (name, value) in preferences:
try:
java.setPreference(name, value)
except Exception:
log.info(f'Preference {name} does not exist.')

# Log that we're done so the start-up time may be inspected.
log.info('Stand-alone client initialized.')
Expand Down

0 comments on commit 5b5dca3

Please sign in to comment.