Use Path.chmod() (#3051)

This commit is contained in:
codefiles 2025-01-02 21:41:41 -05:00 committed by GitHub
parent 459b84b6fe
commit 18ef7fd469
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View File

@ -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

View File

@ -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