MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / admin_delete_user

Function admin_delete_user

Scripts/ButSystem.py:12245–12287  ·  view source on GitHub ↗

admin_delete_user. Admin-only route handler. This docstring was expanded to make future maintenance easier. Returns: Varies.

()

Source from the content-addressed store, hash-verified

12243
12244
12245def _storage_stats(username: str) -> Dict[str, Any]:
12246 root = user_root(username)
12247 usage = shutil.disk_usage(root)
12248 percent = round((usage.used / usage.total) * 100, 1) if usage.total else 0
12249 return {"total": usage.total, "used": usage.used, "free": usage.free, "total_h": human_size(usage.total), "used_h": human_size(usage.used), "free_h": human_size(usage.free), "percent": percent}
12250
12251
12252def _folder_size(path: str) -> int:
12253 total = 0
12254 for root, dirs, files_ in os.walk(path, followlinks=False):
12255 dirs[:] = [d for d in dirs if not os.path.islink(os.path.join(root, d))]
12256 for name in files_:
12257 fp = os.path.join(root, name)
12258 try:
12259 if not os.path.islink(fp):
12260 total += os.path.getsize(fp)
12261 except Exception:
12262 pass
12263 return total
12264
12265
12266def _sha256_file(path: str) -> str:
12267 digest = hashlib.sha256()
12268 with open(path, "rb") as fh:
12269 while True:
12270 block = fh.read(8 * 1024 * 1024)
12271 if not block:
12272 break
12273 digest.update(block)
12274 return digest.hexdigest()
12275
12276
12277def _all_user_folders(username: str, exclude_rel: str = "") -> List[str]:
12278 root = user_root(username)
12279 exclude_rel = safe_relpath(exclude_rel)
12280 output = []
12281 for current, dirs, _files in os.walk(root, followlinks=False):
12282 dirs[:] = [d for d in dirs if not os.path.islink(os.path.join(current, d))]
12283 rel = os.path.relpath(current, root).replace(os.sep, "/")
12284 rel = "" if rel == "." else rel
12285 if rel and not (exclude_rel and (rel == exclude_rel or rel.startswith(exclude_rel + "/"))):
12286 output.append(rel)
12287 return sorted(output, key=str.casefold)
12288
12289
12290def _log_file_activity(owner: str, action: str, relpath: str, detail: str = "", actor: Optional[str] = None) -> None:

Callers

nothing calls this directly

Calls 5

require_adminFunction · 0.70
current_userFunction · 0.70
db_connectFunction · 0.70
user_is_adminFunction · 0.70
user_rootFunction · 0.70

Tested by

no test coverage detected