Skip to content

Commit

Permalink
Merge pull request #27 from seiuneko/master
Browse files Browse the repository at this point in the history
feat: add dynamic pacman log path detection
  • Loading branch information
hirak99 authored Feb 16, 2024
2 parents b705ace + d2e6f49 commit 7eac532
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/code/os_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ def is_btrfs_volume(mount_point: str) -> bool:
return True


def get_pacman_log_path() -> str:
try:
return execute_sh("pacman-conf LogFile").strip()
except CommandError:
logging.warning("Unable to determine pacman log path. Using default.")
return "/var/log/pacman.log"


def last_pacman_command() -> str:
logfile = "/var/log/pacman.log"
logfile = get_pacman_log_path()
matcher = re.compile(r"\[[\d\-:T+]*\] \[PACMAN\] Running \'(?P<cmd>.*)\'")
with open(logfile) as f:
for line in reversed(f.readlines()):
Expand Down

0 comments on commit 7eac532

Please sign in to comment.