8 |
8 |
9 """ |
9 """ |
10 Uninstallation script for the eric IDE and all eric related tools. |
10 Uninstallation script for the eric IDE and all eric related tools. |
11 """ |
11 """ |
12 |
12 |
|
13 import argparse |
13 import contextlib |
14 import contextlib |
14 import getopt |
|
15 import glob |
15 import glob |
16 import os |
16 import os |
17 import shutil |
17 import shutil |
18 import sys |
18 import sys |
19 import sysconfig |
19 import sysconfig |
20 |
20 |
21 # Define the globals. |
21 # Define the globals. |
22 progName = None |
|
23 currDir = os.getcwd() |
22 currDir = os.getcwd() |
24 pyModDir = None |
23 pyModDir = None |
25 progLanguages = ["MicroPython", "Python3", "QSS"] |
24 progLanguages = ["MicroPython", "Python3", "QSS"] |
26 defaultMacAppBundleName = "eric7.app" |
25 defaultMacAppBundleName = "eric7.app" |
27 defaultMacAppBundlePath = "/Applications" |
26 defaultMacAppBundlePath = "/Applications" |
63 exit(1) |
62 exit(1) |
64 except SyntaxError: |
63 except SyntaxError: |
65 # an incomplete or old config file was found |
64 # an incomplete or old config file was found |
66 print("The eric IDE seems to be installed incompletely. Aborting.") |
65 print("The eric IDE seems to be installed incompletely. Aborting.") |
67 exit(1) |
66 exit(1) |
68 |
|
69 |
|
70 def usage(rcode=2): |
|
71 """ |
|
72 Display a usage message and exit. |
|
73 |
|
74 @param rcode return code passed back to the calling process (integer) |
|
75 """ |
|
76 global progName |
|
77 |
|
78 print("Usage:") |
|
79 print(" {0} [-h]".format(progName)) |
|
80 print("where:") |
|
81 print(" -h display this help message") |
|
82 |
|
83 exit(rcode) |
|
84 |
67 |
85 |
68 |
86 def initGlobals(): |
69 def initGlobals(): |
87 """ |
70 """ |
88 Set the values of globals that need more than a simple assignment. |
71 Set the values of globals that need more than a simple assignment. |
340 try: |
323 try: |
341 macAppBundlePath = getConfig("macAppBundlePath") |
324 macAppBundlePath = getConfig("macAppBundlePath") |
342 macAppBundleName = getConfig("macAppBundleName") |
325 macAppBundleName = getConfig("macAppBundleName") |
343 except AttributeError: |
326 except AttributeError: |
344 macAppBundlePath = ( |
327 macAppBundlePath = ( |
345 defaultMacAppBundlePath |
328 defaultMacAppBundlePath if os.getpid() == 0 else defaultMacUserAppBundlePath |
346 if os.getpid() == 0 |
|
347 else defaultMacUserAppBundlePath |
|
348 ) |
329 ) |
349 macAppBundleName = defaultMacAppBundleName |
330 macAppBundleName = defaultMacAppBundleName |
350 for bundlePath in [ |
331 for bundlePath in [ |
351 os.path.join(defaultMacAppBundlePath, macAppBundleName), |
332 os.path.join(defaultMacAppBundlePath, macAppBundleName), |
352 os.path.join(defaultMacUserAppBundlePath, macAppBundleName), |
333 os.path.join(defaultMacUserAppBundlePath, macAppBundleName), |
488 """ |
469 """ |
489 majorVersion, minorVersion = sys.version_info[:2] |
470 majorVersion, minorVersion = sys.version_info[:2] |
490 return "eric7 (Python {0}.{1})".format(majorVersion, minorVersion) |
471 return "eric7 (Python {0}.{1})".format(majorVersion, minorVersion) |
491 |
472 |
492 |
473 |
493 def main(argv): |
474 def createArgumentParser(): |
|
475 """ |
|
476 Function to create an argument parser. |
|
477 |
|
478 @return created argument parser object |
|
479 @rtype argparse.ArgumentParser |
|
480 """ |
|
481 parser = argparse.ArgumentParser(description="Uninstall eric7.") |
|
482 return parser |
|
483 |
|
484 |
|
485 def main(): |
494 """ |
486 """ |
495 The main function of the script. |
487 The main function of the script. |
496 |
|
497 @param argv list of command line arguments |
|
498 """ |
488 """ |
499 initGlobals() |
489 initGlobals() |
500 |
490 |
501 # Parse the command line. |
491 parser = createArgumentParser() |
502 global progName |
492 parser.parse_args() |
503 progName = os.path.basename(argv[0]) |
|
504 |
|
505 try: |
|
506 optlist, args = getopt.getopt(argv[1:], "hy") |
|
507 except getopt.GetoptError: |
|
508 usage() |
|
509 |
|
510 global platBinDir |
|
511 |
|
512 for opt, _arg in optlist: |
|
513 if opt == "-h": |
|
514 usage(0) |
|
515 |
493 |
516 print("\nUninstalling eric ...") |
494 print("\nUninstalling eric ...") |
517 uninstallEric() |
495 uninstallEric() |
518 print("\nUninstallation complete.") |
496 print("\nUninstallation complete.") |
519 print() |
497 print() |