14 import os |
14 import os |
15 import sys |
15 import sys |
16 |
16 |
17 from eric6config import getConfig |
17 from eric6config import getConfig |
18 |
18 |
19 # Define file name markers for Python variants |
|
20 PythonMarkers = { |
|
21 2: "_py2", |
|
22 3: "_py3", |
|
23 } |
|
24 |
|
25 includePythonVariant = False |
|
26 |
|
27 |
19 |
28 def main(argv): |
20 def main(argv): |
29 """ |
21 """ |
30 Create Desktop and Start Menu links. |
22 Create Desktop and Start Menu links. |
31 |
23 |
32 @param argv list of command line arguments |
24 @param argv list of command line arguments |
33 @type list of str |
25 @type list of str |
34 """ |
26 """ |
35 global includePythonVariant |
|
36 |
|
37 if "-y" in argv: |
|
38 includePythonVariant = True |
|
39 |
|
40 regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" + \ |
27 regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" + \ |
41 "\\User Shell Folders" |
28 "\\User Shell Folders" |
42 |
29 |
43 # 1. create desktop shortcuts |
30 # 1. create desktop shortcuts |
44 regName = "Desktop" |
31 regName = "Desktop" |
76 @type str |
63 @type str |
77 @return value of requested registry variable |
64 @return value of requested registry variable |
78 @rtype any |
65 @rtype any |
79 """ |
66 """ |
80 try: |
67 try: |
81 import _winreg as winreg |
68 import winreg |
82 except ImportError: |
69 except ImportError: |
83 try: |
70 return None |
84 import winreg |
|
85 except ImportError: |
|
86 return None |
|
87 |
71 |
88 try: |
72 try: |
89 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, |
73 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, |
90 winreg.KEY_READ) |
74 winreg.KEY_READ) |
91 value, _ = winreg.QueryValueEx(registryKey, name) |
75 value, _ = winreg.QueryValueEx(registryKey, name) |
137 |
121 |
138 @return list of tuples containing the desktop link name, |
122 @return list of tuples containing the desktop link name, |
139 the link target and the icon target |
123 the link target and the icon target |
140 @rtype list of tuples of (str, str, str) |
124 @rtype list of tuples of (str, str, str) |
141 """ |
125 """ |
142 global includePythonVariant |
|
143 |
|
144 if includePythonVariant: |
|
145 marker = PythonMarkers[sys.version_info.major] |
|
146 else: |
|
147 marker = "" |
|
148 |
|
149 majorVersion, minorVersion = sys.version_info[:2] |
126 majorVersion, minorVersion = sys.version_info[:2] |
150 entriesTemplates = [ |
127 entriesTemplates = [ |
151 ("eric6 (Python {0}.{1}).lnk", |
128 ("eric6 (Python {0}.{1}).lnk", |
152 os.path.join(getConfig("bindir"), "eric6" + marker + ".cmd"), |
129 os.path.join(getConfig("bindir"), "eric6.cmd"), |
153 os.path.join(getConfig("ericPixDir"), "eric6.ico")), |
130 os.path.join(getConfig("ericPixDir"), "eric6.ico")), |
|
131 ("eric6 Browser (Python {0}.{1}).lnk", |
|
132 os.path.join(getConfig("bindir"), "eric6_browser.cmd"), |
|
133 os.path.join(getConfig("ericPixDir"), "ericWeb48.ico")), |
154 ] |
134 ] |
155 if sys.version_info.major == 2: |
|
156 entriesTemplates.append(( |
|
157 "eric6 Browser (Python {0}.{1}).lnk", |
|
158 os.path.join(getConfig("bindir"), |
|
159 "eric6_webbrowser" + marker + ".cmd"), |
|
160 os.path.join(getConfig("ericPixDir"), "ericWeb48.ico") |
|
161 )) |
|
162 else: |
|
163 entriesTemplates.append(( |
|
164 "eric6 Browser (Python {0}.{1}).lnk", |
|
165 os.path.join(getConfig("bindir"), |
|
166 "eric6_browser" + marker + ".cmd"), |
|
167 os.path.join(getConfig("ericPixDir"), "ericWeb48.ico") |
|
168 )) |
|
169 |
135 |
170 return [ |
136 return [ |
171 (e[0].format(majorVersion, minorVersion), e[1], e[2]) |
137 (e[0].format(majorVersion, minorVersion), e[1], e[2]) |
172 for e in entriesTemplates |
138 for e in entriesTemplates |
173 ] |
139 ] |