diff --git a/module/device/platform/emulator_base.py b/module/device/platform/emulator_base.py index a3ee2ccba..cdb475948 100644 --- a/module/device/platform/emulator_base.py +++ b/module/device/platform/emulator_base.py @@ -197,10 +197,7 @@ class EmulatorBase: list[str]: """ folder = self.abspath(folder) - try: - return list(iter_folder(folder, is_dir=is_dir, ext=ext)) - except FileNotFoundError: - return [] + return list(iter_folder(folder, is_dir=is_dir, ext=ext)) class EmulatorManagerBase: diff --git a/module/device/platform/emulator_windows.py b/module/device/platform/emulator_windows.py index 66d067da2..2117dcd79 100644 --- a/module/device/platform/emulator_windows.py +++ b/module/device/platform/emulator_windows.py @@ -476,11 +476,9 @@ class EmulatorManager(EmulatorManagerBase): if Emulator.is_emulator(file) and os.path.exists(file): exe.add(file) # MuMu specific directory - folder = abspath(os.path.join(os.path.dirname(uninstall), 'EmulatorShell')) - if os.path.exists(folder): - for file in iter_folder(folder, ext='.exe'): - if Emulator.is_emulator(file) and os.path.exists(file): - exe.add(file) + for file in iter_folder(abspath(os.path.join(os.path.dirname(uninstall), 'EmulatorShell')), ext='.exe'): + if Emulator.is_emulator(file) and os.path.exists(file): + exe.add(file) exe = [Emulator(path).path for path in exe if Emulator.is_emulator(path)] exe = sorted(set(exe)) diff --git a/module/device/platform/utils.py b/module/device/platform/utils.py index 633bd2966..4ebf94af1 100644 --- a/module/device/platform/utils.py +++ b/module/device/platform/utils.py @@ -35,7 +35,12 @@ def iter_folder(folder, is_dir=False, ext=None): Yields: str: Absolute path of files """ - for file in os.listdir(folder): + try: + files = os.listdir(folder) + except FileNotFoundError: + return + + for file in files: sub = os.path.join(folder, file) if is_dir: if os.path.isdir(sub):