mirror of
https://github.com/krkn-chaos/krkn.git
synced 2026-04-15 06:57:28 +00:00
This commit: - Adds timeout to avoid operations hanging for long durations. - Improves exception handling and exits wherever needed. - Sets KUBECONFIG env var globoally to access the cluster.
21 lines
521 B
Python
21 lines
521 B
Python
import subprocess
|
|
import logging
|
|
import sys
|
|
|
|
|
|
# Invokes a given command and returns the stdout
|
|
def invoke(command, timeout=None):
|
|
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
|