Make.py Mikero tools detection fix (#5774)

* make.py mikero tools registry bug fix

* Fixed missed change

* Spaces after comma
This commit is contained in:
Daniel Jupp
2017-11-22 16:10:30 -06:00
committed by jonpas
parent 5db7be4488
commit e507291bb6

View File

@ -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.") 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.""" """Use registry entries to find DePBO-based tools."""
stop = False requiredToolPaths = {"pboProject": None, "rapify": None, "MakePbo": None}
failed = False
if regKey == "HKCU": for tool in requiredToolPaths:
reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
stop = True
else:
reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
try:
try: try:
k = winreg.OpenKey(reg, r"Software\Wow6432Node\Mikero\pboProject") k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Mikero\{}".format(tool))
except FileNotFoundError: except FileNotFoundError:
k = winreg.OpenKey(reg, r"Software\Mikero\pboProject") k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\Mikero\{}".format(tool))
try: try:
pboproject_path = winreg.QueryValueEx(k, "exe")[0] path = winreg.QueryValueEx(k, "exe")[0]
winreg.CloseKey(k) #Strip any quotations from the path due to a MikeRo tool bug which leaves a trailing space in some of its registry paths.
print("Found pboproject.") requiredToolPaths[tool] = path.strip('"')
print_green("Found {}.".format(tool))
except: except:
print_error("Could not find pboProject.") print_error("Could not find {}".format(tool))
failed = True
try: finally:
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]
winreg.CloseKey(k) winreg.CloseKey(k)
print("Found rapify.")
except:
print_error("Could not find rapify.")
try: if failed:
k = winreg.OpenKey(reg, r"Software\Wow6432Node\Mikero\MakePbo") raise Exception("BadDePBO", "DePBO tools not installed correctly")
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
return requiredToolPaths
#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('"')]
def color(color): def color(color):
@ -1037,12 +1011,11 @@ See the make.cfg file for additional build options.
if build_tool == "pboproject": if build_tool == "pboproject":
try: try:
depbo_tools = find_depbo_tools("HKLM") depbo_tools = find_depbo_tools()
if depbo_tools == -1:
depbo_tools = find_depbo_tools("HKCU") pboproject = depbo_tools["pboProject"]
pboproject = depbo_tools[0] rapifyTool = depbo_tools["rapify"]
rapifyTool = depbo_tools[1] makepboTool = depbo_tools["MakePbo"]
makepboTool = depbo_tools[2]
except: except:
raise raise
print_error("Could not find dePBO tools. Download the needed tools from: https://dev.withsix.com/projects/mikero-pbodll/files") print_error("Could not find dePBO tools. Download the needed tools from: https://dev.withsix.com/projects/mikero-pbodll/files")