Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cspp_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ def update_files(url_jpss_remote_dir, update_stampfile_prefix, mirror_jpss,
try:
fpt = open(filename, "w")
fpt.write(timestamp)
except OSError:
LOG.warning(f'Failed to write {what:s}-update time-stamp file')
except OSError as e:
LOG.warning(
f'Failed to write {what:s}-update time-stamp file to '
f"{filename!s}: {e.strerror:s}")
return
else:
fpt.close()
Expand Down Expand Up @@ -292,11 +294,11 @@ def publish_sdr(publisher, result_files, mda, site, mode,
to_send = mda.copy()
# Delete the RDR uri and uid from the message:
try:
del(to_send['uri'])
del to_send['uri']
except KeyError:
LOG.warning("Couldn't remove URI from message")
try:
del(to_send['uid'])
del to_send['uid']
except KeyError:
LOG.warning("Couldn't remove UID from message")

Expand Down
16 changes: 16 additions & 0 deletions cspp_runner/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ def test_update_nominal(monkeypatch, tmp_path, caplog, funcname, label):
assert exp1.exists() or exp2.exists()


@pytest.mark.parametrize(
"funcname,label", [("update_lut_files", "LUT"),
("update_ancillary_files", "ANC")])
def test_update_stampfile_fails(monkeypatch, tmp_path, caplog, funcname, label):
"""Test update case when writing stampfile files."""
import cspp_runner.runner
updater = getattr(cspp_runner.runner, funcname)
monkeypatch.setenv("CSPP_WORKDIR", os.fspath(tmp_path / "env"))
stampfile = os.fspath(tmp_path / "stampfile" / "directory" / "does" / "not" / "exist")
with caplog.at_level(logging.INFO):
updater("gopher://dummy/location", stampfile, "echo")
assert (f"Failed to write {label:s}-update time-stamp file to "
f"{stampfile:s}" in caplog.text)
assert "No such file or directory" in caplog.text


@pytest.mark.parametrize(
"funcname", ["update_lut_files", "update_ancillary_files"])
def test_update_error(monkeypatch, tmp_path, caplog, funcname):
Expand Down