git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2592 38d2e660-2303-0410-9eaa...
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 20 Apr 2009 18:00:03 +0000 (18:00 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 20 Apr 2009 18:00:03 +0000 (18:00 +0000)
wizard/winreg_importer.py

index 4e5131a9e1a120cb18194d1dec812d476fa650f0..4c75acb3bb0df5b12a4563a6e14f75ccf3417756 100644 (file)
 \r
 from _winreg import *\r
 \r
-DIR_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\BeRTOS Dirs")\r
-TOOLCHAIN_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Toolchain Executables")\r
+# Open the registry keys. When the keys don't exist it do nothing\r
+try:\r
+    DIR_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\BeRTOS Dirs")\r
+except WindowsError:\r
+    DIR_KEY = None\r
+\r
+try:\r
+    TOOLCHAIN_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Toolchain Executables")\r
+except WindowsError:\r
+    TOOLCHAIN_KEY = None\r
 \r
 def getBertosDirs():\r
     """\r
@@ -33,10 +41,12 @@ def getFromRegistry(key):
     """\r
     index = 0\r
     items = []\r
-    while True:\r
-        try:\r
-            item = EnumValue(TOOLCHAIN_KEY, index)[1]\r
-            items.append(item)\r
-        except WindowsError:\r
-            break\r
+    if key:\r
+        while True:\r
+            try:\r
+                item = EnumValue(key, index)[1]\r
+                items.append(item)\r
+                index += 1\r
+            except WindowsError:\r
+                break\r
     return items
\ No newline at end of file