summaryrefslogtreecommitdiff
path: root/src/system
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-07 08:27:36 +0200
committerGitHub <noreply@github.com>2020-04-07 08:27:36 +0200
commit09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c (patch)
tree6e7b0971ecd8859cff864b3ebb37f86f8ba288f5 /src/system
parente0f13b79a669e7fc8cadac8757b2f5fbbf51dc99 (diff)
parent7256810914e6664bf92041dcd7c3daf649ce0001 (diff)
downloadvyos-1x-09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c.tar.gz
vyos-1x-09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c.zip
Merge pull request #307 from thomas-mangin/T2226
util: T2226: convert all call to use vyos.util.{popen, cmd, run}
Diffstat (limited to 'src/system')
-rwxr-xr-xsrc/system/keepalived-fifo.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/system/keepalived-fifo.py b/src/system/keepalived-fifo.py
index 5e85da4a4..2778deaab 100755
--- a/src/system/keepalived-fifo.py
+++ b/src/system/keepalived-fifo.py
@@ -20,7 +20,6 @@ import time
import signal
import argparse
import threading
-import subprocess
import re
import json
from pathlib import Path
@@ -28,6 +27,8 @@ from queue import Queue
import logging
from logging.handlers import SysLogHandler
+from vyos.util import cmd
+
# configure logging
logger = logging.getLogger(__name__)
logs_format = logging.Formatter('%(filename)s: %(message)s')
@@ -84,14 +85,11 @@ class KeepalivedFifo:
# run command
def _run_command(self, command):
+ logger.debug("Running the command: {}".format(command))
try:
- logger.debug("Running the command: {}".format(command))
- process = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
- stdout, stderr = process.communicate()
- if process.returncode != 0:
- raise Exception("The command \"{}\" returned status {}. Error: {}".format(command, process.returncode, stderr))
- except Exception as err:
- logger.error("Unable to execute command \"{}\": {}".format(command, err))
+ cmd(command, universal_newlines=True)
+ except OSError as err:
+ logger.error(f'Unable to execute command "{command}": {err}')
# create FIFO pipe
def pipe_create(self):