uninstall.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2002-2009 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6 # This is the uninstall script for eric4.
7
8 """
9 Uninstallation script for the eric4 IDE and all eric4 related tools.
10 """
11
12 import sys
13 import os
14 import shutil
15 import glob
16 import distutils.sysconfig
17
18 from eric4config import getConfig
19
20 # Define the globals.
21 progName = None
22 pyModDir = None
23
24 def usage(rcode = 2):
25 """Display a usage message and exit.
26
27 rcode is the return code passed back to the calling process.
28 """
29 global progName
30
31 print "Usage:"
32 print " %s [-h]" % (progName)
33 print "where:"
34 print " -h display this help message"
35
36 sys.exit(rcode)
37
38
39 def initGlobals():
40 """
41 Sets the values of globals that need more than a simple assignment.
42 """
43 global pyModDir
44
45 pyModDir = distutils.sysconfig.get_python_lib(True)
46
47
48 def wrapperName(dname,wfile):
49 """Create the platform specific name for the wrapper script.
50 """
51 if sys.platform.startswith("win"):
52 wname = dname + "\\" + wfile + ".bat"
53 else:
54 wname = dname + "/" + wfile
55
56 return wname
57
58
59 def uninstallEric():
60 """
61 Uninstall the eric files.
62 """
63 global pyModDir
64
65 # Remove the wrapper scripts
66 rem_wnames = [
67 "eric4-api", "eric4-compare",
68 "eric4-configure", "eric4-diff",
69 "eric4-doc", "eric4-helpviewer",
70 "eric4-qregexp", "eric4-re",
71 "eric4-trpreviewer", "eric4-uipreviewer",
72 "eric4-unittest", "eric4",
73 "eric4-tray", "eric4-editor",
74 "eric4-plugininstall", "eric4-pluginuninstall",
75 "eric4-pluginrepository", "eric4-sqlbrowser",
76 "eric4-webbrowser",
77 ]
78 for rem_wname in rem_wnames:
79 rwname = wrapperName(getConfig('bindir'),rem_wname)
80 if os.path.exists(rwname):
81 os.remove(rwname)
82
83 # Cleanup our config file
84 for name in ['eric4config.py', 'eric4config.pyc']:
85 e4cfile = os.path.join(pyModDir, name)
86 if os.path.exists(e4cfile):
87 os.remove(e4cfile)
88
89 # Cleanup the install directories
90 for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir',
91 'ericIconDir', 'ericPixDir', 'ericDir', 'ericTemplatesDir',
92 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir']:
93 dirpath = getConfig(name)
94 if os.path.exists(dirpath):
95 shutil.rmtree(dirpath, True)
96
97 # Cleanup translations
98 for name in glob.glob(os.path.join(getConfig('ericTranslationsDir'), 'eric4_*.qm')):
99 if os.path.exists(name):
100 os.remove(name)
101
102 # Cleanup API files
103 apidir = getConfig('apidir')
104 for name in getConfig('apis'):
105 apiname = os.path.join(apidir, name)
106 if os.path.exists(apiname):
107 os.remove(apiname)
108
109 def main(argv):
110 """The main function of the script.
111
112 argv is the list of command line arguments.
113 """
114 import getopt
115
116 initGlobals()
117
118 # Parse the command line.
119 global progName
120 progName = os.path.basename(argv[0])
121
122 try:
123 optlist, args = getopt.getopt(argv[1:],"h")
124 except getopt.GetoptError:
125 usage()
126
127 global platBinDir
128
129 for opt, arg in optlist:
130 if opt == "-h":
131 usage(0)
132
133 try:
134 uninstallEric()
135 except IOError, msg:
136 sys.stderr.write('IOError: %s\nTry uninstall as root.\n' % msg)
137
138
139 if __name__ == "__main__":
140 try:
141 main(sys.argv)
142 except SystemExit:
143 raise
144 except:
145 print \
146 """An internal error occured. Please report all the output of the program,
147 including the following traceback, to eric5-bugs@eric-ide.python-projects.org.
148 """
149 raise

eric ide

mercurial