fix index out of range when parsing output from shell_scripts/get.sh

This commit is contained in:
forest 2021-01-29 00:26:21 -06:00
parent 40016ecbe6
commit 29008bc963

View File

@ -96,6 +96,9 @@ class ShellScriptVirtualization(VirtualizationInterface):
completedProcess = run([join(current_app.root_path, 'shell_scripts/get.sh'), id], capture_output=True) completedProcess = run([join(current_app.root_path, 'shell_scripts/get.sh'), id], capture_output=True)
self.validate_completed_process(completedProcess) self.validate_completed_process(completedProcess)
lines = completedProcess.stdout.splitlines() lines = completedProcess.stdout.splitlines()
if len(lines) == 0:
return None
ipaddr = lines[0].decode("utf-8") ipaddr = lines[0].decode("utf-8")
if not re.match(r"^([0-9]{1,3}\.){3}[0-9]{1,3}$", ipaddr): if not re.match(r"^([0-9]{1,3}\.){3}[0-9]{1,3}$", ipaddr):