Files
krkn/kraken/invoke/command.py
Naga Ravi Chaitanya Elluri cdf3bc03d2 Add support to block traffic to an application
This commit enables users to simulate a downtime of an application
by blocking the traffic for the specified duration to see how
it/other components communicating with it behave in case of downtime.
2021-10-01 10:13:40 -04:00

22 lines
537 B
Python

import subprocess
import logging
import sys
# Invokes a given command and returns the stdout
def invoke(command, timeout=None):
output = ""
try:
output = subprocess.check_output(command, shell=True, universal_newlines=True, timeout=timeout)
except Exception as e:
logging.error("Failed to run %s, error: %s" % (command, e))
sys.exit(1)
return output
def run(command):
try:
subprocess.run(command, shell=True, universal_newlines=True, timeout=45)
except Exception:
pass