Skip to content

Commit

Permalink
Merge pull request SciLifeLab#91 from remiolsen/master
Browse files Browse the repository at this point in the history
Quickfix: json parsing needs exception handling
  • Loading branch information
remiolsen committed Jul 9, 2014
2 parents d691a0f + fe61cc5 commit 73ed183
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions status/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ def project_summary_data(self, row):

# Find the latest running note, return it as a separate field
if 'running_notes' in row.value:
notes = json.loads(row.value['running_notes'])
# note_dates = {datetime obj: time string, ...}
note_dates = dict(zip(map(dateutil.parser.parse, notes.keys()), notes.keys()))
latest_date = note_dates[max(note_dates.keys())]
row.value['latest_running_note'] = json.dumps({latest_date: notes[latest_date]})
try:
notes = json.loads(row.value['running_notes'])
# note_dates = {datetime obj: time string, ...}
note_dates = dict(zip(map(dateutil.parser.parse, notes.keys()), notes.keys()))
latest_date = note_dates[max(note_dates.keys())]
row.value['latest_running_note'] = json.dumps({latest_date: notes[latest_date]})
except ValueError:
pass

if row.key[0] == 'open' and 'queued' in row.value:
#Add days in production field
Expand Down

0 comments on commit 73ed183

Please sign in to comment.