sbin/sync/fabfile.py
changeset 86 bb39eafd5293
parent 82 cb842369c5ca
child 96 900b29a370ae
--- a/sbin/sync/fabfile.py	Thu Jun 14 10:49:33 2012 +0200
+++ b/sbin/sync/fabfile.py	Fri Jun 22 20:44:32 2012 +0200
@@ -2,6 +2,7 @@
 from fabric.colors import green
 from fabric.contrib.project import rsync_project
 from fabric.contrib.files import exists, upload_template
+from fabric.context_managers import settings 
 from mercurial import commands, ui, hg, cmdutil
 import imp
 import os, os.path
@@ -101,7 +102,7 @@
     print("Collect static in %s with %s" % (remotepath, remotevirtualenvpath))
     activate_path = os.path.join(remotevirtualenvpath, "bin/activate")
     with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath):
-        run("python manage.py collectstatic --noinput")
+        run("python manage.py collectstatic -c --noinput")
         
 def create_config(export_path):    
     print("Create config from %s" % (export_path,))
@@ -187,13 +188,26 @@
     print("Relaunch server")
     collectstatic(env.remote_web_path, env.remote_virtualenv_path)
     sudo(env.web_relaunch_cmd, shell=False)
+    
+def check_folder_access():
+    print("Check folder access")
+    # get remote user
+    for folder_path in env.folders:
+        if not os.path.isabs(folder_path):
+            folder_path = env.remote_web_path.rstrip("/")+ "/" + folder_path
+            with settings(warn_only=True):
+                if not exists(folder_path):
+                    run("mkdir -p \"%s\"" % folder_path)
+                run("chown -R -c :%s \"%s\"" % (env.web_group, folder_path))
+                run("chown -R -c g+w \"%s\"" % folder_path)
 
 @task
 def sync_web(version):
     print(green("sync web with version %s" % version))
     export_path = export_version(version)
     do_sync_web(version, export_path)
-    create_config(export_path)    
+    check_folder_access()
+    create_config(export_path)
     clean_export_folder(export_path)
     relaunch_server()
 
@@ -228,6 +242,8 @@
     export_path = export_version(version)
     do_sync_ldt(version, export_path)
     do_sync_web(version, export_path)
+    check_folder_access()
+    create_config(export_path)
     clean_export_folder(export_path)
     relaunch_server()