hooks/post_gen_project.py
changeset 6 365da6d54a09
parent 2 01a55c704ea1
child 8 8ab3fffe8d36
--- a/hooks/post_gen_project.py	Tue Jun 27 13:21:59 2017 +0200
+++ b/hooks/post_gen_project.py	Fri Oct 06 09:15:58 2017 +0200
@@ -53,20 +53,24 @@
 
 VAR_DIRECTORY = os.path.join(TARGET, 'var')
 
-os.chown(VAR_DIRECTORY, user_id, group_id)
+try:
+    os.chown(VAR_DIRECTORY, user_id, group_id)
+except PermissionError:
+    print("WARNING: Can't set owner ({0}:{1}) for directory {2}".format(user_id, group_id, VAR_DIRECTORY))
+
 for root, dirs, files in os.walk(VAR_DIRECTORY):
     for dirname in dirs:
         try:
             target = os.path.join(VAR_DIRECTORY, root, dirname)
             os.chown(target, user_id, group_id)
         except PermissionError:
-            print("WARNING: Can't set permissions for directory {0}".format(target))
+            print("WARNING: Can't set owner ({0}:{1}) for directory {2}".format(user_id, group_id, target))
     for filename in files:
         try:
             target = os.path.join(VAR_DIRECTORY, root, filename)
             os.chown(target, user_id, group_id)
         except PermissionError:
-            print("WARNING: Can't set permissions for file {0}".format(target))
+            print("WARNING: Can't set owner ({0}:{1}) for file {2}".format(user_id, group_id, target))
 
 
 #
@@ -81,7 +85,7 @@
             target = os.path.join(BIN_DIRECTORY, root, filename)
             os.chmod(target, 0o775)
         except PermissionError:
-            print("WARNING: Can't set permissions for file {0}".format(target))
+            print("WARNING: Can't set permissions (0775) for file {0}".format(target))
 
 
 print("\nYour ZEO environment is initialized.")