fix in commnds #13
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from .client import *
|
from .client import *
|
||||||
from .. import poller_control
|
from .. import poller_control
|
||||||
import shlex
|
|
||||||
|
|
||||||
def scgi_diagnostics(profile: dict) -> dict:
|
def scgi_diagnostics(profile: dict) -> dict:
|
||||||
c = client_for(profile)
|
c = client_for(profile)
|
||||||
@@ -90,12 +89,12 @@ def profile_diagnostics(profile: dict) -> dict:
|
|||||||
base = paths.get("default_directory") if isinstance(paths.get("default_directory"), str) else ""
|
base = paths.get("default_directory") if isinstance(paths.get("default_directory"), str) else ""
|
||||||
if base:
|
if base:
|
||||||
try:
|
try:
|
||||||
out = _rt_execute(c, "execute.capture", "sh", "-lc", f"test -w {shlex.quote(base)} && printf writable || printf readonly")
|
out = _rt_execute(c, "execute.capture", "sh", "-c", 'if test -w "$1"; then printf writable; else printf readonly; fi', "pytorrent-diagnostics-write", base)
|
||||||
write_permissions[base] = str(out or "").strip() or "unknown"
|
write_permissions[base] = str(out or "").strip() or "unknown"
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
write_permissions[base] = f"error: {exc}"
|
write_permissions[base] = f"error: {exc}"
|
||||||
try:
|
try:
|
||||||
out = _rt_execute(c, "execute.capture", "sh", "-lc", f"df -Pk {shlex.quote(base)} | tail -1 | awk '{{print $4}}'")
|
out = _rt_execute(c, "execute.capture", "sh", "-c", "df -Pk \"$1\" 2>/dev/null | awk 'END {print $4}'", "pytorrent-diagnostics-df", base)
|
||||||
kb = int(str(out or "0").strip() or 0)
|
kb = int(str(out or "0").strip() or 0)
|
||||||
free_disk[base] = {"free_bytes": kb * 1024, "free_h": human_size(kb * 1024)}
|
free_disk[base] = {"free_bytes": kb * 1024, "free_h": human_size(kb * 1024)}
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|||||||
Reference in New Issue
Block a user