16 import os |
16 import os |
17 import shutil |
17 import shutil |
18 import glob |
18 import glob |
19 import distutils.sysconfig |
19 import distutils.sysconfig |
20 |
20 |
21 if sys.version_info[0] == 2: |
|
22 try: |
|
23 from PyQt5 import sip |
|
24 except ImportError: |
|
25 import sip |
|
26 sip.setapi('QString', 2) |
|
27 else: |
|
28 raw_input = input |
|
29 |
|
30 # Define the globals. |
21 # Define the globals. |
31 progName = None |
22 progName = None |
32 currDir = os.getcwd() |
23 currDir = os.getcwd() |
33 pyModDir = None |
24 pyModDir = None |
34 progLanguages = ["Python", "Ruby", "QSS"] |
25 progLanguages = ["Python", "Ruby", "QSS"] |
35 includePythonVariant = False |
|
36 defaultMacAppBundleName = "eric6.app" |
26 defaultMacAppBundleName = "eric6.app" |
37 defaultMacAppBundlePath = "/Applications" |
27 defaultMacAppBundlePath = "/Applications" |
38 settingsNameOrganization = "Eric6" |
28 settingsNameOrganization = "Eric6" |
39 settingsNameGlobal = "eric6" |
29 settingsNameGlobal = "eric6" |
40 |
|
41 # Define file name markers for Python variants |
|
42 PythonMarkers = { |
|
43 2: "_py2", |
|
44 3: "_py3", |
|
45 } |
|
46 |
30 |
47 |
31 |
48 def exit(rcode=0): |
32 def exit(rcode=0): |
49 """ |
33 """ |
50 Exit the uninstall script. |
34 Exit the uninstall script. |
58 if os.path.exists("eric6config.py"): |
42 if os.path.exists("eric6config.py"): |
59 os.remove("eric6config.py") |
43 os.remove("eric6config.py") |
60 os.rename("eric6config.py.orig", "eric6config.py") |
44 os.rename("eric6config.py.orig", "eric6config.py") |
61 |
45 |
62 if sys.platform.startswith(("win", "cygwin")): |
46 if sys.platform.startswith(("win", "cygwin")): |
63 # different meaning of input between Py2 and Py3 |
|
64 try: |
47 try: |
65 input("Press enter to continue...") |
48 input("Press enter to continue...") |
66 except (EOFError, SyntaxError): |
49 except (EOFError, SyntaxError): |
67 pass |
50 pass |
68 |
51 |
149 "eric6_trpreviewer", "eric6_uipreviewer", |
131 "eric6_trpreviewer", "eric6_uipreviewer", |
150 "eric6_unittest", "eric6", |
132 "eric6_unittest", "eric6", |
151 "eric6_tray", "eric6_editor", |
133 "eric6_tray", "eric6_editor", |
152 "eric6_plugininstall", "eric6_pluginuninstall", |
134 "eric6_plugininstall", "eric6_pluginuninstall", |
153 "eric6_pluginrepository", "eric6_sqlbrowser", |
135 "eric6_pluginrepository", "eric6_sqlbrowser", |
154 "eric6_webbrowser", "eric6_iconeditor", |
136 "eric6_iconeditor", "eric6_snap", "eric6_hexeditor", |
155 "eric6_snap", "eric6_hexeditor", "eric6_browser", |
137 "eric6_browser", "eric6_shell", |
156 "eric6_shell", |
138 # from Python2 era |
|
139 "eric6_webbrowser", |
157 ] |
140 ] |
158 if includePythonVariant: |
|
159 marker = PythonMarkers[sys.version_info.major] |
|
160 rem_wnames = [n + marker for n in rem_wnames] |
|
161 |
141 |
162 try: |
142 try: |
163 for rem_wname in rem_wnames: |
143 for rem_wname in rem_wnames: |
164 for rwname in wrapperNames(getConfig('bindir'), rem_wname): |
144 for rwname in wrapperNames(getConfig('bindir'), rem_wname): |
165 if os.path.exists(rwname): |
145 if os.path.exists(rwname): |
271 if os.getuid() == 0: |
251 if os.getuid() == 0: |
272 for name in ["/usr/share/pixmaps/eric.png", |
252 for name in ["/usr/share/pixmaps/eric.png", |
273 "/usr/share/pixmaps/ericWeb.png"]: |
253 "/usr/share/pixmaps/ericWeb.png"]: |
274 if os.path.exists(name): |
254 if os.path.exists(name): |
275 os.remove(name) |
255 os.remove(name) |
276 if includePythonVariant: |
|
277 marker = PythonMarkers[sys.version_info.major] |
|
278 else: |
|
279 marker = "" |
|
280 for name in [ |
256 for name in [ |
281 "/usr/share/applications/eric6" + marker + ".desktop", |
257 "/usr/share/applications/eric6.desktop", |
282 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
258 "/usr/share/appdata/eric6.appdata.xml", |
283 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
259 "/usr/share/metainfo/eric6.appdata.xml", |
284 "/usr/share/applications/eric6_webbrowser" + marker + |
260 "/usr/share/applications/eric6_browser.desktop", |
285 ".desktop", |
261 "/usr/share/pixmaps/eric.png", |
286 "/usr/share/applications/eric6_browser" + marker + |
262 "/usr/share/pixmaps/ericWeb.png", |
287 ".desktop", |
263 # from Python2 era |
288 "/usr/share/pixmaps/eric" + marker + ".png", |
264 "/usr/share/applications/eric6_webbrowser.desktop", |
289 "/usr/share/pixmaps/ericWeb" + marker + ".png", |
|
290 ]: |
265 ]: |
291 if os.path.exists(name): |
266 if os.path.exists(name): |
292 os.remove(name) |
267 os.remove(name) |
293 elif os.getuid() >= 1000: |
268 elif os.getuid() >= 1000: |
294 # it is assumed that user ids start at 1000 |
269 # it is assumed that user ids start at 1000 |
295 for name in ["~/.local/share/pixmaps/eric.png", |
270 for name in ["~/.local/share/pixmaps/eric.png", |
296 "~/.local/share/pixmaps/ericWeb.png"]: |
271 "~/.local/share/pixmaps/ericWeb.png"]: |
297 path = os.path.expanduser(name) |
272 path = os.path.expanduser(name) |
298 if os.path.exists(path): |
273 if os.path.exists(path): |
299 os.remove(path) |
274 os.remove(path) |
300 if includePythonVariant: |
|
301 marker = PythonMarkers[sys.version_info.major] |
|
302 else: |
|
303 marker = "" |
|
304 for name in [ |
275 for name in [ |
305 "~/.local/share/applications/eric6" + marker + ".desktop", |
276 "~/.local/share/applications/eric6.desktop", |
306 "~/.local/share/appdata/eric6" + marker + ".appdata.xml", |
277 "~/.local/share/appdata/eric6.appdata.xml", |
307 "~/.local/share/metainfo/eric6" + marker + ".appdata.xml", |
278 "~/.local/share/metainfo/eric6.appdata.xml", |
308 "~/.local/share/applications/eric6_webbrowser" + marker + |
279 "~/.local/share/applications/eric6_browser.desktop", |
309 ".desktop", |
280 "~/.local/share/pixmaps/eric.png", |
310 "~/.local/share/applications/eric6_browser" + marker + |
281 "~/.local/share/pixmaps/ericWeb.png", |
311 ".desktop", |
282 # from Python2 era |
312 "~/.local/share/pixmaps/eric" + marker + ".png", |
283 "/usr/share/applications/eric6_webbrowser.desktop", |
313 "~/.local/share/pixmaps/ericWeb" + marker + ".png", |
|
314 ]: |
284 ]: |
315 path = os.path.expanduser(name) |
285 path = os.path.expanduser(name) |
316 if os.path.exists(path): |
286 if os.path.exists(path): |
317 os.remove(path) |
287 os.remove(path) |
318 |
288 |
356 print("Found these plug-in directories") |
326 print("Found these plug-in directories") |
357 for path in pathsToRemove: |
327 for path in pathsToRemove: |
358 print(" - {0}".format(path)) |
328 print(" - {0}".format(path)) |
359 answer = "c" |
329 answer = "c" |
360 while answer not in ["y", "Y", "n", "N", ""]: |
330 while answer not in ["y", "Y", "n", "N", ""]: |
361 answer = raw_input( |
331 answer = input("Shall these directories be removed (y/N)? ") |
362 "Shall these directories be removed (y/N)? ") |
|
363 if answer in ["y", "Y"]: |
332 if answer in ["y", "Y"]: |
364 for path in pathsToRemove: |
333 for path in pathsToRemove: |
365 shutil.rmtree(path) |
334 shutil.rmtree(path) |
366 |
335 |
367 |
336 |
373 if os.path.exists(cfg): |
342 if os.path.exists(cfg): |
374 print("Found the eric data directory") |
343 print("Found the eric data directory") |
375 print(" - {0}".format(cfg)) |
344 print(" - {0}".format(cfg)) |
376 answer = "c" |
345 answer = "c" |
377 while answer not in ["y", "Y", "n", "N", ""]: |
346 while answer not in ["y", "Y", "n", "N", ""]: |
378 answer = raw_input( |
347 answer = input("Shall this directory be removed (y/N)? ") |
379 "Shall this directory be removed (y/N)? ") |
|
380 if answer in ["y", "Y"]: |
348 if answer in ["y", "Y"]: |
381 shutil.rmtree(cfg) |
349 shutil.rmtree(cfg) |
382 |
350 |
383 |
351 |
384 def removeConfigurationData(): |
352 def removeConfigurationData(): |
386 Remove the eric configuration directory. |
354 Remove the eric configuration directory. |
387 """ |
355 """ |
388 try: |
356 try: |
389 from PyQt5.QtCore import QSettings |
357 from PyQt5.QtCore import QSettings |
390 except ImportError: |
358 except ImportError: |
391 try: |
359 print("No PyQt variant installed. The configuration directory") |
392 from PyQt4.QtCore import QSettings |
360 print("cannot be determined. You have to remove it manually.\n") |
393 except ImportError: |
361 return |
394 print("No PyQt variant installed. The configuration directory") |
|
395 print("cannot be determined. You have to remove it manually.\n") |
|
396 return |
|
397 |
362 |
398 settings = QSettings(QSettings.IniFormat, QSettings.UserScope, |
363 settings = QSettings(QSettings.IniFormat, QSettings.UserScope, |
399 settingsNameOrganization, settingsNameGlobal) |
364 settingsNameOrganization, settingsNameGlobal) |
400 settingsDir = os.path.dirname(settings.fileName()) |
365 settingsDir = os.path.dirname(settings.fileName()) |
401 if os.path.exists(settingsDir): |
366 if os.path.exists(settingsDir): |
402 print("Found the eric configuration directory") |
367 print("Found the eric configuration directory") |
403 print(" - {0}".format(settingsDir)) |
368 print(" - {0}".format(settingsDir)) |
404 answer = "c" |
369 answer = "c" |
405 while answer not in ["y", "Y", "n", "N", ""]: |
370 while answer not in ["y", "Y", "n", "N", ""]: |
406 answer = raw_input( |
371 answer = input("Shall this directory be removed (y/N)? ") |
407 "Shall this directory be removed (y/N)? ") |
|
408 if answer in ["y", "Y"]: |
372 if answer in ["y", "Y"]: |
409 shutil.rmtree(settingsDir) |
373 shutil.rmtree(settingsDir) |
410 |
374 |
411 |
375 |
412 def getConfigDir(): |
376 def getConfigDir(): |