|
1 from fablib import (export_version, do_sync_web, create_config, |
|
2 clean_export_folder, do_sync_comp, sync_install_build, do_create_virtualenv, |
|
3 clean_rsync_folder, rsync_export, get_comp_versions_dict, SyncComp, |
|
4 do_relaunch_server) |
|
5 from fabric.api import task, env |
|
6 from fabric.colors import green |
|
7 import config #@UnusedImport |
|
8 import imp |
|
9 import os.path |
|
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) |
|
61 |
|
62 if len(env.repos) > 1: |
|
63 @task |
|
64 def sync_platform(version): |
|
65 print(green("sync platform with version web %s" % (version))) |
|
66 export_path = export_version(web=version) |
|
67 |
|
68 export_path_web = os.path.join(export_path,'web') |
|
69 do_sync_web(version, export_path_web) |
|
70 |
|
71 comp_versions = get_comp_versions_dict(export_path_web) |
|
72 |
|
73 for key in [k for k in env.repos if k != 'web']: |
|
74 export_path_key = export_version(**{key: comp_versions[key]}) |
|
75 export_path_comp = os.path.join(export_path_key, key) |
|
76 do_sync_comp(key, export_path_comp) |
|
77 clean_export_folder(export_path_key) |
|
78 |
|
79 create_config(export_path_web) |
|
80 clean_export_folder(export_path) |
|
81 relaunch_server() |
|
82 |
|
83 for sync_name in [key for key in env.repos if key != 'web']: |
|
84 globals()[sync_name] = SyncComp(sync_name) |