From e507291bb6b95c30ea813fa9a3073bee7f7061b4 Mon Sep 17 00:00:00 2001 From: Daniel Jupp Date: Wed, 22 Nov 2017 16:10:30 -0600 Subject: [PATCH] Make.py Mikero tools detection fix (#5774) * make.py mikero tools registry bug fix * Fixed missed change * Spaces after comma --- tools/make.py | 69 ++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 48 deletions(-) diff --git a/tools/make.py b/tools/make.py index c1d0b860ca..5fc6b8bc39 100644 --- a/tools/make.py +++ b/tools/make.py @@ -228,57 +228,31 @@ def find_bi_tools(work_drive): raise Exception("BadTools","Arma 3 Tools are not installed correctly or the P: drive needs to be created.") -def find_depbo_tools(regKey): +def find_depbo_tools(): """Use registry entries to find DePBO-based tools.""" - stop = False + requiredToolPaths = {"pboProject": None, "rapify": None, "MakePbo": None} + failed = False - if regKey == "HKCU": - reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) - stop = True - else: - reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) - - try: + for tool in requiredToolPaths: try: - k = winreg.OpenKey(reg, r"Software\Wow6432Node\Mikero\pboProject") + k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Mikero\{}".format(tool)) except FileNotFoundError: - k = winreg.OpenKey(reg, r"Software\Mikero\pboProject") + k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\Mikero\{}".format(tool)) try: - pboproject_path = winreg.QueryValueEx(k, "exe")[0] - winreg.CloseKey(k) - print("Found pboproject.") + path = winreg.QueryValueEx(k, "exe")[0] + #Strip any quotations from the path due to a MikeRo tool bug which leaves a trailing space in some of its registry paths. + requiredToolPaths[tool] = path.strip('"') + print_green("Found {}.".format(tool)) except: - print_error("Could not find pboProject.") - - try: - k = winreg.OpenKey(reg, r"Software\Wow6432Node\Mikero\rapify") - except FileNotFoundError: - k = winreg.OpenKey(reg, r"Software\Mikero\rapify") - try: - rapify_path = winreg.QueryValueEx(k, "exe")[0] + print_error("Could not find {}".format(tool)) + failed = True + finally: winreg.CloseKey(k) - print("Found rapify.") - except: - print_error("Could not find rapify.") - try: - k = winreg.OpenKey(reg, r"Software\Wow6432Node\Mikero\MakePbo") - except FileNotFoundError: - k = winreg.OpenKey(reg, r"Software\Mikero\MakePbo") - try: - makepbo_path = winreg.QueryValueEx(k, "exe")[0] - winreg.CloseKey(k) - print("Found makepbo.") - except: - print_error("Could not find makepbo.") - except: - if stop == True: - raise Exception("BadDePBO", "DePBO tools not installed correctly") - return -1 + if failed: + raise Exception("BadDePBO", "DePBO tools not installed correctly") - - #Strip any quotations from the path due to a MikeRo tool bug which leaves a trailing space in some of its registry paths. - return [pboproject_path.strip('"'),rapify_path.strip('"'),makepbo_path.strip('"')] + return requiredToolPaths def color(color): @@ -1037,12 +1011,11 @@ See the make.cfg file for additional build options. if build_tool == "pboproject": try: - depbo_tools = find_depbo_tools("HKLM") - if depbo_tools == -1: - depbo_tools = find_depbo_tools("HKCU") - pboproject = depbo_tools[0] - rapifyTool = depbo_tools[1] - makepboTool = depbo_tools[2] + depbo_tools = find_depbo_tools() + + pboproject = depbo_tools["pboProject"] + rapifyTool = depbo_tools["rapify"] + makepboTool = depbo_tools["MakePbo"] except: raise print_error("Could not find dePBO tools. Download the needed tools from: https://dev.withsix.com/projects/mikero-pbodll/files")