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