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