uninstall.py

changeset 6500
0373580fc86c
parent 6495
6e73d31af3af
child 6509
884182bfd25c
diff -r dcff57f91861 -r 0373580fc86c uninstall.py
--- a/uninstall.py	Sat Sep 15 19:59:20 2018 +0200
+++ b/uninstall.py	Sun Sep 16 18:15:43 2018 +0200
@@ -127,53 +127,7 @@
     
     # Remove the menu entry for Linux systems
     if sys.platform.startswith("linux"):
-        if os.getuid() == 0:
-            for name in ["/usr/share/pixmaps/eric.png",
-                         "/usr/share/pixmaps/ericWeb.png"]:
-                if os.path.exists(name):
-                    os.remove(name)
-            if includePythonVariant:
-                marker = PythonMarkers[sys.version_info.major]
-            else:
-                marker = ""
-            for name in [
-                "/usr/share/applications/eric6" + marker + ".desktop",
-                "/usr/share/appdata/eric6" + marker + ".appdata.xml",
-                "/usr/share/metainfo/eric6" + marker + ".appdata.xml",
-                "/usr/share/applications/eric6_webbrowser" + marker +
-                ".desktop",
-                "/usr/share/applications/eric6_browser" + marker +
-                ".desktop",
-                "/usr/share/pixmaps/eric" + marker + ".png",
-                "/usr/share/pixmaps/ericWeb" + marker + ".png",
-            ]:
-                if os.path.exists(name):
-                    os.remove(name)
-        elif os.getuid() >= 1000:
-            # it is assumed that user ids start at 1000
-            for name in ["~/.local/share/pixmaps/eric.png",
-                         "~/.local/share/pixmaps/ericWeb.png"]:
-                path = os.path.expanduser(name)
-                if os.path.exists(path):
-                    os.remove(path)
-            if includePythonVariant:
-                marker = PythonMarkers[sys.version_info.major]
-            else:
-                marker = ""
-            for name in [
-                "~/.local/share/applications/eric6" + marker + ".desktop",
-                "~/.local/share/appdata/eric6" + marker + ".appdata.xml",
-                "~/.local/share/metainfo/eric6" + marker + ".appdata.xml",
-                "~/.local/share/applications/eric6_webbrowser" + marker +
-                ".desktop",
-                "~/.local/share/applications/eric6_browser" + marker +
-                ".desktop",
-                "~/.local/share/pixmaps/eric" + marker + ".png",
-                "~/.local/share/pixmaps/ericWeb" + marker + ".png",
-            ]:
-                path = os.path.expanduser(name)
-                if os.path.exists(path):
-                    os.remove(path)
+        uninstallLinuxSpecifics()
     
     # Remove the wrapper scripts
     rem_wnames = [
@@ -240,21 +194,7 @@
         
         if sys.platform == "darwin":
             # delete the Mac app bundle
-            if os.path.exists("/Developer/Applications/Eric6"):
-                shutil.rmtree("/Developer/Applications/Eric6")
-            try:
-                macAppBundlePath = getConfig("macAppBundlePath")
-                macAppBundleName = getConfig("macAppBundleName")
-            except AttributeError:
-                macAppBundlePath = defaultMacAppBundlePath
-                macAppBundleName = defaultMacAppBundleName
-            for bundlePath in [os.path.join(defaultMacAppBundlePath,
-                                            macAppBundleName),
-                               os.path.join(macAppBundlePath,
-                                            macAppBundleName),
-                               ]:
-                if os.path.exists(bundlePath):
-                    shutil.rmtree(bundlePath)
+            uninstallMacAppBundle()
         
         # remove plug-in directories
         removePluginDirectories()
@@ -272,6 +212,80 @@
         exit(7)
 
 
+def uninstallLinuxSpecifics():
+    """
+    Uninstall Linux specific files.
+    """
+    if os.getuid() == 0:
+        for name in ["/usr/share/pixmaps/eric.png",
+                     "/usr/share/pixmaps/ericWeb.png"]:
+            if os.path.exists(name):
+                os.remove(name)
+        if includePythonVariant:
+            marker = PythonMarkers[sys.version_info.major]
+        else:
+            marker = ""
+        for name in [
+            "/usr/share/applications/eric6" + marker + ".desktop",
+            "/usr/share/appdata/eric6" + marker + ".appdata.xml",
+            "/usr/share/metainfo/eric6" + marker + ".appdata.xml",
+            "/usr/share/applications/eric6_webbrowser" + marker +
+            ".desktop",
+            "/usr/share/applications/eric6_browser" + marker +
+            ".desktop",
+            "/usr/share/pixmaps/eric" + marker + ".png",
+            "/usr/share/pixmaps/ericWeb" + marker + ".png",
+        ]:
+            if os.path.exists(name):
+                os.remove(name)
+    elif os.getuid() >= 1000:
+        # it is assumed that user ids start at 1000
+        for name in ["~/.local/share/pixmaps/eric.png",
+                     "~/.local/share/pixmaps/ericWeb.png"]:
+            path = os.path.expanduser(name)
+            if os.path.exists(path):
+                os.remove(path)
+        if includePythonVariant:
+            marker = PythonMarkers[sys.version_info.major]
+        else:
+            marker = ""
+        for name in [
+            "~/.local/share/applications/eric6" + marker + ".desktop",
+            "~/.local/share/appdata/eric6" + marker + ".appdata.xml",
+            "~/.local/share/metainfo/eric6" + marker + ".appdata.xml",
+            "~/.local/share/applications/eric6_webbrowser" + marker +
+            ".desktop",
+            "~/.local/share/applications/eric6_browser" + marker +
+            ".desktop",
+            "~/.local/share/pixmaps/eric" + marker + ".png",
+            "~/.local/share/pixmaps/ericWeb" + marker + ".png",
+        ]:
+            path = os.path.expanduser(name)
+            if os.path.exists(path):
+                os.remove(path)
+
+
+def uninstallMacAppBundle():
+    """
+    Uninstall the macOS application bundle.
+    """
+    if os.path.exists("/Developer/Applications/Eric6"):
+        shutil.rmtree("/Developer/Applications/Eric6")
+    try:
+        macAppBundlePath = getConfig("macAppBundlePath")
+        macAppBundleName = getConfig("macAppBundleName")
+    except AttributeError:
+        macAppBundlePath = defaultMacAppBundlePath
+        macAppBundleName = defaultMacAppBundleName
+    for bundlePath in [os.path.join(defaultMacAppBundlePath,
+                                    macAppBundleName),
+                       os.path.join(macAppBundlePath,
+                                    macAppBundleName),
+                       ]:
+        if os.path.exists(bundlePath):
+            shutil.rmtree(bundlePath)
+
+
 def removePluginDirectories():
     """
     Remove the plug-in directories.

eric ide

mercurial