From 3ef47f8f329caee1eae87909811202e85d61a568 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Mon, 21 Oct 2024 19:37:04 +0100 Subject: [PATCH] Tux: Avoid warning on startup when BIM is not installed os.listdir() raises an exception if modpath does not exist. --- src/Mod/Tux/InitGui.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Mod/Tux/InitGui.py b/src/Mod/Tux/InitGui.py index 8b76401b2a..4e058b2ac3 100644 --- a/src/Mod/Tux/InitGui.py +++ b/src/Mod/Tux/InitGui.py @@ -44,12 +44,15 @@ try: # running built-in BIM without the addon, or the addon without built-in BIM except: # Arch_rc not importable: We have both the BIM addon and the built-in BIM - import os + from pathlib import Path import FreeCAD - modpath = os.path.join(FreeCAD.getUserAppDataDir(), "Mod") - if "BIM" in os.listdir(modpath): - os.rename(os.path.join(modpath, "BIM"), os.path.join(modpath, "BIM021")) + bim_modpath = Path(FreeCAD.getUserAppDataDir(), "Mod", "BIM") + try: + bim_modpath.rename(bim_modpath.with_name("BIM021")) + except FileNotFoundError: + pass + else: FreeCAD.Console.PrintWarning( "BIM addon path has been renamed to BIM021 to avoid conflicts with the builtin BIM workbench. Please restart FreeCAD\n" )