From 09cb99b057f26628320ecee789799adc04a0435c Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Fri, 3 Nov 2023 10:36:34 +0100 Subject: ogcli: ignore SIGPIPE # 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 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. --- ogcli | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ogcli b/ogcli index 4adc5cf..b0edcf3 100755 --- a/ogcli +++ b/ogcli @@ -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) -- cgit v1.2.3-18-g5258