|
1 import imp |
|
2 import os.path |
|
3 |
|
4 from fabric.api import task, env |
|
5 from fabric.colors import green |
|
6 |
|
7 import config # @UnusedImport |
|
8 from fablib import (export_version, do_sync_web, create_config, |
|
9 clean_export_folder, do_sync_comp, sync_install_build, do_create_virtualenv, |
|
10 clean_rsync_folder, rsync_export, get_comp_versions_dict, SyncComp, |
|
11 do_relaunch_server) |
|
12 |
|
13 |
|
14 @task |
|
15 def relaunch_server(do_collectstatic=True, do_syncdb=True, do_check_folder_access=True): |
|
16 print("Relaunch server") |
|
17 do_relaunch_server(do_collectstatic, do_syncdb, env.get('check_folder_access',do_check_folder_access)) |
|
18 |
|
19 @task |
|
20 def sync_web(version): |
|
21 print(green("sync web with version %s" % version)) |
|
22 export_path = export_version(web=version) |
|
23 export_path_full = os.path.join(export_path,'web') |
|
24 do_sync_web(version, export_path_full) |
|
25 create_config(export_path_full) |
|
26 clean_export_folder(export_path) |
|
27 relaunch_server() |
|
28 |
|
29 @task |
|
30 def update_lib(version, package): |
|
31 print(green("update %s with version %s" % (package,version))) |
|
32 export_path = export_version(web=version) |
|
33 export_path_full = os.path.join(export_path,'web') |
|
34 lib_path = os.path.join(export_path_full, "virtualenv", "res", "lib") |
|
35 |
|
36 f, pathname, description = imp.find_module("patch", [lib_path]) |
|
37 imp.load_module("patch", f, pathname, description) |
|
38 f, pathname, description = imp.find_module("lib_create_env", [lib_path]) |
|
39 lib_create_env = imp.load_module("lib_create_env", f, pathname, description) |
|
40 |
|
41 package_path_full = os.path.join(export_path_full, "virtualenv", "res", "src", lib_create_env.URLS[package]['local']) |
|
42 |
|
43 sync_install_build(package_path_full) |
|
44 clean_export_folder(export_path) |
|
45 relaunch_server() |
|
46 |
|
47 |
|
48 @task |
|
49 def create_virtualenv(version): |
|
50 print(green("create virtualenv with version %s" % version)) |
|
51 export_path = export_version(web=version) |
|
52 export_path_web = os.path.join(export_path,'web') |
|
53 venv_remote_export_path = "" |
|
54 try: |
|
55 virtualenv_path = os.path.join(export_path_web, "virtualenv") |
|
56 |
|
57 venv_remote_export_path = os.path.join(env.remote_path['venv_export'], env.export_prefix, version,"virtualenv") |
|
58 rsync_export(virtualenv_path, venv_remote_export_path, env.rsync_filters['venv']) |
|
59 do_create_virtualenv(venv_remote_export_path, env.remote_path['virtualenv']) |
|
60 finally: |
|
61 clean_export_folder(export_path) |
|
62 if venv_remote_export_path: |
|
63 clean_rsync_folder(venv_remote_export_path) |
|
64 |
|
65 if len(env.repos) > 1: |
|
66 @task |
|
67 def sync_platform(version): |
|
68 print(green("sync platform with version web %s" % (version))) |
|
69 export_path = export_version(web=version) |
|
70 |
|
71 export_path_web = os.path.join(export_path,'web') |
|
72 do_sync_web(version, export_path_web) |
|
73 |
|
74 comp_versions = get_comp_versions_dict(export_path_web) |
|
75 |
|
76 for key in [k for k in env.repos if k != 'web']: |
|
77 export_path_key = export_version(**{key: comp_versions[key]}) |
|
78 export_path_comp = os.path.join(export_path_key, key) |
|
79 do_sync_comp(key, export_path_comp) |
|
80 clean_export_folder(export_path_key) |
|
81 |
|
82 create_config(export_path_web) |
|
83 clean_export_folder(export_path) |
|
84 relaunch_server() |
|
85 |
|
86 for sync_name in [key for key in env.repos if key != 'web']: |
|
87 globals()[sync_name] = SyncComp(sync_name) |