8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 import sys |
11 import sys |
12 import logging |
12 import logging |
|
13 import shutil |
|
14 import json |
|
15 import datetime |
|
16 import getpass |
13 |
17 |
14 from PyQt5.QtCore import ( |
18 from PyQt5.QtCore import ( |
15 pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, |
19 pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, |
16 QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread, |
20 QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread, |
17 QUrlQuery |
21 QUrlQuery |
1443 |
1448 |
1444 if opens == 0: |
1449 if opens == 0: |
1445 # no files, project or multiproject was given |
1450 # no files, project or multiproject was given |
1446 if not self.__noOpenAtStartup: |
1451 if not self.__noOpenAtStartup: |
1447 self.__openOnStartup() |
1452 self.__openOnStartup() |
1448 |
1453 |
|
1454 def processInstallInfoFile(self): |
|
1455 """ |
|
1456 Public method to process the file containing installation information. |
|
1457 """ |
|
1458 import Globals |
|
1459 |
|
1460 installInfoFile = Globals.getInstallInfoFilePath() |
|
1461 if not os.path.exists(installInfoFile): |
|
1462 filename = os.path.join(getConfig("ericDir"), "eric6install.json") |
|
1463 if os.path.exists(filename): |
|
1464 # eric was installed via the install.py script |
|
1465 shutil.copy2(filename, installInfoFile) |
|
1466 else: |
|
1467 filename = os.path.join(getConfig("ericDir"), |
|
1468 "eric6installpip.json") |
|
1469 if os.path.exists(filename): |
|
1470 # eric was installed via pip (i.e. eric-ide) |
|
1471 try: |
|
1472 installDateTime = datetime.datetime.now(tz=None) |
|
1473 with open(filename, "r") as infoFile: |
|
1474 installInfo = json.load(infoFile) |
|
1475 installInfo["guessed"] = True |
|
1476 installInfo["eric"] = getConfig("ericDir") |
|
1477 installInfo["virtualenv"] = ( |
|
1478 installInfo["eric"].startswith( |
|
1479 os.path.expanduser("~")) |
|
1480 ) |
|
1481 if installInfo["virtualenv"]: |
|
1482 installInfo["user"] = getpass.getuser() |
|
1483 installInfo["exe"] = sys.executable |
|
1484 installInfo["installed"] = True |
|
1485 installInfo["installed_on"] = installDateTime.strftime( |
|
1486 "%Y-%m-%d %H:%M:%S") |
|
1487 installInfo["sudo"] = not os.access( |
|
1488 installInfo["eric"], os.W_OK) |
|
1489 with open(installInfoFile, "w") as infoFile: |
|
1490 json.dump(installInfo, infoFile, indent=2) |
|
1491 except EnvironmentError: |
|
1492 # ignore this |
|
1493 pass |
|
1494 else: |
|
1495 changed = False |
|
1496 with open(installInfoFile, "r") as infoFile: |
|
1497 installInfo = json.load(infoFile) |
|
1498 |
|
1499 # 1. adapt stored file to latest format |
|
1500 if "install_cwd" not in installInfo: |
|
1501 installInfo["install_cwd"] = "" |
|
1502 installInfo["install_cwd_edited"] = False |
|
1503 changed = True |
|
1504 if "installed_on" not in installInfo: |
|
1505 installInfo["installed_on"] = "" |
|
1506 changed = True |
|
1507 |
|
1508 # 2. merge new data into stored file |
|
1509 filename = os.path.join(getConfig("ericDir"), "eric6install.json") |
|
1510 if os.path.exists(filename): |
|
1511 # eric was updated via the install.py script |
|
1512 if ( |
|
1513 os.path.getmtime(filename) > |
|
1514 os.path.getmtime(installInfoFile) |
|
1515 ): |
|
1516 if not installInfo["edited"]: |
|
1517 shutil.copy2(filename, installInfoFile) |
|
1518 else: |
|
1519 with open(filename, "r") as infoFile: |
|
1520 installInfo2 = json.load(infoFile) |
|
1521 if not installInfo["install_cwd_edited"]: |
|
1522 installInfo2["install_cwd"] = installInfo[ |
|
1523 "install_cwd"] |
|
1524 if not installInfo["exe_edited"]: |
|
1525 installInfo2["exe"] = installInfo["exe"] |
|
1526 if not installInfo["argv_edited"]: |
|
1527 installInfo2["argv"] = installInfo["argv"] |
|
1528 if not installInfo["eric_edited"]: |
|
1529 installInfo2["eric"] = installInfo["eric"] |
|
1530 installInfo = installInfo2 |
|
1531 changed = True |
|
1532 else: |
|
1533 filename = os.path.join(getConfig("ericDir"), |
|
1534 "eric6installpip.json") |
|
1535 if os.path.exists(filename): |
|
1536 # eric was updated via pip (i.e. eric-ide) |
|
1537 # just update the installation date and time |
|
1538 installDateTime = datetime.datetime.now(tz=None) |
|
1539 installInfo["installed_on"] = installDateTime.strftime( |
|
1540 "%Y-%m-%d %H:%M:%S") |
|
1541 changed = True |
|
1542 |
|
1543 if changed: |
|
1544 with open(installInfoFile, "w") as infoFile: |
|
1545 json.dump(installInfo, infoFile, indent=2) |
|
1546 |
1449 def __createDockWindow(self, name): |
1547 def __createDockWindow(self, name): |
1450 """ |
1548 """ |
1451 Private method to create a dock window with common properties. |
1549 Private method to create a dock window with common properties. |
1452 |
1550 |
1453 @param name object name of the new dock window (string) |
1551 @param name object name of the new dock window (string) |
2100 """<b>Show Error Log...</b>""" |
2198 """<b>Show Error Log...</b>""" |
2101 """<p>Opens a dialog showing the most recent error log.</p>""" |
2199 """<p>Opens a dialog showing the most recent error log.</p>""" |
2102 )) |
2200 )) |
2103 self.showErrorLogAct.triggered.connect(self.__showErrorLog) |
2201 self.showErrorLogAct.triggered.connect(self.__showErrorLog) |
2104 self.actions.append(self.showErrorLogAct) |
2202 self.actions.append(self.showErrorLogAct) |
|
2203 |
|
2204 self.showInstallInfoAct = E5Action( |
|
2205 self.tr('Show Install Info'), |
|
2206 self.tr('Show Install &Info...'), |
|
2207 0, 0, self, 'show_install_info') |
|
2208 self.showInstallInfoAct.setStatusTip(self.tr( |
|
2209 'Show Installation Information')) |
|
2210 self.showInstallInfoAct.setWhatsThis(self.tr( |
|
2211 """<b>Show Install Info...</b>""" |
|
2212 """<p>Opens a dialog showing some information about the""" |
|
2213 """ installation process.</p>""" |
|
2214 )) |
|
2215 self.showInstallInfoAct.triggered.connect(self.__showInstallInfo) |
|
2216 self.actions.append(self.showInstallInfoAct) |
2105 |
2217 |
2106 self.reportBugAct = E5Action( |
2218 self.reportBugAct = E5Action( |
2107 self.tr('Report Bug'), |
2219 self.tr('Report Bug'), |
2108 self.tr('Report &Bug...'), |
2220 self.tr('Report &Bug...'), |
2109 0, 0, self, 'report_bug') |
2221 0, 0, self, 'report_bug') |
3131 self.__menus["help"].addAction(self.versionAct) |
3243 self.__menus["help"].addAction(self.versionAct) |
3132 self.__menus["help"].addSeparator() |
3244 self.__menus["help"].addSeparator() |
3133 self.__menus["help"].addAction(self.checkUpdateAct) |
3245 self.__menus["help"].addAction(self.checkUpdateAct) |
3134 self.__menus["help"].addAction(self.showVersionsAct) |
3246 self.__menus["help"].addAction(self.showVersionsAct) |
3135 self.__menus["help"].addSeparator() |
3247 self.__menus["help"].addSeparator() |
|
3248 self.__menus["help"].addAction(self.showInstallInfoAct) |
|
3249 self.__menus["help"].addSeparator() |
3136 self.__menus["help"].addAction(self.showErrorLogAct) |
3250 self.__menus["help"].addAction(self.showErrorLogAct) |
3137 self.__menus["help"].addAction(self.reportBugAct) |
3251 self.__menus["help"].addAction(self.reportBugAct) |
3138 self.__menus["help"].addAction(self.requestFeatureAct) |
3252 self.__menus["help"].addAction(self.requestFeatureAct) |
3139 self.__menus["help"].addSeparator() |
3253 self.__menus["help"].addSeparator() |
3140 self.__menus["help"].addAction(self.whatsThisAct) |
3254 self.__menus["help"].addAction(self.whatsThisAct) |
3728 self.ErrorLogFileName) |
3845 self.ErrorLogFileName) |
3729 if os.path.exists(logFile): |
3846 if os.path.exists(logFile): |
3730 from .ErrorLogDialog import ErrorLogDialog |
3847 from .ErrorLogDialog import ErrorLogDialog |
3731 dlg = ErrorLogDialog(logFile, True, self) |
3848 dlg = ErrorLogDialog(logFile, True, self) |
3732 dlg.show() |
3849 dlg.show() |
3733 |
3850 |
|
3851 def __showInstallInfo(self): |
|
3852 """ |
|
3853 Private slot to show a dialog containing information about the |
|
3854 installation process. |
|
3855 """ |
|
3856 from .InstallInfoDialog import InstallInfoDialog |
|
3857 dlg = InstallInfoDialog(self) |
|
3858 if dlg.wasLoaded(): |
|
3859 dlg.exec() |
|
3860 |
3734 def __compareFiles(self): |
3861 def __compareFiles(self): |
3735 """ |
3862 """ |
3736 Private slot to handle the Compare Files dialog. |
3863 Private slot to handle the Compare Files dialog. |
3737 """ |
3864 """ |
3738 aw = self.viewmanager.activeWindow() |
3865 aw = self.viewmanager.activeWindow() |