Fine tuned the upgrader behavior and introduced a configurable delay to give eric sufficient time to exit before doing the upgrade. eric7

Tue, 22 Mar 2022 19:28:43 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 22 Mar 2022 19:28:43 +0100
branch
eric7
changeset 8994
3bebd76dc6ea
parent 8993
d91e674d200c
child 8995
52c50ac1002a

Fine tuned the upgrader behavior and introduced a configurable delay to give eric sufficient time to exit before doing the upgrade.

eric7/Preferences/ConfigurationPages/ApplicationPage.py file | annotate | diff | comparison | revisions
eric7/Preferences/ConfigurationPages/ApplicationPage.ui file | annotate | diff | comparison | revisions
eric7/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric7/UI/UserInterface.py file | annotate | diff | comparison | revisions
eric7/UI/upgrader.py file | annotate | diff | comparison | revisions
--- a/eric7/Preferences/ConfigurationPages/ApplicationPage.py	Sun Mar 20 17:59:49 2022 +0100
+++ b/eric7/Preferences/ConfigurationPages/ApplicationPage.py	Tue Mar 22 19:28:43 2022 +0100
@@ -91,6 +91,9 @@
         
         self.backgroundServicesSpinBox.setValue(
             Preferences.getUI("BackgroundServiceProcesses"))
+        
+        self.upgraderDelaySpinBox.setValue(
+            Preferences.getUI("UpgraderDelay"))
     
     def save(self):
         """
@@ -154,6 +157,10 @@
         Preferences.setUI(
             "BackgroundServiceProcesses",
             self.backgroundServicesSpinBox.value())
+        
+        Preferences.setUI(
+            "UpgraderDelay",
+            self.upgraderDelaySpinBox.value())
 
 
 def create(dlg):
--- a/eric7/Preferences/ConfigurationPages/ApplicationPage.ui	Sun Mar 20 17:59:49 2022 +0100
+++ b/eric7/Preferences/ConfigurationPages/ApplicationPage.ui	Tue Mar 22 19:28:43 2022 +0100
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>589</width>
-    <height>610</height>
+    <height>748</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_4">
@@ -203,6 +203,54 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="groupBox_7">
+     <property name="title">
+      <string>Upgrader</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_3">
+      <item>
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>Upgrader Delay:</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QSpinBox" name="upgraderDelaySpinBox">
+        <property name="toolTip">
+         <string>Enter the time the upgrader process should wait for eric to exit</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+        <property name="suffix">
+         <string> s</string>
+        </property>
+        <property name="minimum">
+         <number>1</number>
+        </property>
+        <property name="maximum">
+         <number>30</number>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <spacer name="horizontalSpacer_3">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>411</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <widget class="QGroupBox" name="groupBox_4">
      <property name="title">
       <string>Reporting</string>
@@ -392,6 +440,7 @@
   <tabstop>dailyCheckRadioButton</tabstop>
   <tabstop>weeklyCheckRadioButton</tabstop>
   <tabstop>monthlyCheckRadioButton</tabstop>
+  <tabstop>upgraderDelaySpinBox</tabstop>
   <tabstop>systemEmailClientCheckBox</tabstop>
   <tabstop>errorlogCheckBox</tabstop>
   <tabstop>msgSeverityComboBox</tabstop>
--- a/eric7/Preferences/__init__.py	Sun Mar 20 17:59:49 2022 +0100
+++ b/eric7/Preferences/__init__.py	Tue Mar 22 19:28:43 2022 +0100
@@ -219,6 +219,7 @@
                                    # 4 = last global session
         "OpenCrashSessionOnStartup": True,
         "CrashSessionEnabled": True,
+        "UpgraderDelay": 5,
         
         "DownloadPath": "",
         "RequestDownloadFilename": True,
@@ -1951,7 +1952,7 @@
     elif key in ["TabViewManagerFilenameLength", "CaptionFilenameLength",
                  "ProxyPort/Http", "ProxyPort/Https", "ProxyPort/Ftp",
                  "OpenOnStartup", "PerformVersionCheck", "RecentNumber",
-                 "NotificationTimeout",
+                 "NotificationTimeout", "UpgraderDelay",
                  "KeyboardInputInterval", "BackgroundServiceProcesses",
                  "MinimumMessageTypeSeverity"]:
         return int(Prefs.settings.value(
--- a/eric7/UI/UserInterface.py	Sun Mar 20 17:59:49 2022 +0100
+++ b/eric7/UI/UserInterface.py	Tue Mar 22 19:28:43 2022 +0100
@@ -4497,7 +4497,12 @@
         upgrader = os.path.join(
             os.path.dirname(__file__), "upgrader.py"
         )
-        upgraderArgs = [upgrader, "--" + upgradeType, "--"] + ericStartArgs
+        upgraderArgs = [
+            upgrader,
+            "--type={0}".format(upgradeType),
+            "--delay={0}".format(Preferences.getUI("UpgraderDelay")),
+            "--"
+        ] + ericStartArgs
         QProcess.startDetached(program, upgraderArgs)
     
     def __newWindow(self):
--- a/eric7/UI/upgrader.py	Sun Mar 20 17:59:49 2022 +0100
+++ b/eric7/UI/upgrader.py	Tue Mar 22 19:28:43 2022 +0100
@@ -11,6 +11,7 @@
 the requested packages and will restart eric.
 """
 
+import contextlib
 import subprocess
 import sys
 import time
@@ -57,9 +58,6 @@
     """
     Main entry point into the upgrader.
     """
-    # wait a few seconds to give eric the chance to fully shut down
-    time.sleep(2)
-    
     try:
         ddindex = sys.argv.index("--")
     except ValueError:
@@ -73,12 +71,25 @@
     
     upgraderArgs = sys.argv[1:ddindex]
     
+    upgradeType = ""
+    upgradeDelay = 2
+    
+    for arg in upgraderArgs:
+        if arg.startswith("--delay="):
+            with contextlib.suppress(ValueError):
+                upgradeDelay = int(arg.split("=")[1].strip())
+        elif arg.startswith("--type="):
+            upgradeType=arg.split("=")[1].strip()
+    
+    # wait a few seconds to give eric the chance to fully shut down
+    time.sleep(upgradeDelay)
+    
     # now perform the upgrade and start eric, if it was successful
-    if upgraderArgs[0] == "--pyqt":
+    if upgradeType == "pyqt":
         ok = doUpgrade(_pyqtPackages)
-    elif upgraderArgs[0] == "--eric":
+    elif upgradeType == "eric":
         ok = doUpgrade(_ericPackages)
-    elif upgraderArgs[0] == "--ericpyqt":
+    elif upgradeType == "ericpyqt":
         ok = doUpgrade(_ericPackages + _pyqtPackages)
     else:
         ok = False

eric ide

mercurial