Skip to content

Commit

Permalink
Improve readability of debug log read/write settings file. (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRoy committed May 18, 2017
1 parent dc58ffe commit 3bf0393
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions capture_gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,26 +648,28 @@ def _store_widget_configuration(self):
"""Store all used widget settings in the local json file"""

inputs = self.get_inputs(as_preset=False)
path = self.settingfile

with open(self.settingfile, "w") as f:
log.debug("Writing JSON file: {0}".format(f))
with open(path, "w") as f:
log.debug("Writing JSON file: {0}".format(path))
json.dump(inputs, f, sort_keys=True,
indent=4, separators=(',', ': '))

def _read_widget_configuration(self):
"""Read the stored widget inputs"""

inputs = {}
path = self.settingfile

if not os.path.isfile(self.settingfile) or \
os.stat(self.settingfile).st_size == 0:
if not os.path.isfile(path) or os.stat(path).st_size == 0:
return inputs

try:
with open(self.settingfile, "r") as f:
log.debug("Reading JSON file: {0}".format(f))
with open(path, "r") as f:
log.debug("Reading JSON file: {0}".format(path))
try:
inputs = json.load(f)
except ValueError as error:
log.error(str(error))
except ValueError as error:
log.error(str(error))

return inputs

Expand Down

0 comments on commit 3bf0393

Please sign in to comment.