vm management
This commit is contained in:
4
app.py
4
app.py
@@ -21,11 +21,11 @@ app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||
def run(cmd: List[str], timeout: int = 25) -> subprocess.CompletedProcess:
|
||||
return subprocess.run(cmd, check=False, text=True, capture_output=True, timeout=timeout)
|
||||
|
||||
def get_text(cmd: List[str]) -> str:
|
||||
def get_text(cmd: List[str], timeout: Optional[int] = None) -> str:
|
||||
r = run(cmd, timeout=timeout or 25)
|
||||
return r.stdout if r.returncode == 0 else ""
|
||||
|
||||
def get_json(cmd: List[str]) -> Any:
|
||||
def get_json(cmd: List[str], timeout: Optional[int] = None) -> Any:
|
||||
if cmd and cmd[0] == "pvesh" and "--output-format" not in cmd:
|
||||
cmd = cmd + ["--output-format", "json"]
|
||||
r = run(cmd, timeout=timeout or 25)
|
||||
|
Reference in New Issue
Block a user