Skip to content

Commit 6ac3e1d

Browse files
committed
Use Path.chmod()
1 parent 459b84b commit 6ac3e1d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

archinstall/lib/configuration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import os
32
import readline
43
import stat
54
from pathlib import Path
@@ -117,14 +116,14 @@ def save_user_config(self, dest_path: Path) -> None:
117116
if self._is_valid_path(dest_path):
118117
target = dest_path / self._user_config_file
119118
target.write_text(self.user_config_to_json())
120-
os.chmod(target, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
119+
target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
121120

122121
def save_user_creds(self, dest_path: Path) -> None:
123122
if self._is_valid_path(dest_path):
124123
if user_creds := self.user_credentials_to_json():
125124
target = dest_path / self._user_creds_file
126125
target.write_text(user_creds)
127-
os.chmod(target, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
126+
target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
128127

129128
def save(self, dest_path: Path | None = None) -> None:
130129
dest_path = dest_path or self._default_save_path

archinstall/lib/general.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def peak(self, output: str | bytes) -> bool:
257257
peek_output_log.write(str(output))
258258

259259
if change_perm:
260-
os.chmod(str(peak_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
260+
peak_logfile.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
261261

262262
sys.stdout.write(str(output))
263263
sys.stdout.flush()
@@ -317,7 +317,7 @@ def execute(self) -> bool:
317317
cmd_log.write(f"{time.time()} {self.cmd}\n")
318318

319319
if change_perm:
320-
os.chmod(str(history_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
320+
history_logfile.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
321321
except (PermissionError, FileNotFoundError):
322322
# If history_logfile does not exist, ignore the error
323323
pass

0 commit comments

Comments
 (0)