Skip to content

Commit 1c82e5a

Browse files
committed
Filter stage 3 files
1 parent 8a0ed89 commit 1c82e5a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

jwql/website/apps/jwql/data_containers.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,8 +1720,13 @@ def get_proposal_info(filepaths):
17201720
for fname in files_for_proposal:
17211721
file_info = filename_parser(fname)
17221722
if file_info['recognized_filename']:
1723-
obs = file_info['observation']
1724-
obsnums.append(obs)
1723+
# Wrap in a try/except because level 3 files do not have an 'observation' key.
1724+
# That's ok. We will ignore those files.
1725+
try:
1726+
obs = file_info['observation']
1727+
obsnums.append(obs)
1728+
except KeyError:
1729+
pass
17251730
else:
17261731
logging.warning((f'While running get_proposal_info() for a program {proposal}, {fname} '
17271732
'was not recognized by the filename_parser().'))
@@ -2163,7 +2168,10 @@ def thumbnails_ajax(inst, proposal, obs_num=None):
21632168
# in those files anyway.
21642169
file_info = filename_parser(root)
21652170
if file_info['recognized_filename']:
2166-
all_obs.append(file_info['observation'])
2171+
try:
2172+
all_obs.append(file_info['observation'])
2173+
except KeyError:
2174+
pass
21672175
else:
21682176
logging.warning((f'While running thumbnails_ajax() on root {root}, '
21692177
'filename_parser() failed to recognize the file pattern.'))

0 commit comments

Comments
 (0)