scripts/uninstall.py

branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 6942
2602857055c5
child 7203
2079ccbfa335
equal deleted inserted replaced
7191:960850ec284c 7192:a22eee00b052
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 # get a local eric6config.py out of the way 21 # get a local eric6config.py out of the way
31 if os.path.exists("eric6config.py"): 22 if os.path.exists("eric6config.py"):
32 os.rename("eric6config.py", "eric6config.py.orig") 23 os.rename("eric6config.py", "eric6config.py.orig")
33 from eric6config import getConfig 24 from eric6config import getConfig
34 25
35 # Define the globals. 26 # Define the globals.
36 progName = None 27 progName = None
37 currDir = os.getcwd() 28 currDir = os.getcwd()
38 pyModDir = None 29 pyModDir = None
39 progLanguages = ["Python", "Ruby", "QSS"] 30 progLanguages = ["Python", "Ruby", "QSS"]
40 includePythonVariant = False
41 defaultMacAppBundleName = "eric6.app" 31 defaultMacAppBundleName = "eric6.app"
42 defaultMacAppBundlePath = "/Applications" 32 defaultMacAppBundlePath = "/Applications"
43 settingsNameOrganization = "Eric6" 33 settingsNameOrganization = "Eric6"
44 settingsNameGlobal = "eric6" 34 settingsNameGlobal = "eric6"
45
46 # Define file name markers for Python variants
47 PythonMarkers = {
48 2: "_py2",
49 3: "_py3",
50 }
51 35
52 36
53 def exit(rcode=0): 37 def exit(rcode=0):
54 """ 38 """
55 Exit the uninstall script. 39 Exit the uninstall script.
63 if os.path.exists("eric6config.py"): 47 if os.path.exists("eric6config.py"):
64 os.remove("eric6config.py") 48 os.remove("eric6config.py")
65 os.rename("eric6config.py.orig", "eric6config.py") 49 os.rename("eric6config.py.orig", "eric6config.py")
66 50
67 if sys.platform.startswith(("win", "cygwin")): 51 if sys.platform.startswith(("win", "cygwin")):
68 # different meaning of input between Py2 and Py3
69 try: 52 try:
70 input("Press enter to continue...") 53 input("Press enter to continue...")
71 except (EOFError, SyntaxError): 54 except (EOFError, SyntaxError):
72 pass 55 pass
73 56
86 69
87 print("Usage:") 70 print("Usage:")
88 print(" {0} [-h]".format(progName)) 71 print(" {0} [-h]".format(progName))
89 print("where:") 72 print("where:")
90 print(" -h display this help message") 73 print(" -h display this help message")
91 print(" -y remove executables with Python variant in name")
92 74
93 exit(rcode) 75 exit(rcode)
94 76
95 77
96 def initGlobals(): 78 def initGlobals():
141 "eric6_trpreviewer", "eric6_uipreviewer", 123 "eric6_trpreviewer", "eric6_uipreviewer",
142 "eric6_unittest", "eric6", 124 "eric6_unittest", "eric6",
143 "eric6_tray", "eric6_editor", 125 "eric6_tray", "eric6_editor",
144 "eric6_plugininstall", "eric6_pluginuninstall", 126 "eric6_plugininstall", "eric6_pluginuninstall",
145 "eric6_pluginrepository", "eric6_sqlbrowser", 127 "eric6_pluginrepository", "eric6_sqlbrowser",
146 "eric6_webbrowser", "eric6_iconeditor", 128 "eric6_iconeditor", "eric6_snap", "eric6_hexeditor",
147 "eric6_snap", "eric6_hexeditor", "eric6_browser", 129 "eric6_browser", "eric6_shell",
148 "eric6_shell",
149 ] 130 ]
150 if includePythonVariant:
151 marker = PythonMarkers[sys.version_info.major]
152 rem_wnames = [n + marker for n in rem_wnames]
153 131
154 try: 132 try:
155 for rem_wname in rem_wnames: 133 for rem_wname in rem_wnames:
156 for rwname in wrapperNames(getConfig('bindir'), rem_wname): 134 for rwname in wrapperNames(getConfig('bindir'), rem_wname):
157 if os.path.exists(rwname): 135 if os.path.exists(rwname):
263 if os.getuid() == 0: 241 if os.getuid() == 0:
264 for name in ["/usr/share/pixmaps/eric.png", 242 for name in ["/usr/share/pixmaps/eric.png",
265 "/usr/share/pixmaps/ericWeb.png"]: 243 "/usr/share/pixmaps/ericWeb.png"]:
266 if os.path.exists(name): 244 if os.path.exists(name):
267 os.remove(name) 245 os.remove(name)
268 if includePythonVariant:
269 marker = PythonMarkers[sys.version_info.major]
270 else:
271 marker = ""
272 for name in [ 246 for name in [
273 "/usr/share/applications/eric6" + marker + ".desktop", 247 "/usr/share/applications/eric6.desktop",
274 "/usr/share/appdata/eric6" + marker + ".appdata.xml", 248 "/usr/share/appdata/eric6.appdata.xml",
275 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", 249 "/usr/share/metainfo/eric6.appdata.xml",
276 "/usr/share/applications/eric6_webbrowser" + marker + 250 "/usr/share/applications/eric6_browser.desktop",
277 ".desktop", 251 "/usr/share/pixmaps/eric.png",
278 "/usr/share/applications/eric6_browser" + marker + 252 "/usr/share/pixmaps/ericWeb.png",
279 ".desktop",
280 "/usr/share/pixmaps/eric" + marker + ".png",
281 "/usr/share/pixmaps/ericWeb" + marker + ".png",
282 ]: 253 ]:
283 if os.path.exists(name): 254 if os.path.exists(name):
284 os.remove(name) 255 os.remove(name)
285 elif os.getuid() >= 1000: 256 elif os.getuid() >= 1000:
286 # it is assumed that user ids start at 1000 257 # it is assumed that user ids start at 1000
287 for name in ["~/.local/share/pixmaps/eric.png", 258 for name in ["~/.local/share/pixmaps/eric.png",
288 "~/.local/share/pixmaps/ericWeb.png"]: 259 "~/.local/share/pixmaps/ericWeb.png"]:
289 path = os.path.expanduser(name) 260 path = os.path.expanduser(name)
290 if os.path.exists(path): 261 if os.path.exists(path):
291 os.remove(path) 262 os.remove(path)
292 if includePythonVariant:
293 marker = PythonMarkers[sys.version_info.major]
294 else:
295 marker = ""
296 for name in [ 263 for name in [
297 "~/.local/share/applications/eric6" + marker + ".desktop", 264 "~/.local/share/applications/eric6.desktop",
298 "~/.local/share/appdata/eric6" + marker + ".appdata.xml", 265 "~/.local/share/appdata/eric6.appdata.xml",
299 "~/.local/share/metainfo/eric6" + marker + ".appdata.xml", 266 "~/.local/share/metainfo/eric6.appdata.xml",
300 "~/.local/share/applications/eric6_webbrowser" + marker + 267 "~/.local/share/applications/eric6_browser.desktop",
301 ".desktop", 268 "~/.local/share/pixmaps/eric.png",
302 "~/.local/share/applications/eric6_browser" + marker + 269 "~/.local/share/pixmaps/ericWeb.png",
303 ".desktop",
304 "~/.local/share/pixmaps/eric" + marker + ".png",
305 "~/.local/share/pixmaps/ericWeb" + marker + ".png",
306 ]: 270 ]:
307 path = os.path.expanduser(name) 271 path = os.path.expanduser(name)
308 if os.path.exists(path): 272 if os.path.exists(path):
309 os.remove(path) 273 os.remove(path)
310 274
348 print("Found these plug-in directories") 312 print("Found these plug-in directories")
349 for path in pathsToRemove: 313 for path in pathsToRemove:
350 print(" - {0}".format(path)) 314 print(" - {0}".format(path))
351 answer = "c" 315 answer = "c"
352 while answer not in ["y", "Y", "n", "N", ""]: 316 while answer not in ["y", "Y", "n", "N", ""]:
353 answer = raw_input( 317 answer = input("Shall these directories be removed (y/N)? ")
354 "Shall these directories be removed (y/N)? ")
355 if answer in ["y", "Y"]: 318 if answer in ["y", "Y"]:
356 for path in pathsToRemove: 319 for path in pathsToRemove:
357 shutil.rmtree(path) 320 shutil.rmtree(path)
358 321
359 322
365 if os.path.exists(cfg): 328 if os.path.exists(cfg):
366 print("Found the eric data directory") 329 print("Found the eric data directory")
367 print(" - {0}".format(cfg)) 330 print(" - {0}".format(cfg))
368 answer = "c" 331 answer = "c"
369 while answer not in ["y", "Y", "n", "N", ""]: 332 while answer not in ["y", "Y", "n", "N", ""]:
370 answer = raw_input( 333 answer = input("Shall this directory be removed (y/N)? ")
371 "Shall this directory be removed (y/N)? ")
372 if answer in ["y", "Y"]: 334 if answer in ["y", "Y"]:
373 shutil.rmtree(cfg) 335 shutil.rmtree(cfg)
374 336
375 337
376 def removeConfigurationData(): 338 def removeConfigurationData():
378 Remove the eric configuration directory. 340 Remove the eric configuration directory.
379 """ 341 """
380 try: 342 try:
381 from PyQt5.QtCore import QSettings 343 from PyQt5.QtCore import QSettings
382 except ImportError: 344 except ImportError:
383 try: 345 print("No PyQt variant installed. The configuration directory")
384 from PyQt4.QtCore import QSettings 346 print("cannot be determined. You have to remove it manually.\n")
385 except ImportError: 347 return
386 print("No PyQt variant installed. The configuration directory")
387 print("cannot be determined. You have to remove it manually.\n")
388 return
389 348
390 settings = QSettings(QSettings.IniFormat, QSettings.UserScope, 349 settings = QSettings(QSettings.IniFormat, QSettings.UserScope,
391 settingsNameOrganization, settingsNameGlobal) 350 settingsNameOrganization, settingsNameGlobal)
392 settingsDir = os.path.dirname(settings.fileName()) 351 settingsDir = os.path.dirname(settings.fileName())
393 if os.path.exists(settingsDir): 352 if os.path.exists(settingsDir):
394 print("Found the eric configuration directory") 353 print("Found the eric configuration directory")
395 print(" - {0}".format(settingsDir)) 354 print(" - {0}".format(settingsDir))
396 answer = "c" 355 answer = "c"
397 while answer not in ["y", "Y", "n", "N", ""]: 356 while answer not in ["y", "Y", "n", "N", ""]:
398 answer = raw_input( 357 answer = input("Shall this directory be removed (y/N)? ")
399 "Shall this directory be removed (y/N)? ")
400 if answer in ["y", "Y"]: 358 if answer in ["y", "Y"]:
401 shutil.rmtree(settingsDir) 359 shutil.rmtree(settingsDir)
402 360
403 361
404 def getConfigDir(): 362 def getConfigDir():
467 425
468 @param argv list of command line arguments 426 @param argv list of command line arguments
469 """ 427 """
470 import getopt 428 import getopt
471 429
472 global includePythonVariant
473
474 initGlobals() 430 initGlobals()
475 431
476 # Parse the command line. 432 # Parse the command line.
477 global progName 433 global progName
478 progName = os.path.basename(argv[0]) 434 progName = os.path.basename(argv[0])
485 global platBinDir 441 global platBinDir
486 442
487 for opt, _arg in optlist: 443 for opt, _arg in optlist:
488 if opt == "-h": 444 if opt == "-h":
489 usage(0) 445 usage(0)
490 if opt == "-y":
491 includePythonVariant = True
492 446
493 print("\nUninstalling eric6 ...") 447 print("\nUninstalling eric6 ...")
494 uninstallEric() 448 uninstallEric()
495 print("\nUninstallation complete.") 449 print("\nUninstallation complete.")
496 print() 450 print()

eric ide

mercurial