author | ymh <ymh.work@gmail.com> |
Tue, 04 Dec 2012 10:19:44 +0100 | |
changeset 24 | 6b79d5424407 |
parent 23 | 7df43b86c425 |
child 47 | 7fc740f8553e |
permissions | -rw-r--r-- |
23 | 1 |
from fabric.api import task, env, sudo |
0 | 2 |
from fabric.colors import green |
23 | 3 |
from ldt_fablib import (check_folder_access, syncdb, collectstatic, |
4 |
export_version, do_sync_web, create_config, clean_export_folder, do_sync_comp, |
|
5 |
sync_install_build, do_create_virtualenv, clean_rsync_folder, rsync_export, |
|
24
6b79d5424407
correct fabfile and test requirement.txt
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
6 |
get_comp_versions_dict, SyncComp, do_relaunch_server) |
0 | 7 |
import imp |
23 | 8 |
import os.path |
0 | 9 |
|
10 |
@task |
|
11 | 11 |
def relaunch_server(do_collectstatic=True, do_syncdb=True): |
0 | 12 |
print("Relaunch server") |
24
6b79d5424407
correct fabfile and test requirement.txt
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
13 |
do_relaunch_server(do_collectstatic, do_syncdb) |
0 | 14 |
|
15 |
@task |
|
16 |
def sync_web(version): |
|
17 |
print(green("sync web with version %s" % version)) |
|
3
800c48d0e3c1
Correct fab file for being able to pass 2 versions : ldt and web
ymh <ymh.work@gmail.com>
parents:
1
diff
changeset
|
18 |
export_path = export_version(web=version) |
1 | 19 |
export_path_full = os.path.join(export_path,'web') |
20 |
do_sync_web(version, export_path_full) |
|
21 |
create_config(export_path_full) |
|
0 | 22 |
clean_export_folder(export_path) |
23 |
relaunch_server() |
|
24 |
||
25 |
@task |
|
26 |
def update_lib(version, package): |
|
27 |
print(green("update ldt with version %s" % version)) |
|
3
800c48d0e3c1
Correct fab file for being able to pass 2 versions : ldt and web
ymh <ymh.work@gmail.com>
parents:
1
diff
changeset
|
28 |
export_path = export_version(web=version) |
1 | 29 |
export_path_full = os.path.join(export_path,'web') |
30 |
lib_path = os.path.join(export_path_full, "virtualenv", "res", "lib") |
|
0 | 31 |
|
32 |
f, pathname, description = imp.find_module("patch", [lib_path]) |
|
23 | 33 |
imp.load_module("patch", f, pathname, description) |
0 | 34 |
f, pathname, description = imp.find_module("lib_create_env", [lib_path]) |
35 |
lib_create_env = imp.load_module("lib_create_env", f, pathname, description) |
|
36 |
||
23 | 37 |
package_path_full = os.path.join(export_path_full, "virtualenv", "res", "src", lib_create_env.URLS[package]['local']) |
0 | 38 |
|
1 | 39 |
sync_install_build(package_path_full) |
0 | 40 |
clean_export_folder(export_path) |
41 |
relaunch_server() |
|
42 |
||
43 |
@task |
|
23 | 44 |
def sync_platform(version): |
45 |
print(green("sync platform with version web %s" % (version))) |
|
46 |
export_path = export_version(web=version) |
|
47 |
||
1 | 48 |
export_path_web = os.path.join(export_path,'web') |
23 | 49 |
do_sync_web(version, export_path_web) |
50 |
||
51 |
comp_versions = get_comp_versions_dict(export_path_web) |
|
52 |
||
53 |
for key in [k for k in env.repos if key != 'web']: |
|
54 |
export_path_key = export_version(**{key: comp_versions[key]}) |
|
55 |
export_path_comp = os.path.join(export_path_key, key) |
|
56 |
do_sync_comp(key, export_path_comp) |
|
57 |
clean_export_folder(export_path_key) |
|
58 |
||
1 | 59 |
create_config(export_path_web) |
0 | 60 |
clean_export_folder(export_path) |
61 |
relaunch_server() |
|
62 |
||
63 |
@task |
|
64 |
def create_virtualenv(version): |
|
65 |
print(green("create virtualenv with version %s" % version)) |
|
3
800c48d0e3c1
Correct fab file for being able to pass 2 versions : ldt and web
ymh <ymh.work@gmail.com>
parents:
1
diff
changeset
|
66 |
export_path = export_version(web=version) |
1 | 67 |
export_path_web = os.path.join(export_path,'web') |
0 | 68 |
venv_remote_export_path = "" |
69 |
try: |
|
1 | 70 |
virtualenv_path = os.path.join(export_path_web, "virtualenv") |
0 | 71 |
|
1 | 72 |
venv_remote_export_path = os.path.join(env.remote_path['venv_export'], env.export_prefix, version,"virtualenv") |
73 |
rsync_export(virtualenv_path, venv_remote_export_path, env.rsync_filters['venv']) |
|
74 |
do_create_virtualenv(venv_remote_export_path, env.remote_path['virtualenv']) |
|
0 | 75 |
finally: |
76 |
clean_export_folder(export_path) |
|
77 |
if venv_remote_export_path: |
|
78 |
clean_rsync_folder(venv_remote_export_path) |
|
1 | 79 |
|
23 | 80 |
|
81 |
for sync_name in [key for key in env.repos if key != 'web']: |
|
82 |
globals()[sync_name] = SyncComp(sync_name) |