Make the IP failover work including threaded background os commands

This commit is contained in:
2018-09-24 04:07:46 -04:00
parent eda92a7cbb
commit 0f9637cb69
5 changed files with 37 additions and 13 deletions

View File

@ -21,12 +21,24 @@
###############################################################################
import subprocess
import threading
def run_os_command(command_string):
command = command_string.split()
command_output = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
return command_output.returncode
def run_os_command(command_string, background=False):
command = command_string.split()
if background:
def runcmd():
subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
thread = threading.Thread(target=runcmd, args=())
thread.start()
return 0
else:
command_output = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
return command_output.returncode