Improved the install script to create some more non-existing directories and deal with permission errors. eric7

Fri, 23 Sep 2022 11:47:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 23 Sep 2022 11:47:42 +0200
branch
eric7
changeset 9347
da982d5b0718
parent 9346
eda0bdb22e67
child 9349
df34d520c63b

Improved the install script to create some more non-existing directories and deal with permission errors.

scripts/install.py file | annotate | diff | comparison | revisions
--- a/scripts/install.py	Fri Sep 23 10:58:55 2022 +0200
+++ b/scripts/install.py	Fri Sep 23 11:47:42 2022 +0200
@@ -264,6 +264,9 @@
     text = text.replace("@MARKER@", "")
     text = text.replace("@PY_MARKER@", "")
 
+    dstPath = os.path.dirname(dst)
+    if not os.path.isdir(dstPath):
+        os.makedirs(dstPath)
     with open(dst, "w", encoding="utf-8") as f:
         f.write(text)
     os.chmod(dst, 0o644)
@@ -294,6 +297,9 @@
         .replace("@DATE@", time.strftime("%Y-%m-%d"))
     )
 
+    dstPath = os.path.dirname(dst)
+    if not os.path.isdir(dstPath):
+        os.makedirs(dstPath)
     with open(dst, "w", encoding="utf-8") as f:
         f.write(text)
     os.chmod(dst, 0o644)
@@ -906,8 +912,12 @@
         for progLanguage in progLanguages:
             apidir = os.path.join(cfg["apidir"], progLanguage.lower())
             print("Installing {0} API files to '{1}'.".format(progLanguage, apidir))
-            if not os.path.exists(apidir):
-                os.makedirs(apidir)
+            try:
+                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")
             ):

eric ide

mercurial