HEX
Server: Apache/2.4.63 (Unix)
System: Linux Synopilou92 4.4.302+ #72806 SMP Mon Jul 21 23:16:00 CST 2025 x86_64
User: pilou92 (1026)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: //var/packages/SupportService/target/python_modules/action_handler/action_utils.py
import subprocess
import json
from typing import Tuple


def synowebapi(exec_type: str, api: str, version: int, method: str, params: dict = {}, check: bool = True) -> Tuple[int, object]:
    cmd = ["/usr/syno/bin/synowebapi", exec_type, f"api={api}", f"version={version}", f"method={method}"]
    for param_key, param_value in params.items():
        cmd.append(f"{param_key}={json.dumps(param_value)}")
    completed_process = subprocess.run(cmd, capture_output=True, check=check)
    return completed_process.returncode, json.loads(completed_process.stdout)


def synowebapi_exec(api: str, version: int, method: str, params: dict = {}, check: bool = True) -> Tuple[int, object]:
    return synowebapi("--exec", api, version, method, params, check)


def synowebapi_exec_fastwebapi(api: str, version: int, method: str, params: dict = {}, check: bool = True) -> Tuple[int, object]:
    return synowebapi("--exec-fastwebapi", api, version, method, params, check)