4c75acb3bb0df5b12a4563a6e14f75ccf3417756
[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 # Open the registry keys. When the keys don't exist it do nothing\r
15 try:\r
16     DIR_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\BeRTOS Dirs")\r
17 except WindowsError:\r
18     DIR_KEY = None\r
19 \r
20 try:\r
21     TOOLCHAIN_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Toolchain Executables")\r
22 except WindowsError:\r
23     TOOLCHAIN_KEY = None\r
24 \r
25 def getBertosDirs():\r
26     """\r
27     Returns the path of the BeRTOS versions installed by the BeRTOS SDK installer.\r
28     """\r
29     return getFromRegistry(DIR_KEY)\r
30 \r
31 def getBertosToolchain():\r
32     """\r
33     Returns the path of the executables of the toolchains installed by the BeRTOS\r
34     SDK installer.\r
35     """\r
36     return getFromRegistry(TOOLCHAIN_KEY)\r
37 \r
38 def getFromRegistry(key):\r
39     """\r
40     Returns the value of all the named values of the given key.\r
41     """\r
42     index = 0\r
43     items = []\r
44     if key:\r
45         while True:\r
46             try:\r
47                 item = EnumValue(key, index)[1]\r
48                 items.append(item)\r
49                 index += 1\r
50             except WindowsError:\r
51                 break\r
52     return items