eric6/UI/UserInterface.py

changeset 7804
1cbc27e34ec6
parent 7785
9978016560ec
child 7806
b346755b09a1
--- a/eric6/UI/UserInterface.py	Sun Oct 18 12:42:37 2020 +0200
+++ b/eric6/UI/UserInterface.py	Sun Oct 18 18:51:45 2020 +0200
@@ -10,6 +10,8 @@
 import os
 import sys
 import logging
+import shutil
+import json
 
 from PyQt5.QtCore import (
     pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate,
@@ -1457,7 +1459,46 @@
             # no files, project or multiproject was given
             if not self.__noOpenAtStartup:
                 self.__openOnStartup()
-        
+    
+    def processInstallInfoFile(self):
+        """
+        Public method to process the file containing installation information.
+        """
+        import Globals
+        
+        installInfoFile = Globals.getInstallInfoFilePath()
+        if not os.path.exists(installInfoFile):
+            filename = os.path.join(getConfig("ericDir"), "eric6install.json")
+            if os.path.exists(filename):
+                # eric was installed via the install.py script
+                shutil.copy2(filename, installInfoFile)
+            else:
+                filename = os.path.join(getConfig("ericDir"),
+                                        "eric6installpip.json")
+                if os.path.exists(filename):
+                    # eric was installed via pip (i.e. eric-ide)
+                    try:
+                        with open(filename, "r") as infoFile:
+                            installInfo = json.load(infoFile)
+                        installInfo["guessed"] = True
+                        installInfo["eric"] = getConfig("ericDir")
+                        installInfo["virtualenv"] = (
+                            installInfo["eric"].startswith(
+                                os.path.expanduser("~"))
+                        )
+                        if installInfo["virtualenv"]:
+                            installInfo["user"] = os.getlogin()
+                            installInfo["exe"] = sys.executable
+                        installInfo["installed"] = True
+                        installInfo["remarks"] = ""
+                        installInfo["sudo"] = not os.access(
+                            installInfo["eric"], os.W_OK)
+                        with open(installInfoFile, "w") as infoFile:
+                            json.dump(installInfo, infoFile, indent=2)
+                    except EnvironmentError:
+                        # ignore this
+                        pass
+    
     def __createDockWindow(self, name):
         """
         Private method to create a dock window with common properties.

eric ide

mercurial