This commit is contained in:
Marc Beninca 2024-06-10 09:51:59 +02:00
parent c7db231dc2
commit 592023d214
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -3,13 +3,13 @@ import shutil
from rwx import ps from rwx import ps
CHARSET = 'UTF-8' CHARSET = "UTF-8"
def create_image(file_path: str, size_bytes: int): def create_image(file_path: str, size_bytes: int):
ps.run( ps.run(
('qemu-img', 'create'), ("qemu-img", "create"),
('-f', 'qcow2'), ("-f", "qcow2"),
(file_path, size_bytes), (file_path, size_bytes),
) )
@ -20,17 +20,17 @@ def empty_file(path: str):
def get_mount_uuid(path: str): def get_mount_uuid(path: str):
return ps.run_line( return ps.run_line(
('findmnt',), ("findmnt",),
('--noheadings',), ("--noheadings",),
('--output', 'UUID'), ("--output", "UUID"),
(path,), (path,),
) )
def get_path_mount(path: str): def get_path_mount(path: str):
return ps.run_line( return ps.run_line(
('stat',), ("stat",),
('--format', '%m'), ("--format", "%m"),
(path,), (path,),
) )
@ -44,7 +44,7 @@ def make_directory(path: str):
def read_file(file_path: str): def read_file(file_path: str):
with open(file_path, 'br') as file_object: with open(file_path, "br") as file_object:
return file_object.read() return file_object.read()
@ -66,5 +66,5 @@ def wipe(path: str):
def write(file_path: str, text: str, charset=CHARSET): def write(file_path: str, text: str, charset=CHARSET):
with open(file_path, 'bw') as file_object: with open(file_path, "bw") as file_object:
file_object.write(text.encode(charset)) file_object.write(text.encode(charset))