X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fwinreg_importer.py;h=2030934e9f163efb3df191e56f4776f816706a21;hb=83e8cfaaf519136e906463151f91ea6bac409973;hp=714d0a7893aa1fa6177b56db3ce693ae1ba24426;hpb=74787ad8b91866fea9188acfc63b4aa47140ac32;p=bertos.git diff --git a/wizard/winreg_importer.py b/wizard/winreg_importer.py index 714d0a78..2030934e 100644 --- a/wizard/winreg_importer.py +++ b/wizard/winreg_importer.py @@ -11,17 +11,42 @@ from _winreg import * -DIR_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\BeRTOS Dirs") +# Open the registry keys. When the keys don't exist it do nothing +try: + DIR_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\BeRTOS Dirs") +except WindowsError: + DIR_KEY = None + +try: + TOOLCHAIN_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Toolchain Executables") +except WindowsError: + TOOLCHAIN_KEY = None def getBertosDirs(): + """ + Returns the path of the BeRTOS versions installed by the BeRTOS SDK installer. + """ + return getFromRegistry(DIR_KEY) + +def getBertosToolchains(): + """ + Returns the path of the executables of the toolchains installed by the BeRTOS + SDK installer. + """ + return getFromRegistry(TOOLCHAIN_KEY) + +def getFromRegistry(key): + """ + Returns the value of all the named values of the given key. + """ index = 0 - dirs = [] - while True: - try: - dir = EnumValue(DIR_KEY, index)[1] - dirs.append(dir) - index += 1 - except WindowsError: - break - return dirs - \ No newline at end of file + items = [] + if key: + while True: + try: + item = EnumValue(key, index)[1] + items.append(item) + index += 1 + except WindowsError: + break + return items \ No newline at end of file