# HG changeset patch # User cavaliet # Date 1346325219 -7200 # Node ID 71f05e757973d8ec1e92022bfb789440bb642644 # Parent 292b15799db26dcc3ae2ec7830024f2f41be0483# Parent 08f962473d45453bfea4ee6d47f7f5f592fb1e60 Merge with 08f962473d45453bfea4ee6d47f7f5f592fb1e60 diff -r 292b15799db2 -r 71f05e757973 sbin/sync/fabfile.py --- a/sbin/sync/fabfile.py Thu Aug 30 13:13:05 2012 +0200 +++ b/sbin/sync/fabfile.py Thu Aug 30 13:13:39 2012 +0200 @@ -22,13 +22,27 @@ def do_export_version(path, version): print("Export version %s"%str(version)) - - #hgui = ui.ui() - #repo = hg.repository(hgui, cmdutil.findrepo(os.getcwd())) - #commands.archive(hgui, repo, path, rev=str(version)) - + local("hg archive -r \'%s\' \"%s\"" % (str(version),path)) print("Export version %s done"%str(version)) + + +def get_remote_env(remotepath, remotevirtualenvpath, platform_web_module, settings_key): + activate_path = os.path.join(remotevirtualenvpath, "bin/activate") + res = "" + with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath): + tempfilepath = run("mktemp --tmpdir ldtplatform.XXXXXX") + with settings(warn_only=True): + run("echo \"import os\" > %s" % (tempfilepath)) + map(lambda str: run("echo \"%s\" >> %s" % (str, tempfilepath)), + ["os.environ.setdefault('DJANGO_SETTINGS_MODULE', '%s.settings')" % (platform_web_module), + "from django.conf import settings", + "print settings.%s" % (settings_key)]) + res = run("python < %s" % (tempfilepath)) + run("rm -f \"%s\"" % (tempfilepath)) + return res + + def rsync_export(path, remotepath, filters): print("Rsync %s to %s",(path,remotepath)) @@ -98,11 +112,14 @@ with prefix("source %s" % activate_path): run("pip install \"%s\"" % remotepath) -def collectstatic(remotepath, remotevirtualenvpath): +def collectstatic(remotepath, remotevirtualenvpath, platform_web_module): print("Collect static in %s with %s" % (remotepath, remotevirtualenvpath)) + remotestaticsitepath = get_remote_env(remotepath, remotevirtualenvpath, platform_web_module, "STATIC_ROOT") 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 -c --noinput") + #remocve old files optio -c of collect static fail ! + run("rm -fr \"%s\"" % (remotestaticsitepath)) + run("python manage.py collectstatic --noinput") def create_config(export_path): print("Create config from %s" % (export_path,)) @@ -197,10 +214,11 @@ run("mkdir -p \"%s\"" % folder_path) run("chown -R -c :%s \"%s\"" % (env.web_group, folder_path)) run("chmod -R -c g+w \"%s\"" % folder_path) - -def relaunch_server(): +@task +def relaunch_server(do_collectstatic=True): print("Relaunch server") - collectstatic(env.remote_web_path, env.remote_virtualenv_path) + if do_collectstatic: + collectstatic(env.remote_web_path, env.remote_virtualenv_path, env.platform_web_module) check_folder_access() sudo(env.web_relaunch_cmd, shell=False)