sbin/sync/fabfile.py
changeset 17 f8c613e43ebd
parent 6 5514662f70af
child 27 4b8a549d6399
equal deleted inserted replaced
16:6118ebbcaaca 17:f8c613e43ebd
    11 
    11 
    12 import config
    12 import config
    13 
    13 
    14 def get_export_path(version):
    14 def get_export_path(version):
    15     base_path = os.path.join(env.base_export_path,env.export_prefix).rstrip("/")
    15     base_path = os.path.join(env.base_export_path,env.export_prefix).rstrip("/")
    16     return os.path.expanduser(base_path) + "_%s/ldt" % (str(version))
    16     return os.path.expanduser(base_path) + "_%s" % (str(version))
    17 
    17 
    18 def clean_export_folder(path):
    18 def clean_export_folder(path):
    19     print("Removing %s" % path)
    19     print("Removing %s" % path)
    20     if os.path.isdir(path):
    20     if os.path.isdir(path):
    21         shutil.rmtree(path, ignore_errors=True)
    21         shutil.rmtree(path, ignore_errors=True)
    69         
    69         
    70 def create_config(export_path):    
    70 def create_config(export_path):    
    71     print("Create config from %s" % (export_path,))
    71     print("Create config from %s" % (export_path,))
    72     remotepath = env.remote_web_path
    72     remotepath = env.remote_web_path
    73     remote_config_path = os.path.join(remotepath, env.platform_web_module, "config.py")
    73     remote_config_path = os.path.join(remotepath, env.platform_web_module, "config.py")
    74     template_path = os.path.join(export_path, "web", env.platform_web_module, "config.py.tmpl")
    74     template_path = os.path.join(export_path, env.local_folders.get("web","web"), env.platform_web_module, "config.py.tmpl")
    75     
    75     
    76     context = {
    76     context = {
    77      'base_dir': os.path.join(remotepath, env.platform_web_module).rstrip("/")+"/",
    77      'base_dir': os.path.join(remotepath, env.platform_web_module).rstrip("/")+"/",
    78      'base_url': env.base_url,
    78      'base_url': env.base_url,
    79      'web_url': env.web_url,
    79      'web_url': env.web_url,
   126         run("pip install -r \"%s\"" % os.path.join(remote_venv_export_path,"virtualenv","web","res","srvr_requirements.txt"))
   126         run("pip install -r \"%s\"" % os.path.join(remote_venv_export_path,"virtualenv","web","res","srvr_requirements.txt"))
   127         
   127         
   128 
   128 
   129 def do_sync_web(version, export_path):
   129 def do_sync_web(version, export_path):
   130     print("do_sync_web with version %s and path %s" % (version,export_path))
   130     print("do_sync_web with version %s and path %s" % (version,export_path))
   131     web_path = os.path.join(export_path,"web/") 
   131     web_path = os.path.join(export_path,env.local_folders.get("web","web").rstrip("/")+"/") 
   132     rsync_export(web_path, env.remote_web_path, env.web_rsync_filters)    
   132     rsync_export(web_path, env.remote_web_path, env.web_rsync_filters)    
   133     
   133     
   134 def check_folder_access():
   134 def check_folder_access():
   135     print("Check folder access")
   135     print("Check folder access")
   136     # get remote user
   136     # get remote user
   161     
   161     
   162 @task
   162 @task
   163 def update_lib(version, package):
   163 def update_lib(version, package):
   164     print(green("update ldt with version %s" % version))
   164     print(green("update ldt with version %s" % version))
   165     export_path = export_version(version)
   165     export_path = export_version(version)
   166     lib_path = os.path.join(export_path, "virtualenv", "res", "lib")
   166     lib_path = os.path.join(export_path, env.local_folders.get("virtualenv","virtualenv"), "res", "lib")
   167     
   167     
   168     f, pathname, description = imp.find_module("patch", [lib_path])
   168     f, pathname, description = imp.find_module("patch", [lib_path])
   169     patch = imp.load_module("patch", f, pathname, description)
   169     patch = imp.load_module("patch", f, pathname, description)
   170     f, pathname, description = imp.find_module("lib_create_env", [lib_path])
   170     f, pathname, description = imp.find_module("lib_create_env", [lib_path])
   171     lib_create_env = imp.load_module("lib_create_env", f, pathname, description)
   171     lib_create_env = imp.load_module("lib_create_env", f, pathname, description)
   172     
   172     
   173     package_path = os.path.join(export_path, "virtualenv", "res", "src", lib_create_env.URLS[package]['local'])
   173     package_path = os.path.join(export_path, env.local_folders.get("virtualenv","virtualenv"), "res", "src", lib_create_env.URLS[package]['local'])
   174     
   174     
   175     sync_install_build(package_path)
   175     sync_install_build(package_path)
   176     clean_export_folder(export_path)
   176     clean_export_folder(export_path)
   177     relaunch_server()
   177     relaunch_server()
   178 
   178 
   181 def create_virtualenv(version):
   181 def create_virtualenv(version):
   182     print(green("create virtualenv with version %s" % version))
   182     print(green("create virtualenv with version %s" % version))
   183     export_path = export_version(version)
   183     export_path = export_version(version)
   184     venv_remote_export_path = ""
   184     venv_remote_export_path = ""
   185     try:
   185     try:
   186         virtualenv_path = os.path.join(export_path, "virtualenv")
   186         virtualenv_path = os.path.join(export_path, env.local_folders.get("virtualenv","virtualenv"))
   187     
   187     
   188         venv_remote_export_path = os.path.join(env.remote_venv_export_path, env.export_prefix, version,"virtualenv")
   188         venv_remote_export_path = os.path.join(env.remote_venv_export_path, env.export_prefix, version,"virtualenv")
   189         rsync_export(virtualenv_path, venv_remote_export_path, env.venv_rsync_filters)
   189         rsync_export(virtualenv_path, venv_remote_export_path, env.venv_rsync_filters)
   190         do_create_virtualenv(venv_remote_export_path, env.remote_virtualenv_path)
   190         do_create_virtualenv(venv_remote_export_path, env.remote_virtualenv_path)
   191     finally:
   191     finally: