Various changes, block telemetry feature.
-Sp/--patch is now required to do block telemetry before patching. Still preparing for hdiffpatch (will be coming at 1.10) Ay yo hosty support coming soon xD
This commit is contained in:
35
worthless/linux.py
Normal file
35
worthless/linux.py
Normal file
@ -0,0 +1,35 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class LinuxUtils:
|
||||
"""Utilities for Linux-specific tasks.
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
async def _exec_command(self, *args):
|
||||
"""Execute a command using pkexec (friendly gui)
|
||||
"""
|
||||
rsp = await asyncio.create_subprocess_exec(*args)
|
||||
match rsp.returncode:
|
||||
case 127:
|
||||
raise OSError("Authentication failed.")
|
||||
case 128:
|
||||
raise RuntimeError("User cancelled the authentication.")
|
||||
|
||||
return rsp
|
||||
|
||||
async def write_text_to_file(self, text, file_path: str | Path):
|
||||
"""Write text to a file using pkexec (friendly gui)
|
||||
"""
|
||||
if isinstance(file_path, Path):
|
||||
file_path = str(file_path)
|
||||
await self._exec_command('pkexec', 'echo', text, '>', file_path)
|
||||
|
||||
async def append_text_to_file(self, text, file_path: str | Path):
|
||||
"""Append text to a file using pkexec (friendly gui)
|
||||
"""
|
||||
if isinstance(file_path, Path):
|
||||
file_path = str(file_path)
|
||||
await self._exec_command('pkexec', 'echo', text, '>>', file_path)
|
||||
Reference in New Issue
Block a user