20 # Define the globals. |
20 # Define the globals. |
21 progName = None |
21 progName = None |
22 currDir = os.getcwd() |
22 currDir = os.getcwd() |
23 pyModDir = None |
23 pyModDir = None |
24 progLanguages = ["Python", "Ruby", "QSS"] |
24 progLanguages = ["Python", "Ruby", "QSS"] |
25 defaultMacAppBundleName = "eric6.app" |
25 defaultMacAppBundleName = "eric7.app" |
26 defaultMacAppBundlePath = "/Applications" |
26 defaultMacAppBundlePath = "/Applications" |
27 settingsNameOrganization = "Eric6" |
27 settingsNameOrganization = "Eric6" |
28 settingsNameGlobal = "eric6" |
28 settingsNameGlobal = "eric7" |
29 |
29 |
30 |
30 |
31 def exit(rcode=0): |
31 def exit(rcode=0): |
32 """ |
32 """ |
33 Exit the uninstall script. |
33 Exit the uninstall script. |
34 |
34 |
35 @param rcode result code to report back (integer) |
35 @param rcode result code to report back (integer) |
36 """ |
36 """ |
37 global currDir |
37 global currDir |
38 |
38 |
39 # restore the local eric6config.py |
39 # restore the local eric7config.py |
40 if os.path.exists("eric6config.py.orig"): |
40 if os.path.exists("eric7config.py.orig"): |
41 if os.path.exists("eric6config.py"): |
41 if os.path.exists("eric7config.py"): |
42 os.remove("eric6config.py") |
42 os.remove("eric7config.py") |
43 os.rename("eric6config.py.orig", "eric6config.py") |
43 os.rename("eric7config.py.orig", "eric7config.py") |
44 |
44 |
45 if sys.platform.startswith(("win", "cygwin")): |
45 if sys.platform.startswith(("win", "cygwin")): |
46 with contextlib.suppress(): |
46 with contextlib.suppress(): |
47 input("Press enter to continue...") # secok |
47 input("Press enter to continue...") # secok |
48 |
48 |
49 os.chdir(currDir) |
49 os.chdir(currDir) |
50 |
50 |
51 sys.exit(rcode) |
51 sys.exit(rcode) |
52 |
52 |
53 # get a local eric6config.py out of the way |
53 # get a local eric7config.py out of the way |
54 if os.path.exists("eric6config.py"): |
54 if os.path.exists("eric7config.py"): |
55 os.rename("eric6config.py", "eric6config.py.orig") |
55 os.rename("eric7config.py", "eric7config.py.orig") |
56 try: |
56 try: |
57 from eric6config import getConfig |
57 from eric7config import getConfig |
58 except ImportError: |
58 except ImportError: |
59 print("The eric IDE doesn't seem to be installed. Aborting.") |
59 print("The eric IDE doesn't seem to be installed. Aborting.") |
60 exit(1) |
60 exit(1) |
61 except SyntaxError: |
61 except SyntaxError: |
62 # an incomplete or old config file was found |
62 # an incomplete or old config file was found |
119 elif sys.platform.startswith(("win", "cygwin")): |
119 elif sys.platform.startswith(("win", "cygwin")): |
120 uninstallWindowsLinks() |
120 uninstallWindowsLinks() |
121 |
121 |
122 # Remove the wrapper scripts |
122 # Remove the wrapper scripts |
123 rem_wnames = [ |
123 rem_wnames = [ |
124 "eric6_api", "eric6_compare", |
124 "eric7_api", "eric7_compare", |
125 "eric6_configure", "eric6_diff", |
125 "eric7_configure", "eric7_diff", |
126 "eric6_doc", "eric6_qregularexpression", |
126 "eric7_doc", "eric7_qregularexpression", |
127 "eric6_qregexp", "eric6_re", |
127 "eric7_qregexp", "eric7_re", |
128 "eric6_trpreviewer", "eric6_uipreviewer", |
128 "eric7_trpreviewer", "eric7_uipreviewer", |
129 "eric6_unittest", "eric6", |
129 "eric7_unittest", "eric7", |
130 "eric6_tray", "eric6_editor", |
130 "eric7_tray", "eric7_editor", |
131 "eric6_plugininstall", "eric6_pluginuninstall", |
131 "eric7_plugininstall", "eric7_pluginuninstall", |
132 "eric6_pluginrepository", "eric6_sqlbrowser", |
132 "eric7_pluginrepository", "eric7_sqlbrowser", |
133 "eric6_iconeditor", "eric6_snap", "eric6_hexeditor", |
133 "eric7_iconeditor", "eric7_snap", "eric7_hexeditor", |
134 "eric6_browser", "eric6_shell", |
134 "eric7_browser", "eric7_shell", |
135 # from Python2 era |
135 # from Python2 era |
136 "eric6_webbrowser", |
136 "eric7_webbrowser", |
137 ] |
137 ] |
138 |
138 |
139 try: |
139 try: |
140 for rem_wname in rem_wnames: |
140 for rem_wname in rem_wnames: |
141 for rwname in wrapperNames(getConfig('bindir'), rem_wname): |
141 for rwname in wrapperNames(getConfig('bindir'), rem_wname): |
142 if os.path.exists(rwname): |
142 if os.path.exists(rwname): |
143 os.remove(rwname) |
143 os.remove(rwname) |
144 |
144 |
145 # Cleanup our config file(s) |
145 # Cleanup our config file(s) |
146 for name in ['eric6config.py', 'eric6config.pyc', 'eric6.pth']: |
146 for name in ['eric7config.py', 'eric7config.pyc', 'eric7.pth']: |
147 e5cfile = os.path.join(pyModDir, name) |
147 e5cfile = os.path.join(pyModDir, name) |
148 if os.path.exists(e5cfile): |
148 if os.path.exists(e5cfile): |
149 os.remove(e5cfile) |
149 os.remove(e5cfile) |
150 e5cfile = os.path.join(pyModDir, "__pycache__", name) |
150 e5cfile = os.path.join(pyModDir, "__pycache__", name) |
151 path, ext = os.path.splitext(e5cfile) |
151 path, ext = os.path.splitext(e5cfile) |
175 apiname = os.path.join(apidir, progLanguage.lower(), name) |
175 apiname = os.path.join(apidir, progLanguage.lower(), name) |
176 if os.path.exists(apiname): |
176 if os.path.exists(apiname): |
177 os.remove(apiname) |
177 os.remove(apiname) |
178 for apiname in glob.glob( |
178 for apiname in glob.glob( |
179 os.path.join(apidir, progLanguage.lower(), "*.bas")): |
179 os.path.join(apidir, progLanguage.lower(), "*.bas")): |
180 if os.path.basename(apiname) != "eric6.bas": |
180 if os.path.basename(apiname) != "eric7.bas": |
181 os.remove(apiname) |
181 os.remove(apiname) |
182 |
182 |
183 if sys.platform == "darwin": |
183 if sys.platform == "darwin": |
184 # delete the Mac app bundle |
184 # delete the Mac app bundle |
185 uninstallMacAppBundle() |
185 uninstallMacAppBundle() |
232 # 2. cleanup start menu entry |
232 # 2. cleanup start menu entry |
233 regName = "Programs" |
233 regName = "Programs" |
234 programsEntry = getWinregEntry(regName, regPath) |
234 programsEntry = getWinregEntry(regName, regPath) |
235 if programsEntry: |
235 if programsEntry: |
236 programsFolder = os.path.normpath(os.path.expandvars(programsEntry)) |
236 programsFolder = os.path.normpath(os.path.expandvars(programsEntry)) |
237 eric6EntryPath = os.path.join(programsFolder, windowsProgramsEntry()) |
237 eric7EntryPath = os.path.join(programsFolder, windowsProgramsEntry()) |
238 if os.path.exists(eric6EntryPath): |
238 if os.path.exists(eric7EntryPath): |
239 try: |
239 try: |
240 shutil.rmtree(eric6EntryPath) |
240 shutil.rmtree(eric7EntryPath) |
241 except OSError: |
241 except OSError: |
242 # maybe restrictions prohibited link removal |
242 # maybe restrictions prohibited link removal |
243 print("Could not remove '{0}'.".format(eric6EntryPath)) |
243 print("Could not remove '{0}'.".format(eric7EntryPath)) |
244 |
244 |
245 |
245 |
246 def uninstallLinuxSpecifics(): |
246 def uninstallLinuxSpecifics(): |
247 """ |
247 """ |
248 Uninstall Linux specific files. |
248 Uninstall Linux specific files. |
249 """ |
249 """ |
250 if os.getuid() == 0: |
250 if os.getuid() == 0: |
251 for name in [ |
251 for name in [ |
252 "/usr/share/applications/eric6.desktop", |
252 "/usr/share/applications/eric7.desktop", |
253 "/usr/share/appdata/eric6.appdata.xml", |
253 "/usr/share/appdata/eric7.appdata.xml", |
254 "/usr/share/metainfo/eric6.appdata.xml", |
254 "/usr/share/metainfo/eric7.appdata.xml", |
255 "/usr/share/applications/eric6_browser.desktop", |
255 "/usr/share/applications/eric7_browser.desktop", |
256 "/usr/share/pixmaps/eric.png", |
256 "/usr/share/pixmaps/eric.png", |
257 "/usr/share/pixmaps/ericWeb.png", |
257 "/usr/share/pixmaps/ericWeb.png", |
258 "/usr/share/icons/eric.png", |
258 "/usr/share/icons/eric.png", |
259 "/usr/share/icons/ericWeb.png", |
259 "/usr/share/icons/ericWeb.png", |
260 # from Python2 era |
260 # from Python2 era |
261 "/usr/share/applications/eric6_webbrowser.desktop", |
261 "/usr/share/applications/eric7_webbrowser.desktop", |
262 ]: |
262 ]: |
263 if os.path.exists(name): |
263 if os.path.exists(name): |
264 os.remove(name) |
264 os.remove(name) |
265 elif os.getuid() >= 1000: |
265 elif os.getuid() >= 1000: |
266 # it is assumed that user ids start at 1000 |
266 # it is assumed that user ids start at 1000 |
267 for name in [ |
267 for name in [ |
268 "~/.local/share/applications/eric6.desktop", |
268 "~/.local/share/applications/eric7.desktop", |
269 "~/.local/share/appdata/eric6.appdata.xml", |
269 "~/.local/share/appdata/eric7.appdata.xml", |
270 "~/.local/share/metainfo/eric6.appdata.xml", |
270 "~/.local/share/metainfo/eric7.appdata.xml", |
271 "~/.local/share/applications/eric6_browser.desktop", |
271 "~/.local/share/applications/eric7_browser.desktop", |
272 "~/.local/share/pixmaps/eric.png", |
272 "~/.local/share/pixmaps/eric.png", |
273 "~/.local/share/pixmaps/ericWeb.png", |
273 "~/.local/share/pixmaps/ericWeb.png", |
274 "~/.local/share/icons/eric.png", |
274 "~/.local/share/icons/eric.png", |
275 "~/.local/share/icons/ericWeb.png", |
275 "~/.local/share/icons/ericWeb.png", |
276 # from Python2 era |
276 # from Python2 era |
277 "/usr/share/applications/eric6_webbrowser.desktop", |
277 "/usr/share/applications/eric7_webbrowser.desktop", |
278 ]: |
278 ]: |
279 path = os.path.expanduser(name) |
279 path = os.path.expanduser(name) |
280 if os.path.exists(path): |
280 if os.path.exists(path): |
281 os.remove(path) |
281 os.remove(path) |
282 |
282 |
306 """ |
306 """ |
307 Remove the plug-in directories. |
307 Remove the plug-in directories. |
308 """ |
308 """ |
309 pathsToRemove = [] |
309 pathsToRemove = [] |
310 |
310 |
311 globalPluginsDir = os.path.join(getConfig('mdir'), "eric6plugins") |
311 globalPluginsDir = os.path.join(getConfig('mdir'), "eric7plugins") |
312 if os.path.exists(globalPluginsDir): |
312 if os.path.exists(globalPluginsDir): |
313 pathsToRemove.append(globalPluginsDir) |
313 pathsToRemove.append(globalPluginsDir) |
314 |
314 |
315 localPluginsDir = os.path.join(getConfigDir(), "eric6plugins") |
315 localPluginsDir = os.path.join(getConfigDir(), "eric7plugins") |
316 if os.path.exists(localPluginsDir): |
316 if os.path.exists(localPluginsDir): |
317 pathsToRemove.append(localPluginsDir) |
317 pathsToRemove.append(localPluginsDir) |
318 |
318 |
319 if pathsToRemove: |
319 if pathsToRemove: |
320 print("Found these plug-in directories") |
320 print("Found these plug-in directories") |