MSD 支持运行目录存放镜像

This commit is contained in:
mofeng-git
2024-10-05 14:31:23 +00:00
parent eca4167789
commit 507c46b986
9 changed files with 40 additions and 16 deletions

View File

@@ -53,7 +53,7 @@ class Drive:
# =====
def set_image_path(self, path: str) -> None:
if path:
if path or not self.__has_param("forced_eject"):
self.__set_param("file", path)
else:
self.__set_param("forced_eject", "")
@@ -75,7 +75,9 @@ class Drive:
return (not int(self.__get_param("ro")))
# =====
def __has_param(self, param: str) -> bool:
return os.access(os.path.join(self.__lun_path, param), os.F_OK)
def __get_param(self, param: str) -> str:
with open(os.path.join(self.__lun_path, param)) as file:
return file.read().strip()