diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2023-11-03 10:36:34 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2023-11-03 10:40:00 +0100 |
commit | 09cb99b057f26628320ecee789799adc04a0435c (patch) | |
tree | 2159762b603450301b558da56964d9eed3b451ca | |
parent | 4bf4f91f5466131bf278a97a6e3685f66106fc6f (diff) |
ogcli: ignore SIGPIPEv0.3.3-2
# ogcli list scope | less
... leave it open for one minute, then press 'q' to exit less
it shows:
Traceback (most recent call last):
File "/usr/bin/ogcli", line 60, in <module>
CLI()
File "/usr/bin/ogcli", line 56, in __init__
getattr(self.ogcli, args.command)(sys.argv[2:])
File "/opt/opengnsys/bin/cli/cli.py", line 93, in list
OgScope.list_scopes(self.rest)
File "/opt/opengnsys/bin/cli/objects/scopes.py", line 18, in list_scopes
print_json(r.text)
File "/opt/opengnsys/bin/cli/utils.py", line 34, in print_json
print(json.dumps(payload, sort_keys=True, indent=2))
BrokenPipeError: [Errno 32] Broken pipe
It seems that the request library in python leaves the socket open
while it still displays the listing.
Ignore SIGPIPE which reports that socket is not there anymore, it is
a common practise to ignore this signal in socket.
-rwxr-xr-x | ogcli | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -10,6 +10,7 @@ from inspect import ismethod, getmembers from cli.cli import OgCLI +import signal import argparse import json import sys @@ -19,6 +20,7 @@ OG_CLI_CFG_PATH = "/opt/opengnsys/etc/ogcli.json" class CLI(): def __init__(self): + signal.signal(signal.SIGPIPE, signal.SIG_IGN) try: with open(OG_CLI_CFG_PATH, 'r') as json_file: self.cfg = json.load(json_file) |