Skip to content

Commit

Permalink
Use Path.chmod()
Browse files Browse the repository at this point in the history
  • Loading branch information
codefiles committed Dec 27, 2024
1 parent 459b84b commit 6ac3e1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions archinstall/lib/configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import os
import readline
import stat
from pathlib import Path
Expand Down Expand Up @@ -117,14 +116,14 @@ def save_user_config(self, dest_path: Path) -> None:
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
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def peak(self, output: str | bytes) -> bool:
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()
Expand Down Expand Up @@ -317,7 +317,7 @@ def execute(self) -> bool:
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
Expand Down

0 comments on commit 6ac3e1d

Please sign in to comment.