Improved the install script with respect to API files installation. eric7

Thu, 29 Sep 2022 11:18:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 29 Sep 2022 11:18:50 +0200
branch
eric7
changeset 9366
57980203d6f8
parent 9365
25f6183494e2
child 9367
4a8b3bf63579

Improved the install script with respect to API files installation.

scripts/install.py file | annotate | diff | comparison | revisions
--- a/scripts/install.py	Wed Sep 28 16:15:56 2022 +0200
+++ b/scripts/install.py	Thu Sep 29 11:18:50 2022 +0200
@@ -920,29 +920,23 @@
 
     # install the API file
     if installApis:
-        for progLanguage in progLanguages:
-            apidir = os.path.join(cfg["apidir"], progLanguage)
-            print("Installing {0} API files to '{1}'.".format(progLanguage, apidir))
-            try:
+        if os.access(cfg["apidir"], os.W_OK):
+            for progLanguage in progLanguages:
+                apidir = os.path.join(cfg["apidir"], progLanguage)
+                print("Installing {0} API files to '{1}'.".format(progLanguage, apidir))
                 if not os.path.exists(apidir):
                     os.makedirs(apidir)
-            except OSError:
-                print("Could not create '{0}' (no permission).".format(apidir))
-                continue
-            for apiName in glob.glob(
-                os.path.join(eric7SourceDir, "APIs", progLanguage, "*.api")
-            ):
-                try:
+                for apiName in glob.glob(
+                    os.path.join(eric7SourceDir, "APIs", progLanguage, "*.api")
+                ):
                     shutilCopy(apiName, apidir)
-                except OSError:
-                    print("Could not install '{0}' (no permission).".format(apiName))
-            for apiName in glob.glob(
-                os.path.join(eric7SourceDir, "APIs", progLanguage, "*.bas")
-            ):
-                try:
+                for apiName in glob.glob(
+                    os.path.join(eric7SourceDir, "APIs", progLanguage, "*.bas")
+                ):
                     shutilCopy(apiName, apidir)
-                except OSError:
-                    print("Could not install '{0}' (no permission).".format(apiName))
+        else:
+            print("The API directory '{0}' is not writable.".format(cfg["apidir"]))
+            print("Use the API files provided by the 'API Files' plug-in.")
 
     # Create menu entry for Linux systems
     if sys.platform.startswith("linux"):

eric ide

mercurial