HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //proc/25636/root/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)