From 18ef7fd469308fce86658eea85c767139860b214 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Thu, 2 Jan 2025 21:41:41 -0500 Subject: [PATCH] Use Path.chmod() (#3051) --- archinstall/lib/configuration.py | 5 ++--- archinstall/lib/general.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/archinstall/lib/configuration.py b/archinstall/lib/configuration.py index c21b1447..aa04a533 100644 --- a/archinstall/lib/configuration.py +++ b/archinstall/lib/configuration.py @@ -1,5 +1,4 @@ import json -import os import readline import stat from pathlib import Path @@ -117,14 +116,14 @@ class ConfigurationOutput: if self._is_valid_path(dest_path): target = dest_path / self._user_config_file target.write_text(self.user_config_to_json()) - os.chmod(target, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) + target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) def save_user_creds(self, dest_path: Path) -> None: if self._is_valid_path(dest_path): if user_creds := self.user_credentials_to_json(): target = dest_path / self._user_creds_file target.write_text(user_creds) - os.chmod(target, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) + target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) def save(self, dest_path: Path | None = None) -> None: dest_path = dest_path or self._default_save_path diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index df8bba51..4d01f787 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -257,7 +257,7 @@ class SysCommandWorker: peek_output_log.write(str(output)) if change_perm: - os.chmod(str(peak_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) + peak_logfile.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) sys.stdout.write(str(output)) sys.stdout.flush() @@ -317,7 +317,7 @@ class SysCommandWorker: cmd_log.write(f"{time.time()} {self.cmd}\n") if change_perm: - os.chmod(str(history_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) + history_logfile.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) except (PermissionError, FileNotFoundError): # If history_logfile does not exist, ignore the error pass