# HG changeset patch # User ymh # Date 1371284914 -7200 # Node ID 4a14963334f495127b5da72f93001bc2e340a9e3 # Parent 4095911a78307164d4fe2c2dcd58507cb4840c8a add sync files diff -r 4095911a7830 -r 4a14963334f4 .hgignore --- a/.hgignore Sat Jun 15 01:33:28 2013 +0200 +++ b/.hgignore Sat Jun 15 10:28:34 2013 +0200 @@ -3,4 +3,6 @@ ^src/jocondelab/config\.py$ ^virtualenv/web/env/ ^run/ -^web/ \ No newline at end of file +^web/ +syntax: regexp +^sbin/sync/config\.py$ \ No newline at end of file diff -r 4095911a7830 -r 4a14963334f4 sbin/sync/config.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sbin/sync/config.py.tmpl Sat Jun 15 10:28:34 2013 +0200 @@ -0,0 +1,62 @@ +from fabric.api import env +from random import choice + +env.hosts = ['iri@web.iri.centrepompidou.fr'] + +env.web_group = 'www-data' +env.folders = ['../run/log', 'static/media'] + +env.repos = {'web' : {'repo':"/Users/ymh/dev/workspace/jocondelab", 'src_root':'src'}} +env.base_export_path = "~/tmp" +env.export_prefix = "jocondelab" + +env.remote_path = { + 'web':"/iridata/www/ldt/", + 'src':"/Users/ymh/dev/tmp/testfab/src", + 'virtualenv':"/iridata/virtualenv/ldt", + 'build_export':"/iridata/users/iri/tmp/build", + 'venv_export':"/iridata/users/iri/tmp/venv", +} + +env.platform_web_module = "jocondelab" +env.remote_baseline_venv = "/iridata/virtualenv/baseline2.7" + +env.rsync_filters = { + 'src' : [ + "P .htpasswd", + "P .htaccess", + "P jocondelab/config.py", + ], + 'web': [ + "+ core", + "P .htpasswd", + "P .htaccess", + "P robots.txt", + "P env/***", + "P log/***", + "P index/***", + "P static/media/***", + "P crossdomain.xml", + ], + 'venv': [ + "+ core", + ] +} +env.web_relaunch_cmd = "supervisorctl restart jocondelab" + + +env.config = { + 'web': { + 'base_url': "/", + 'web_url': 'http://labs.iri-resesarch.org/jocondelab', + 'db_engine':'postgresql_psycopg2', + 'db_name':'jocondelab', + 'db_user': 'iriuser', + 'db_password': '', + 'db_host': 'sql.iri.centrepompidou.fr', + 'db_port': 5432, + 'log_file' : env.remote_path['web'] + '/log/log.txt', + 'secret_key' : ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]), + }, +} + diff -r 4095911a7830 -r 4a14963334f4 sbin/sync/fabfile.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sbin/sync/fabfile.py Sat Jun 15 10:28:34 2013 +0200 @@ -0,0 +1,60 @@ +from fabric.api import task, env, sudo + +from fablib import (export_version, do_sync_web, create_config, + clean_export_folder, sync_install_build, do_create_virtualenv, + clean_rsync_folder, rsync_export, do_relaunch_server) +from fabric.colors import green +import imp +import os.path +import config + +@task +def relaunch_server(do_collectstatic=True, do_syncdb=True): + print("Relaunch server") + do_relaunch_server(do_collectstatic, do_syncdb) + +@task +def sync_web(version): + print(green("sync web with version %s" % version)) + export_path = export_version(web=version) + export_path_full = os.path.join(export_path,'web') + do_sync_web(version, export_path_full) + create_config(export_path_full) + clean_export_folder(export_path) + relaunch_server() + +@task +def update_lib(version, package): + print(green("update %s with version %s" % (package,version))) + export_path = export_version(web=version) + export_path_full = os.path.join(export_path,'web') + lib_path = os.path.join(export_path_full, "virtualenv", "res", "lib") + + f, pathname, description = imp.find_module("patch", [lib_path]) + imp.load_module("patch", f, pathname, description) + f, pathname, description = imp.find_module("lib_create_env", [lib_path]) + lib_create_env = imp.load_module("lib_create_env", f, pathname, description) + + package_path_full = os.path.join(export_path_full, "virtualenv", "res", "src", lib_create_env.URLS[package]['local']) + + sync_install_build(package_path_full) + clean_export_folder(export_path) + relaunch_server() + + +@task +def create_virtualenv(version): + print(green("create virtualenv with version %s" % version)) + export_path = export_version(web=version) + export_path_web = os.path.join(export_path,'web') + venv_remote_export_path = "" + try: + virtualenv_path = os.path.join(export_path_web, "virtualenv") + + venv_remote_export_path = os.path.join(env.remote_path['venv_export'], env.export_prefix, version,"virtualenv") + rsync_export(virtualenv_path, venv_remote_export_path, env.rsync_filters['venv']) + do_create_virtualenv(venv_remote_export_path, env.remote_path['virtualenv']) + finally: + clean_export_folder(export_path) + if venv_remote_export_path: + clean_rsync_folder(venv_remote_export_path)