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