From eaf8e56e0ac99a312bff4cf4af59fca090d2d6c0 Mon Sep 17 00:00:00 2001 From: heylenz Date: Mon, 4 Jul 2022 15:27:25 +0800 Subject: [PATCH 1/5] Modify window's maya search installation method --- startup.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/startup.py b/startup.py index 27e83ae..f2372bc 100644 --- a/startup.py +++ b/startup.py @@ -218,7 +218,11 @@ def _find_software(self): """ Find executables in the default install locations. """ - + + if sgtk.util.is_windows(): + sw_versions = self._find_window_softwares() + return sw_versions + # all the executable templates for the current OS executable_templates = self.EXECUTABLE_TEMPLATES.get( "darwin" @@ -258,3 +262,48 @@ def _find_software(self): ) return sw_versions + + def _find_window_softwares(self): + """ + Return maya install location on Windows + Source: https://github.com/JukeboxPipeline/jukebox-core/blob/master/src/jukeboxcore/ostool.py + + """ + # The supported maya versions + MAYA_VERSIONS = ["2018", "2019", "2020", "2021", "2022", "2023", "2024"] + + # Registry key on windows to access maya install path + MAYA_REG_KEY = "Software\\Autodesk\\Maya\\{mayaversion}\\Setup\\InstallPath" + + sw_versions = [] + + try: + import _winreg as winreg + except: + import winreg + + # query winreg entry + # the last flag is needed, if we want to test with 32 bit python! + # Because Maya is an 64 bit key! + for ver in MAYA_VERSIONS: + try: + key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, + MAYA_REG_KEY.format(mayaversion=ver), 0, + winreg.KEY_READ | winreg.KEY_WOW64_64KEY) + value = winreg.QueryValueEx(key, "MAYA_INSTALL_LOCATION")[0] + + + executable_path = os.path.join(value, "bin", "maya.exe") + + if os.path.exists(executable_path): + sw_versions.append( + SoftwareVersion( + ver, + "Maya", + executable_path, + self._icon_from_executable(executable_path), + ) + ) + except WindowsError: + self.logger.debug('Maya %s installation not found in registry!' % ver) + return sw_versions \ No newline at end of file From 766419b02733cd2ee2374499c0237f7cc9eb46fd Mon Sep 17 00:00:00 2001 From: heylenz Date: Mon, 4 Jul 2022 15:40:22 +0800 Subject: [PATCH 2/5] add end new file --- startup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/startup.py b/startup.py index f2372bc..88988ca 100644 --- a/startup.py +++ b/startup.py @@ -306,4 +306,5 @@ def _find_window_softwares(self): ) except WindowsError: self.logger.debug('Maya %s installation not found in registry!' % ver) - return sw_versions \ No newline at end of file + return sw_versions + \ No newline at end of file From e3b2f015069fe953e06a3609e2e62eb53659644e Mon Sep 17 00:00:00 2001 From: heylenz Date: Wed, 31 Aug 2022 13:33:54 +0800 Subject: [PATCH 3/5] remove spaces at the end of a function remove spaces at the end of a function --- startup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/startup.py b/startup.py index 88988ca..f14fa6b 100644 --- a/startup.py +++ b/startup.py @@ -306,5 +306,4 @@ def _find_window_softwares(self): ) except WindowsError: self.logger.debug('Maya %s installation not found in registry!' % ver) - return sw_versions - \ No newline at end of file + return sw_versions From dbfc008cedb305d496a7944497800c3fe9079114 Mon Sep 17 00:00:00 2001 From: heylenz Date: Wed, 31 Aug 2022 05:48:03 +0000 Subject: [PATCH 4/5] remove Trailing Spaces --- startup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/startup.py b/startup.py index f14fa6b..4dc3cd0 100644 --- a/startup.py +++ b/startup.py @@ -218,11 +218,11 @@ def _find_software(self): """ Find executables in the default install locations. """ - + if sgtk.util.is_windows(): sw_versions = self._find_window_softwares() return sw_versions - + # all the executable templates for the current OS executable_templates = self.EXECUTABLE_TEMPLATES.get( "darwin" @@ -264,10 +264,10 @@ def _find_software(self): return sw_versions def _find_window_softwares(self): - """ + """ Return maya install location on Windows - Source: https://github.com/JukeboxPipeline/jukebox-core/blob/master/src/jukeboxcore/ostool.py - + Source: https://github.com/JukeboxPipeline/jukebox-core/blob/master/src/jukeboxcore/ostool.py + """ # The supported maya versions MAYA_VERSIONS = ["2018", "2019", "2020", "2021", "2022", "2023", "2024"] @@ -304,6 +304,6 @@ def _find_window_softwares(self): self._icon_from_executable(executable_path), ) ) - except WindowsError: + except WindowsError: self.logger.debug('Maya %s installation not found in registry!' % ver) - return sw_versions + return sw_versions \ No newline at end of file From 77b3e0f20ec61f8c568447c94aed9a1d99b8bd50 Mon Sep 17 00:00:00 2001 From: heylenz Date: Wed, 31 Aug 2022 05:52:33 +0000 Subject: [PATCH 5/5] fixed end new line --- startup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup.py b/startup.py index 4dc3cd0..387cff2 100644 --- a/startup.py +++ b/startup.py @@ -306,4 +306,4 @@ def _find_window_softwares(self): ) except WindowsError: self.logger.debug('Maya %s installation not found in registry!' % ver) - return sw_versions \ No newline at end of file + return sw_versions