From a314c4943b6b4b35c0c6e8b151f83875eb59c026 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 15 Apr 2020 16:18:02 +0200 Subject: [PATCH] Fix import script if Uranium is not on your PYTHONPATH It was doing an os.path.exists on the relative path which has no context of where we're looking from. So make it absolute first and then check for the existence of the file. Also take the correct parent folder then and improve debug output. --- scripts/lionbridge_import.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/lionbridge_import.py b/scripts/lionbridge_import.py index 0c2c132216..83f53403ea 100644 --- a/scripts/lionbridge_import.py +++ b/scripts/lionbridge_import.py @@ -55,11 +55,13 @@ def destination_uranium() -> str: import UM except ImportError: relative_path = os.path.join(__file__, "..", "..", "..", "Uranium", "resources", "i18n", "uranium.pot") - print(os.path.abspath(relative_path)) - if os.path.exists(relative_path): - return os.path.abspath(relative_path) + absolute_path = os.path.abspath(relative_path) + if os.path.exists(absolute_path): + absolute_path = os.path.abspath(os.path.join(absolute_path, "..")) + print("Uranium is at:", absolute_path) + return absolute_path else: - raise Exception("Can't find Uranium. Please put UM on the PYTHONPATH or put the Uranium folder next to the Cura folder.") + raise Exception("Can't find Uranium. Please put UM on the PYTHONPATH or put the Uranium folder next to the Cura folder. Looked for: " + absolute_path) return os.path.abspath(os.path.join(UM.__file__, "..", "..", "resources", "i18n")) ## Merges translations from the source file into the destination file if they @@ -177,4 +179,4 @@ if __name__ == "__main__": argparser = argparse.ArgumentParser(description = "Import translation files from Lionbridge.") argparser.add_argument("source") args = argparser.parse_args() - lionbridge_import(args.source) \ No newline at end of file + lionbridge_import(args.source)