Add generic function for retrieve information from the registry
[bertos.git] / wizard / winreg_importer.py
1 #!/usr/bin/env python\r
2 # encoding: utf-8\r
3 #\r
4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)\r
5 # All rights reserved.\r
6 #\r
7 # $Id: qvariant_converter.py 2506 2009-04-15 08:29:07Z duplo $\r
8 #\r
9 # Author: Lorenzo Berni <duplo@develer.com>\r
10 #\r
11 \r
12 from _winreg import *\r
13 \r
14 DIR_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\BeRTOS Dirs")\r
15 TOOLCHAIN_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Toolchain Executables")\r
16 \r
17 def getBertosDirs():\r
18     """\r
19     Returns the path of the BeRTOS versions installed by the BeRTOS SDK installer.\r
20     """\r
21     return getFromRegistry(DIR_KEY)\r
22 \r
23 def getBertosToolchain():\r
24     """\r
25     Returns the path of the executables of the toolchains installed by the BeRTOS\r
26     SDK installer.\r
27     """\r
28     return getFromRegistry(TOOLCHAIN_KEY)\r
29 \r
30 def getFromRegistry(key):\r
31     """\r
32     Returns the value of all the named values of the given key.\r
33     """\r
34     index = 0\r
35     items = []\r
36     while True:\r
37         try:\r
38             item = EnumValue(TOOLCHAIN_KEY, index)[1]\r
39             items.append(item)\r
40         except WindowsError:\r
41             break\r
42     return items