mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-11 17:44:28 +05:00
fix(klipper): handle file access exception for dietpi version file (#658)
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ from core.submodules.simple_config_parser.src.simple_config_parser.simple_config
|
||||
)
|
||||
from core.types.component_status import ComponentStatus
|
||||
from utils.common import check_install_dependencies, get_install_status
|
||||
from utils.fs_utils import check_file_exist
|
||||
from utils.input_utils import get_confirm, get_number_input, get_string_input
|
||||
from utils.instance_utils import get_instances
|
||||
from utils.sys_utils import cmd_sysctl_service, parse_packages_from_file
|
||||
@@ -206,7 +207,7 @@ def install_klipper_packages() -> None:
|
||||
packages.append("pkg-config")
|
||||
|
||||
# Add dbus requirement for DietPi distro
|
||||
if Path("/boot/dietpi/.version").exists():
|
||||
if check_file_exist(Path("/boot/dietpi/.version")):
|
||||
packages.append("dbus")
|
||||
|
||||
check_install_dependencies({*packages})
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
# ======================================================================= #
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
@@ -29,15 +30,15 @@ def check_file_exist(file_path: Path, sudo=False) -> bool:
|
||||
:return: True, if file exists, otherwise False
|
||||
"""
|
||||
if sudo:
|
||||
command = ["sudo", "find", file_path.as_posix()]
|
||||
try:
|
||||
command = ["sudo", "find", file_path.as_posix()]
|
||||
check_output(command, stderr=DEVNULL)
|
||||
return True
|
||||
except CalledProcessError:
|
||||
return False
|
||||
else:
|
||||
if file_path.exists():
|
||||
return True
|
||||
if os.access(file_path, os.F_OK):
|
||||
return file_path.exists()
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user