Compare commits

..

4 Commits

Author SHA1 Message Date
dw-0
2bbdf3eab9 Merge ff777ce7e9 into d414be609a 2024-05-25 23:06:14 +02:00
dw-0
ff777ce7e9 fix: fix logic of asking for linking
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2024-05-25 23:04:42 +02:00
dw-0
5ce925c734 fix: correctly recognize the suffix of the instance
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2024-05-25 23:03:39 +02:00
dw-0
5dd276f56b refactor: add obico to moonraker suffix blacklist
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2024-05-25 21:49:04 +02:00
3 changed files with 12 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ from utils.logger import Logger
class Moonraker(BaseInstance):
@classmethod
def blacklist(cls) -> List[str]:
return ["None", "mcu"]
return ["None", "mcu", "obico"]
def __init__(self, suffix: str = ""):
super().__init__(instance_type=self, suffix=suffix)

View File

@@ -172,14 +172,18 @@ class InstanceManager:
]
instance_list = [
self.instance_type(suffix=self._get_instance_suffix(service))
self.instance_type(suffix=self._get_instance_suffix(name, service))
for service in service_list
]
return sorted(instance_list, key=lambda x: self._sort_instance_list(x.suffix))
def _get_instance_suffix(self, file_path: Path) -> str:
return file_path.stem.split("-")[-1] if "-" in file_path.stem else ""
def _get_instance_suffix(self, name: str, file_path: Path) -> str:
# to get the suffix of the instance, we remove the name of the instance from
# the file name, if the remaining part an empty string we return it
# otherwise there is and hyphen left, and we return the part after the hyphen
suffix = file_path.stem[len(name) :]
return suffix[1:] if suffix else ""
def _sort_instance_list(self, s: Union[int, str, None]):
if s is None:

View File

@@ -312,9 +312,10 @@ class ObicoExtension(BaseExtension):
end="",
)
if not get_confirm("Do you want to link the printers now?"):
self._link_obico_instances(unlinked_instances)
else:
Logger.print_info("Linking to server skipped ...")
Logger.print_info("Linking to Obico server skipped ...")
return
self._link_obico_instances(unlinked_instances)
def _remove_obico_instances(
self,