scripts/install.py

changeset 8243
cc717c2ae956
parent 8240
93b8a353c4bf
child 8254
259484b0fc75
--- a/scripts/install.py	Thu Apr 15 16:52:05 2021 +0200
+++ b/scripts/install.py	Thu Apr 15 18:11:24 2021 +0200
@@ -100,10 +100,8 @@
     print()
     
     if sys.platform.startswith(("win", "cygwin")):
-        try:
+        with contextlib.suppress():
             input("Press enter to continue...")             # secok
-        except (EOFError, SyntaxError):
-            pass
     
     os.chdir(currDir)
     
@@ -558,7 +556,7 @@
                 os.remove(name)
         
         # Cleanup API files
-        try:
+        with contextlib.suppress(AttributeError):
             apidir = getConfig('apidir')
             for progLanguage in progLanguages:
                 for name in getConfig('apis'):
@@ -569,8 +567,6 @@
                         os.path.join(apidir, progLanguage.lower(), "*.bas")):
                     if os.path.basename(apiname) != "eric6.bas":
                         os.remove(apiname)
-        except AttributeError:
-            pass
         
         if sys.platform == "darwin":
             # delete the Mac app bundle
@@ -1449,7 +1445,7 @@
         from PyQt5.QtCore import qVersion
     except ImportError as msg:
         installed = not isSudo and pipInstall(
-            "PyQt5>=5.12.1,<5.15.2",
+            "PyQt5>=5.12.1",
             "'PyQt5' could not be detected.\nError: {0}".format(msg)
         )
         if installed:
@@ -1485,7 +1481,7 @@
                 print("Optional 'PyQtWebEngine' could not be detected.")
             else:
                 pipInstall(
-                    "PyQtWebEngine>=5.12.1,<5.15.2",
+                    "PyQtWebEngine>=5.12.1",
                     "Optional 'PyQtWebEngine' could not be detected.\n"
                     "Error: {0}".format(msg)
                 )
@@ -1497,7 +1493,7 @@
             print("Optional 'PyQtChart' could not be detected.")
         else:
             pipInstall(
-                "PyQtChart>=5.12.1,<5.15.2",
+                "PyQtChart>=5.12.1",
                 "Optional 'PyQtChart' could not be detected.\n"
                 "Error: {0}".format(msg)
             )
@@ -1565,13 +1561,11 @@
             modulesOK = False
             for altModule in altModules:
                 name = altModule.split(".")[1]
-                try:
+                with contextlib.suppress(ImportError):
                     __import__(altModule)
                     print("Found", name)
                     modulesOK = True
                     break
-                except ImportError:
-                    pass
             if not modulesOK and not forcedOk:
                 altModulesOK = False
                 print('Sorry, please install {0}.'
@@ -1611,7 +1605,7 @@
         exit(2)
     
     # check version of sip
-    try:
+    with contextlib.suppress(ImportError, AttributeError):
         try:
             from PyQt5 import sip
         except ImportError:
@@ -1627,11 +1621,11 @@
             minor = int(minor)
             pat = int(pat)
             if (
-                major < 4 or
-                (major == 4 and minor < 14) or
-                (major == 4 and minor == 14 and pat < 2)
+                major < 5 or
+                (major == 5 and minor < 0) or
+                (major == 5 and minor == 0 and pat < 0)
             ):
-                print('Sorry, you must have sip 4.14.2 or higher or'
+                print('Sorry, you must have sip 5.0.0 or higher or'
                       ' a recent snapshot release.')
                 exit(3)
             # check for blacklisted versions
@@ -1642,8 +1636,6 @@
                         .format(vers))
                     print('Please install another version.')
                     exit(3)
-    except (ImportError, AttributeError):
-        pass
     
     # check version of PyQt
     from PyQt5.QtCore import PYQT_VERSION_STR
@@ -1702,15 +1694,12 @@
                 exit(5)
     
     # print version info for additional modules
-    try:
+    with contextlib.suppress(NameError, AttributeError):
         print("PyQtChart:", QtChart.PYQT_CHART_VERSION_STR)
-    except (NameError, AttributeError):
-        pass
-    try:
+    
+    with contextlib.suppress(ImportError, AttributeError):
         from PyQt5 import QtWebEngine
         print("PyQtWebEngine.", QtWebEngine.PYQT_WEBENGINE_VERSION_STR)
-    except (ImportError, AttributeError):
-        pass
     
     print("All dependencies ok.")
     print()
@@ -1807,16 +1796,13 @@
     from win32com.client import Dispatch
     from pywintypes import com_error
     
-    try:
+    with contextlib.suppress(com_error):
         shell = Dispatch('WScript.Shell')
         shortcut = shell.CreateShortCut(linkPath)
         shortcut.Targetpath = targetPath
         shortcut.WorkingDirectory = os.path.dirname(targetPath)
         shortcut.IconLocation = iconPath
         shortcut.save()
-    except com_error:
-        # maybe restrictions prohibited link creation
-        pass
 
 
 def windowsDesktopNames():
@@ -1990,15 +1976,13 @@
         createInstallConfig()
     
     # get rid of development config file, if it exists
-    try:
+    with contextlib.suppress(OSError):
         if installFromSource:
             os.rename(configName, configName + ".orig")
             configNameC = configName + 'c'
             if os.path.exists(configNameC):
                 os.remove(configNameC)
         os.remove(configName)
-    except OSError:
-        pass
     
     # cleanup old installation
     print("Cleaning up old installation ...")

eric ide

mercurial