63 from E5Network.E5SslErrorHandler import E5SslErrorHandler, E5SslErrorState |
63 from E5Network.E5SslErrorHandler import E5SslErrorHandler, E5SslErrorState |
64 SSL_AVAILABLE = True |
64 SSL_AVAILABLE = True |
65 except ImportError: |
65 except ImportError: |
66 SSL_AVAILABLE = False |
66 SSL_AVAILABLE = False |
67 |
67 |
68 from eric6config import getConfig |
68 from eric7config import getConfig |
69 |
69 |
70 |
70 |
71 class Redirector(QObject): |
71 class Redirector(QObject): |
72 """ |
72 """ |
73 Helper class used to redirect stdout and stderr to the log window. |
73 Helper class used to redirect stdout and stderr to the log window. |
155 |
155 |
156 LeftSide = 1 |
156 LeftSide = 1 |
157 BottomSide = 2 |
157 BottomSide = 2 |
158 RightSide = 3 |
158 RightSide = 3 |
159 |
159 |
160 ErrorLogFileName = "eric6_error.log" |
160 ErrorLogFileName = "eric7_error.log" |
161 |
161 |
162 def __init__(self, app, locale, splash, plugin, disabledPlugins, |
162 def __init__(self, app, locale, splash, plugin, disabledPlugins, |
163 noOpenAtStartup, noCrashOpenAtStartup, disableCrashSession, |
163 noOpenAtStartup, noCrashOpenAtStartup, disableCrashSession, |
164 restartArguments, originalPathString): |
164 restartArguments, originalPathString): |
165 """ |
165 """ |
1468 """ |
1468 """ |
1469 import Globals |
1469 import Globals |
1470 |
1470 |
1471 installInfoFile = Globals.getInstallInfoFilePath() |
1471 installInfoFile = Globals.getInstallInfoFilePath() |
1472 if not os.path.exists(installInfoFile): |
1472 if not os.path.exists(installInfoFile): |
1473 filename = os.path.join(getConfig("ericDir"), "eric6install.json") |
1473 filename = os.path.join(getConfig("ericDir"), "eric7install.json") |
1474 if os.path.exists(filename): |
1474 if os.path.exists(filename): |
1475 # eric was installed via the install.py script |
1475 # eric was installed via the install.py script |
1476 shutil.copy2(filename, installInfoFile) |
1476 shutil.copy2(filename, installInfoFile) |
1477 else: |
1477 else: |
1478 filename = os.path.join(getConfig("ericDir"), |
1478 filename = os.path.join(getConfig("ericDir"), |
1479 "eric6installpip.json") |
1479 "eric7installpip.json") |
1480 if os.path.exists(filename): |
1480 if os.path.exists(filename): |
1481 # eric was installed via pip (i.e. eric-ide) |
1481 # eric was installed via pip (i.e. eric-ide) |
1482 with contextlib.suppress(OSError): |
1482 with contextlib.suppress(OSError): |
1483 installDateTime = datetime.datetime.now(tz=None) |
1483 installDateTime = datetime.datetime.now(tz=None) |
1484 with open(filename, "r") as infoFile: |
1484 with open(filename, "r") as infoFile: |
1512 if "installed_on" not in installInfo: |
1512 if "installed_on" not in installInfo: |
1513 installInfo["installed_on"] = "" |
1513 installInfo["installed_on"] = "" |
1514 changed = True |
1514 changed = True |
1515 |
1515 |
1516 # 2. merge new data into stored file |
1516 # 2. merge new data into stored file |
1517 filename = os.path.join(getConfig("ericDir"), "eric6install.json") |
1517 filename = os.path.join(getConfig("ericDir"), "eric7install.json") |
1518 if os.path.exists(filename): |
1518 if os.path.exists(filename): |
1519 # eric was updated via the install.py script |
1519 # eric was updated via the install.py script |
1520 if ( |
1520 if ( |
1521 os.path.getmtime(filename) > |
1521 os.path.getmtime(filename) > |
1522 os.path.getmtime(installInfoFile) |
1522 os.path.getmtime(installInfoFile) |
1537 installInfo2["eric"] = installInfo["eric"] |
1537 installInfo2["eric"] = installInfo["eric"] |
1538 installInfo = installInfo2 |
1538 installInfo = installInfo2 |
1539 changed = True |
1539 changed = True |
1540 else: |
1540 else: |
1541 filename = os.path.join(getConfig("ericDir"), |
1541 filename = os.path.join(getConfig("ericDir"), |
1542 "eric6installpip.json") |
1542 "eric7installpip.json") |
1543 if os.path.exists(filename): |
1543 if os.path.exists(filename): |
1544 # eric was updated via pip (i.e. eric-ide) |
1544 # eric was updated via pip (i.e. eric-ide) |
1545 # just update the installation date and time |
1545 # just update the installation date and time |
1546 installDateTime = datetime.datetime.now(tz=None) |
1546 installDateTime = datetime.datetime.now(tz=None) |
1547 installInfo["installed_on"] = installDateTime.strftime( |
1547 installInfo["installed_on"] = installDateTime.strftime( |
4135 ) |
4135 ) |
4136 |
4136 |
4137 if res and self.__shutdown(): |
4137 if res and self.__shutdown(): |
4138 e5App().closeAllWindows() |
4138 e5App().closeAllWindows() |
4139 program = sys.executable |
4139 program = sys.executable |
4140 eric6 = os.path.join(getConfig("ericDir"), "eric6.py") |
4140 eric7 = os.path.join(getConfig("ericDir"), "eric7.py") |
4141 args = [eric6] |
4141 args = [eric7] |
4142 args.append("--start-session") |
4142 args.append("--start-session") |
4143 args.extend(self.__restartArgs) |
4143 args.extend(self.__restartArgs) |
4144 QProcess.startDetached(program, args) |
4144 QProcess.startDetached(program, args) |
4145 |
4145 |
4146 def __newWindow(self): |
4146 def __newWindow(self): |
4148 Private slot to start a new instance of eric. |
4148 Private slot to start a new instance of eric. |
4149 """ |
4149 """ |
4150 if not Preferences.getUI("SingleApplicationMode"): |
4150 if not Preferences.getUI("SingleApplicationMode"): |
4151 # start eric without any arguments |
4151 # start eric without any arguments |
4152 program = sys.executable |
4152 program = sys.executable |
4153 eric6 = os.path.join(getConfig("ericDir"), "eric6.py") |
4153 eric7 = os.path.join(getConfig("ericDir"), "eric7.py") |
4154 args = [eric6] |
4154 args = [eric7] |
4155 QProcess.startDetached(program, args) |
4155 QProcess.startDetached(program, args) |
4156 |
4156 |
4157 def __initToolsMenus(self, menu): |
4157 def __initToolsMenus(self, menu): |
4158 """ |
4158 """ |
4159 Private slot to initialize the various tool menus. |
4159 Private slot to initialize the various tool menus. |
5967 clientArgs.append("--search={0}".format(searchWord)) |
5967 clientArgs.append("--search={0}".format(searchWord)) |
5968 |
5968 |
5969 if self.__webBrowserProcess is None: |
5969 if self.__webBrowserProcess is None: |
5970 webBrowsers = [ |
5970 webBrowsers = [ |
5971 os.path.join( |
5971 os.path.join( |
5972 os.path.dirname(__file__), "..", "eric6_browser.py"), |
5972 os.path.dirname(__file__), "..", "eric7_browser.py"), |
5973 # QtWebEngine based web browser |
5973 # QtWebEngine based web browser |
5974 ] |
5974 ] |
5975 process = QProcess() |
5975 process = QProcess() |
5976 for browser in webBrowsers: |
5976 for browser in webBrowsers: |
5977 args = [ |
5977 args = [ |
6500 |
6500 |
6501 def __writeTasks(self): |
6501 def __writeTasks(self): |
6502 """ |
6502 """ |
6503 Private slot to write the tasks data to a JSON file (.etj). |
6503 Private slot to write the tasks data to a JSON file (.etj). |
6504 """ |
6504 """ |
6505 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.etj") |
6505 fn = os.path.join(Utilities.getConfigDir(), "eric7tasks.etj") |
6506 self.__tasksFile.writeFile(fn) |
6506 self.__tasksFile.writeFile(fn) |
6507 |
6507 |
6508 def __readTasks(self): |
6508 def __readTasks(self): |
6509 """ |
6509 """ |
6510 Private slot to read in the tasks file (.etj or .e6t). |
6510 Private slot to read in the tasks file (.etj or .e6t). |
6511 """ |
6511 """ |
6512 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.etj") |
6512 fn = os.path.join(Utilities.getConfigDir(), "eric7tasks.etj") |
6513 if os.path.exists(fn): |
6513 if os.path.exists(fn): |
6514 # try new style JSON file first |
6514 # try new style JSON file first |
6515 self.__tasksFile.readFile(fn) |
6515 self.__tasksFile.readFile(fn) |
6516 else: |
6516 else: |
6517 # try old style XML file second |
6517 # try old style XML file second |
6518 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e6t") |
6518 fn = os.path.join(Utilities.getConfigDir(), "eric7tasks.e6t") |
6519 if os.path.exists(fn): |
6519 if os.path.exists(fn): |
6520 f = QFile(fn) |
6520 f = QFile(fn) |
6521 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
6521 if f.open(QIODevice.OpenModeFlag.ReadOnly): |
6522 from E5XML.TasksReader import TasksReader |
6522 from E5XML.TasksReader import TasksReader |
6523 reader = TasksReader(f, viewer=self.taskViewer) |
6523 reader = TasksReader(f, viewer=self.taskViewer) |
6545 """ |
6545 """ |
6546 if filename: |
6546 if filename: |
6547 fn = filename |
6547 fn = filename |
6548 elif crashSession: |
6548 elif crashSession: |
6549 fn = os.path.join(Utilities.getConfigDir(), |
6549 fn = os.path.join(Utilities.getConfigDir(), |
6550 "eric6_crash_session.esj") |
6550 "eric7_crash_session.esj") |
6551 else: |
6551 else: |
6552 fn = os.path.join(Utilities.getConfigDir(), |
6552 fn = os.path.join(Utilities.getConfigDir(), |
6553 "eric6session.esj") |
6553 "eric7session.esj") |
6554 |
6554 |
6555 if fn.endswith(".esj"): |
6555 if fn.endswith(".esj"): |
6556 res = self.__sessionFile.writeFile(fn) |
6556 res = self.__sessionFile.writeFile(fn) |
6557 else: |
6557 else: |
6558 f = QFile(fn) |
6558 f = QFile(fn) |
6583 """ |
6583 """ |
6584 if filename: |
6584 if filename: |
6585 fn = filename |
6585 fn = filename |
6586 else: |
6586 else: |
6587 fn = os.path.join(Utilities.getConfigDir(), |
6587 fn = os.path.join(Utilities.getConfigDir(), |
6588 "eric6session.esj") |
6588 "eric7session.esj") |
6589 if not os.path.exists(fn): |
6589 if not os.path.exists(fn): |
6590 fn = os.path.join(Utilities.getConfigDir(), |
6590 fn = os.path.join(Utilities.getConfigDir(), |
6591 "eric6session.e5s") |
6591 "eric7session.e5s") |
6592 if not os.path.exists(fn): |
6592 if not os.path.exists(fn): |
6593 E5MessageBox.critical( |
6593 E5MessageBox.critical( |
6594 self, |
6594 self, |
6595 self.tr("Read Session"), |
6595 self.tr("Read Session"), |
6596 self.tr("<p>The session file <b>{0}</b> could not" |
6596 self.tr("<p>The session file <b>{0}</b> could not" |
6672 """ |
6672 """ |
6673 Private slot to delete the crash session file. |
6673 Private slot to delete the crash session file. |
6674 """ |
6674 """ |
6675 for ext in (".esj", ".e5s"): |
6675 for ext in (".esj", ".e5s"): |
6676 fn = os.path.join(Utilities.getConfigDir(), |
6676 fn = os.path.join(Utilities.getConfigDir(), |
6677 f"eric6_crash_session{ext}") |
6677 f"eric7_crash_session{ext}") |
6678 if os.path.exists(fn): |
6678 if os.path.exists(fn): |
6679 with contextlib.suppress(OSError): |
6679 with contextlib.suppress(OSError): |
6680 os.remove(fn) |
6680 os.remove(fn) |
6681 |
6681 |
6682 def __writeCrashSession(self): |
6682 def __writeCrashSession(self): |
6702 not self.__disableCrashSession and |
6702 not self.__disableCrashSession and |
6703 not self.__noCrashOpenAtStartup and |
6703 not self.__noCrashOpenAtStartup and |
6704 Preferences.getUI("OpenCrashSessionOnStartup") |
6704 Preferences.getUI("OpenCrashSessionOnStartup") |
6705 ): |
6705 ): |
6706 fn = os.path.join(Utilities.getConfigDir(), |
6706 fn = os.path.join(Utilities.getConfigDir(), |
6707 "eric6_crash_session.esj") |
6707 "eric7_crash_session.esj") |
6708 if os.path.exists(fn): |
6708 if os.path.exists(fn): |
6709 yes = E5MessageBox.yesNo( |
6709 yes = E5MessageBox.yesNo( |
6710 self, |
6710 self, |
6711 self.tr("Crash Session found!"), |
6711 self.tr("Crash Session found!"), |
6712 self.tr("""A session file of a crashed session was""" |
6712 self.tr("""A session file of a crashed session was""" |