def list_installed(): cmd = Command("pacman", ["-Qe"], opts=ExecOpts(display=False)) cmd.safe_run() if cmd.stdout: return [line.split(" ")[0] for line in cmd.stdout.split("\n")] else: return []
def lvm_size(vg: str, lv: str, opts: ExecOpts = DEFAULT_OPTS) -> int: """Returns size in bytes of a given logical volume""" cmd = Command( "lvs", [ f"{vg}/{lv}", "-o", "LV_SIZE", "--noheadings", "--units", "B", "--nosuffix" ], opts=opts, ) cmd.safe_run() if cmd.exit_code == 0 and cmd.stdout: return int(cmd.stdout.strip()) return 0