Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* New option `--verbose` for the `datasets ls` command which lists every
relevant metadata field for the listed datasets.
* New output format option for printing CSV: `--format=csv`.
* Improved SIGPIPE handling so that `okdata` works better with tools
such as `head`.

## 4.4.0 - 2025-05-14

Expand Down
9 changes: 9 additions & 0 deletions okdata/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import sys

from keycloak.exceptions import KeycloakGetError, KeycloakPostError
Expand Down Expand Up @@ -33,6 +34,9 @@ def main():
try:
instance.login()
instance.handle()
# Flush output here to force SIGPIPE to be triggered while inside
# this try block.
sys.stdout.flush()
except RequestException as e:
if hasattr(e.response, "json"):
instance.print_error_response(e.response.json())
Expand All @@ -55,6 +59,11 @@ def main():
)
except (EOFError, KeyboardInterrupt):
instance.print("\nAbort.")
except BrokenPipeError:
# https://docs.python.org/3/library/signal.html#note-on-sigpipe
devnull = os.open(os.devnull, os.O_WRONLY)
os.dup2(devnull, sys.stdout.fileno())
sys.exit(1)
except Exception as e:
instance.print(
"An exception occurred",
Expand Down