sbin/sync/fabfile.py
changeset 52 eea37d86feea
child 54 e7a2e615eced
equal deleted inserted replaced
51:d842aad55f81 52:eea37d86feea
       
     1 from fablib import (export_version, do_sync_web, create_config, 
       
     2     clean_export_folder, sync_install_build, do_create_virtualenv, 
       
     3     clean_rsync_folder, rsync_export, do_relaunch_server)
       
     4 from fabric.api import task, env, sudo
       
     5 from fabric.colors import green
       
     6 import imp
       
     7 import os.path
       
     8 
       
     9 @task
       
    10 def relaunch_server(do_collectstatic=True, do_syncdb=True):
       
    11     print("Relaunch server")
       
    12     do_relaunch_server(do_collectstatic, do_syncdb)
       
    13 
       
    14 @task
       
    15 def sync_web(version):
       
    16     print(green("sync web with version %s" % version))
       
    17     export_path = export_version(web=version)
       
    18     export_path_full = os.path.join(export_path,'web')
       
    19     do_sync_web(version, export_path_full)
       
    20     create_config(export_path_full)
       
    21     clean_export_folder(export_path)
       
    22     relaunch_server()
       
    23     
       
    24 @task
       
    25 def update_lib(version, package):
       
    26     print(green("update ldt with version %s" % version))
       
    27     export_path = export_version(web=version)
       
    28     export_path_full = os.path.join(export_path,'web')
       
    29     lib_path = os.path.join(export_path_full, "virtualenv", "res", "lib")
       
    30     
       
    31     f, pathname, description = imp.find_module("patch", [lib_path])
       
    32     imp.load_module("patch", f, pathname, description)
       
    33     f, pathname, description = imp.find_module("lib_create_env", [lib_path])
       
    34     lib_create_env = imp.load_module("lib_create_env", f, pathname, description)
       
    35     
       
    36     package_path_full = os.path.join(export_path_full, "virtualenv", "res", "src", lib_create_env.URLS[package]['local'])
       
    37     
       
    38     sync_install_build(package_path_full)
       
    39     clean_export_folder(export_path)
       
    40     relaunch_server()
       
    41     
       
    42 
       
    43 @task
       
    44 def create_virtualenv(version):
       
    45     print(green("create virtualenv with version %s" % version))
       
    46     export_path = export_version(web=version)
       
    47     export_path_web = os.path.join(export_path,'web')
       
    48     venv_remote_export_path = ""
       
    49     try:
       
    50         virtualenv_path = os.path.join(export_path_web, "virtualenv")
       
    51     
       
    52         venv_remote_export_path = os.path.join(env.remote_path['venv_export'], env.export_prefix, version,"virtualenv")
       
    53         rsync_export(virtualenv_path, venv_remote_export_path, env.rsync_filters['venv'])
       
    54         do_create_virtualenv(venv_remote_export_path, env.remote_path['virtualenv'])
       
    55     finally:
       
    56         clean_export_folder(export_path)
       
    57         if venv_remote_export_path:
       
    58             clean_rsync_folder(venv_remote_export_path)