# HG changeset patch # User ymh # Date 1340390672 -7200 # Node ID bb39eafd5293ee87047e0c80eb2f107a5beb7822 # Parent 42393fa72f0e3d3d8f4b569e3198f00cd61ef403 correction on sync fab files diff -r 42393fa72f0e -r bb39eafd5293 sbin/sync/config.py.tmpl --- a/sbin/sync/config.py.tmpl Thu Jun 14 10:49:33 2012 +0200 +++ b/sbin/sync/config.py.tmpl Fri Jun 22 20:44:32 2012 +0200 @@ -1,6 +1,10 @@ from fabric.api import env env.hosts = ['iri@web.iri.centrepompidou.fr'] + +env.web_group = 'www-data' +env.folders = ['index', 'log', 'static/media'] + env.base_export_path = "~/tmp" env.export_prefix = "platform" env.remote_web_path = "/iridata/www/ldt/" diff -r 42393fa72f0e -r bb39eafd5293 sbin/sync/fabfile.py --- 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()