File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010* New option ` --verbose ` for the ` datasets ls ` command which lists every
1111 relevant metadata field for the listed datasets.
1212* New output format option for printing CSV: ` --format=csv ` .
13+ * Improved SIGPIPE handling so that ` okdata ` works better with tools
14+ such as ` head ` .
1315
1416## 4.4.0 - 2025-05-14
1517
Original file line number Diff line number Diff line change 11import json
2+ import os
23import sys
34
45from keycloak .exceptions import KeycloakGetError , KeycloakPostError
@@ -33,6 +34,9 @@ def main():
3334 try :
3435 instance .login ()
3536 instance .handle ()
37+ # Flush output here to force SIGPIPE to be triggered while inside
38+ # this try block.
39+ sys .stdout .flush ()
3640 except RequestException as e :
3741 if hasattr (e .response , "json" ):
3842 instance .print_error_response (e .response .json ())
@@ -55,6 +59,11 @@ def main():
5559 )
5660 except (EOFError , KeyboardInterrupt ):
5761 instance .print ("\n Abort." )
62+ except BrokenPipeError :
63+ # https://docs.python.org/3/library/signal.html#note-on-sigpipe
64+ devnull = os .open (os .devnull , os .O_WRONLY )
65+ os .dup2 (devnull , sys .stdout .fileno ())
66+ sys .exit (1 )
5867 except Exception as e :
5968 instance .print (
6069 "An exception occurred" ,
You can’t perform that action at this time.
0 commit comments