67 """ |
68 """ |
68 try: |
69 try: |
69 import winreg |
70 import winreg |
70 except ImportError: |
71 except ImportError: |
71 return None |
72 return None |
72 |
73 |
73 try: |
74 try: |
74 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, |
75 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ) |
75 winreg.KEY_READ) |
|
76 value, _ = winreg.QueryValueEx(registryKey, name) |
76 value, _ = winreg.QueryValueEx(registryKey, name) |
77 winreg.CloseKey(registryKey) |
77 winreg.CloseKey(registryKey) |
78 return value |
78 return value |
79 except WindowsError: |
79 except WindowsError: |
80 return None |
80 return None |
81 |
81 |
82 |
82 |
83 def windowsDesktopEntries(): |
83 def windowsDesktopEntries(): |
84 """ |
84 """ |
85 Function to generate data for the Windows Desktop links. |
85 Function to generate data for the Windows Desktop links. |
86 |
86 |
87 @return list of tuples containing the desktop link name, |
87 @return list of tuples containing the desktop link name, |
88 the link target and the icon target |
88 the link target and the icon target |
89 @rtype list of tuples of (str, str, str) |
89 @rtype list of tuples of (str, str, str) |
90 """ |
90 """ |
91 import eric7 |
91 import eric7 |
92 |
92 |
93 majorVersion, minorVersion = sys.version_info[:2] |
93 majorVersion, minorVersion = sys.version_info[:2] |
94 scriptsDir = sysconfig.get_path("scripts") |
94 scriptsDir = sysconfig.get_path("scripts") |
95 iconsDir = os.path.join(os.path.dirname(eric7.__file__), "pixmaps") |
95 iconsDir = os.path.join(os.path.dirname(eric7.__file__), "pixmaps") |
96 entriesTemplates = [ |
96 entriesTemplates = [ |
97 ("eric7 (Python {0}.{1}).lnk", |
97 ( |
98 os.path.join(scriptsDir, "eric7.exe"), |
98 "eric7 (Python {0}.{1}).lnk", |
99 os.path.join(iconsDir, "eric7.ico") |
99 os.path.join(scriptsDir, "eric7.exe"), |
100 ), |
100 os.path.join(iconsDir, "eric7.ico"), |
101 ("eric7 Browser (Python {0}.{1}).lnk", |
101 ), |
102 os.path.join(scriptsDir, "eric7_browser.exe"), |
102 ( |
103 os.path.join(iconsDir, "ericWeb48.ico") |
103 "eric7 Browser (Python {0}.{1}).lnk", |
104 ), |
104 os.path.join(scriptsDir, "eric7_browser.exe"), |
|
105 os.path.join(iconsDir, "ericWeb48.ico"), |
|
106 ), |
105 ] |
107 ] |
106 |
108 |
107 return [ |
109 return [ |
108 (e[0].format(majorVersion, minorVersion), e[1], e[2]) |
110 (e[0].format(majorVersion, minorVersion), e[1], e[2]) for e in entriesTemplates |
109 for e in entriesTemplates |
|
110 ] |
111 ] |
111 |
112 |
112 |
113 |
113 def createWindowsShortcut(linkPath, targetPath, iconPath): |
114 def createWindowsShortcut(linkPath, targetPath, iconPath): |
114 """ |
115 """ |
115 Create Windows shortcut. |
116 Create Windows shortcut. |
116 |
117 |
117 @param linkPath path of the shortcut file |
118 @param linkPath path of the shortcut file |
118 @type str |
119 @type str |
119 @param targetPath path the shortcut shall point to |
120 @param targetPath path the shortcut shall point to |
120 @type str |
121 @type str |
121 @param iconPath path of the icon file |
122 @param iconPath path of the icon file |
122 @type str |
123 @type str |
123 """ |
124 """ |
124 from win32com.client import Dispatch |
125 from win32com.client import Dispatch |
125 from pywintypes import com_error |
126 from pywintypes import com_error |
126 |
127 |
127 with contextlib.suppress(com_error): |
128 with contextlib.suppress(com_error): |
128 shell = Dispatch('WScript.Shell') |
129 shell = Dispatch("WScript.Shell") |
129 shortcut = shell.CreateShortCut(linkPath) |
130 shortcut = shell.CreateShortCut(linkPath) |
130 shortcut.Targetpath = targetPath |
131 shortcut.Targetpath = targetPath |
131 shortcut.WorkingDirectory = os.path.dirname(targetPath) |
132 shortcut.WorkingDirectory = os.path.dirname(targetPath) |
132 shortcut.IconLocation = iconPath |
133 shortcut.IconLocation = iconPath |
133 shortcut.save() |
134 shortcut.save() |
134 |
135 |
135 |
136 |
136 def windowsProgramsEntry(): |
137 def windowsProgramsEntry(): |
137 """ |
138 """ |
138 Function to generate the name of the Start Menu top entry. |
139 Function to generate the name of the Start Menu top entry. |
139 |
140 |
140 @return name of the Start Menu top entry |
141 @return name of the Start Menu top entry |
141 @rtype str |
142 @rtype str |
142 """ |
143 """ |
143 majorVersion, minorVersion = sys.version_info[:2] |
144 majorVersion, minorVersion = sys.version_info[:2] |
144 return "eric7 (Python {0}.{1})".format(majorVersion, minorVersion) |
145 return "eric7 (Python {0}.{1})".format(majorVersion, minorVersion) |
145 |
146 |
|
147 |
146 ###################################################################### |
148 ###################################################################### |
147 ## Post installation hooks for Linux below |
149 ## Post installation hooks for Linux below |
148 ###################################################################### |
150 ###################################################################### |
149 |
151 |
150 |
152 |
151 def copyLinuxMetaData(): |
153 def copyLinuxMetaData(): |
152 """ |
154 """ |
153 Function to copy the meta data files. |
155 Function to copy the meta data files. |
154 """ |
156 """ |
155 import eric7 |
157 import eric7 |
156 |
158 |
157 scriptsDir = sysconfig.get_path("scripts") |
159 scriptsDir = sysconfig.get_path("scripts") |
158 dstDir = os.path.join(os.path.expanduser("~"), ".local", "share") |
160 dstDir = os.path.join(os.path.expanduser("~"), ".local", "share") |
159 iconsDir = os.path.join(os.path.dirname(eric7.__file__), "pixmaps") |
161 iconsDir = os.path.join(os.path.dirname(eric7.__file__), "pixmaps") |
160 svgIconsDir = os.path.join(os.path.dirname(eric7.__file__), |
162 svgIconsDir = os.path.join(os.path.dirname(eric7.__file__), "icons", "breeze-dark") |
161 "icons", "breeze-dark") |
|
162 linuxDir = os.path.join(os.path.dirname(eric7.__file__), "data", "linux") |
163 linuxDir = os.path.join(os.path.dirname(eric7.__file__), "data", "linux") |
163 |
164 |
164 for metaDir in ["appdata", "metainfo"]: |
165 for metaDir in ["appdata", "metainfo"]: |
165 copyMetaFile(os.path.join(linuxDir, "eric7.appdata.xml"), |
166 copyMetaFile( |
166 os.path.join(dstDir, metaDir), |
167 os.path.join(linuxDir, "eric7.appdata.xml"), |
167 "eric7.appdata.xml") |
168 os.path.join(dstDir, metaDir), |
168 |
169 "eric7.appdata.xml", |
|
170 ) |
|
171 |
169 for svgIcon in ("eric.svg", "ericWeb48.svg"): |
172 for svgIcon in ("eric.svg", "ericWeb48.svg"): |
170 copyMetaFile(os.path.join(svgIconsDir, svgIcon), |
173 copyMetaFile( |
171 os.path.join(dstDir, "icons"), |
174 os.path.join(svgIconsDir, svgIcon), os.path.join(dstDir, "icons"), svgIcon |
172 svgIcon) |
175 ) |
173 for icon in ("eric48_icon.png", "ericWeb48_icon.png"): |
176 for icon in ("eric48_icon.png", "ericWeb48_icon.png"): |
174 copyMetaFile(os.path.join(iconsDir, icon), |
177 copyMetaFile(os.path.join(iconsDir, icon), os.path.join(dstDir, "icons"), icon) |
175 os.path.join(dstDir, "icons"), |
178 copyMetaFile( |
176 icon) |
179 os.path.join(iconsDir, "eric48_icon.png"), |
177 copyMetaFile(os.path.join(iconsDir, "eric48_icon.png"), |
180 os.path.join(dstDir, "icons", "hicolor", "48x48", "apps"), |
178 os.path.join(dstDir, "icons", "hicolor", "48x48", "apps"), |
181 "eric.png", |
179 "eric.png") |
182 ) |
180 copyMetaFile(os.path.join(iconsDir, "ericWeb48_icon.png"), |
183 copyMetaFile( |
181 os.path.join(dstDir, "icons", "hicolor", "48x48", "apps"), |
184 os.path.join(iconsDir, "ericWeb48_icon.png"), |
182 "ericWeb.png") |
185 os.path.join(dstDir, "icons", "hicolor", "48x48", "apps"), |
183 |
186 "ericWeb.png", |
|
187 ) |
|
188 |
184 for desktop in ["eric7.desktop", "eric7_browser.desktop"]: |
189 for desktop in ["eric7.desktop", "eric7_browser.desktop"]: |
185 copyDesktopFile( |
190 copyDesktopFile( |
186 os.path.join(linuxDir, desktop), |
191 os.path.join(linuxDir, desktop), |
187 os.path.join(dstDir, "applications", desktop), |
192 os.path.join(dstDir, "applications", desktop), |
188 scriptsDir |
193 scriptsDir, |
189 ) |
194 ) |
190 |
195 |
191 |
196 |
192 def copyMetaFile(srcname, dstpath, dstname): |
197 def copyMetaFile(srcname, dstpath, dstname): |
193 """ |
198 """ |
194 Function to copy a file to its destination. |
199 Function to copy a file to its destination. |
195 |
200 |
196 @param srcname name of the source file |
201 @param srcname name of the source file |
197 @type str |
202 @type str |
198 @param dstpath name of the destination path |
203 @param dstpath name of the destination path |
199 @type str |
204 @type str |
200 @param dstname name of the destination file (without path) |
205 @param dstname name of the destination file (without path) |