From 09855a7790d0a5a2eef4cbf6f60f84f2f9f8981e Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Thu, 22 Jan 2026 17:19:50 +0100 Subject: T8154: make catch_broken_pipe decorator to common vyos.utils.io function This adds the capability to make it re-usable in other code paths. --- src/op_mode/interfaces.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src') diff --git a/src/op_mode/interfaces.py b/src/op_mode/interfaces.py index ed36731e3..ecc4e73d2 100755 --- a/src/op_mode/interfaces.py +++ b/src/op_mode/interfaces.py @@ -13,9 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# -import os import re import sys import glob @@ -30,6 +28,7 @@ from vyos.ifconfig import Section from vyos.ifconfig import Interface from vyos.ifconfig import VRRP from vyos.utils.dict import dict_set_nested +from vyos.utils.io import catch_broken_pipe from vyos.utils.network import get_interface_vrf from vyos.utils.network import interface_exists from vyos.utils.process import cmd @@ -37,15 +36,6 @@ from vyos.utils.process import rc_cmd from vyos.utils.process import call from vyos.configquery import op_mode_config_dict -def catch_broken_pipe(func): - def wrapped(*args, **kwargs): - try: - func(*args, **kwargs) - except (BrokenPipeError, KeyboardInterrupt): - # Flush output to /dev/null and bail out. - os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno()) # pylint: disable = no-member - return wrapped - # The original implementation of filtered_interfaces has signature: # (ifnames: list, iftypes: typing.Union[str, list], vif: bool, vrrp: bool) -> intf: Interface: # Arg types allowed in CLI (ifnames: str, iftypes: str) were manually -- cgit v1.2.3