a9f5f8a7c0bf23dea8f7cefbd302824878e8b7a5
[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 try:\r
26     CLI_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Ide Command Lines")\r
27 except WindowsError:\r
28     CLI_KEY = None\r
29 \r
30 def getBertosDirs():\r
31     """\r
32     Returns the path of the BeRTOS versions installed by the BeRTOS SDK installer.\r
33     """\r
34     return getFromRegistry(DIR_KEY).values()\r
35 \r
36 def getBertosToolchains():\r
37     """\r
38     Returns the path of the executables of the toolchains installed by the BeRTOS\r
39     SDK installer.\r
40     """\r
41     return getFromRegistry(TOOLCHAIN_KEY).values()\r
42 \r
43 def getCommandLines():\r
44     """\r
45     Returns the command lines to launch in order to open the selected IDE.\r
46     """\r
47     return getFromRegistry(CLI_KEY)\r
48 \r
49 def getFromRegistry(key):\r
50     """\r
51     Returns the value of all the named values of the given key.\r
52     """\r
53     index = 0\r
54     items = {}\r
55     if key:\r
56         while True:\r
57             try:\r
58                 item = EnumValue(key, index)\r
59                 items[item[0]] = item[1]\r
60                 index += 1\r
61             except WindowsError:\r
62                 break\r
63     return items