Buckets:

download
raw
1.11 kB
"""
Sudo/Root check for privileged operations
Prevents accidental task system activation
"""
import os
import sys
def is_root() -> bool:
"""Check if running as root (Unix) or Administrator (Windows)"""
try:
# Unix/Linux/Mac
return os.geteuid() == 0
except AttributeError:
# Windows
import ctypes
return ctypes.windll.shell32.IsUserAnAdmin() != 0
def require_root(message: str = "This operation requires root/sudo privileges") -> None:
"""
Raise PermissionError if not running as root
Args:
message: Error message to display
Raises:
PermissionError: If not running as root
"""
if not is_root():
raise PermissionError(f"{message}\nRun with: sudo {sys.executable} {' '.join(sys.argv)}")
def check_root_warning() -> bool:
"""
Check root status and print warning if not root
Returns:
True if root, False otherwise
"""
if is_root():
return True
print("⚠️ WARNING: Not running as root/sudo")
print(" Task system activation will be blocked")
return False

Xet Storage Details

Size:
1.11 kB
·
Xet hash:
0cae8f5006e80c9c15a9585114a10be22e0dc6b7217f919e06e0cb9ed8a49738

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.