author | cavaliet |
Thu, 16 Oct 2014 16:19:21 +0200 | |
changeset 218 | 86e695732c67 |
parent 193 | a2c100af4e89 |
child 244 | 4f07ad576fee |
permissions | -rw-r--r-- |
193 | 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, |
|
60
10e4b6eae0e5
sync script evolution for django-chunked-upload
ymh <ymh.work@gmail.com>
parents:
59
diff
changeset
|
7 |
do_relaunch_server) |
10e4b6eae0e5
sync script evolution for django-chunked-upload
ymh <ymh.work@gmail.com>
parents:
59
diff
changeset
|
8 |
from fabric.api import task, env |
0 | 9 |
from fabric.colors import green |
193 | 10 |
from fabric.tasks import execute |
11 |
||
12 |
import config # @UnusedImport |
|
13 |
||
0 | 14 |
|
15 |
@task |
|
173 | 16 |
def relaunch_server(do_collectstatic=True, do_syncdb=True, do_check_folder_access=True): |
0 | 17 |
print("Relaunch server") |
173 | 18 |
do_relaunch_server(do_collectstatic, do_syncdb, env.get('check_folder_access',do_check_folder_access)) |
0 | 19 |
|
20 |
@task |
|
21 |
def sync_web(version): |
|
22 |
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
|
23 |
export_path = export_version(web=version) |
1 | 24 |
export_path_full = os.path.join(export_path,'web') |
25 |
do_sync_web(version, export_path_full) |
|
26 |
create_config(export_path_full) |
|
0 | 27 |
clean_export_folder(export_path) |
28 |
relaunch_server() |
|
29 |
||
30 |
@task |
|
31 |
def update_lib(version, package): |
|
109 | 32 |
print(green("update %s with version %s" % (package,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
|
33 |
export_path = export_version(web=version) |
1 | 34 |
export_path_full = os.path.join(export_path,'web') |
35 |
lib_path = os.path.join(export_path_full, "virtualenv", "res", "lib") |
|
0 | 36 |
|
37 |
f, pathname, description = imp.find_module("patch", [lib_path]) |
|
23 | 38 |
imp.load_module("patch", f, pathname, description) |
0 | 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 |
||
23 | 42 |
package_path_full = os.path.join(export_path_full, "virtualenv", "res", "src", lib_create_env.URLS[package]['local']) |
0 | 43 |
|
1 | 44 |
sync_install_build(package_path_full) |
0 | 45 |
clean_export_folder(export_path) |
46 |
relaunch_server() |
|
47 |
||
48 |
@task |
|
23 | 49 |
def sync_platform(version): |
50 |
print(green("sync platform with version web %s" % (version))) |
|
51 |
export_path = export_version(web=version) |
|
52 |
||
1 | 53 |
export_path_web = os.path.join(export_path,'web') |
23 | 54 |
do_sync_web(version, export_path_web) |
55 |
||
56 |
comp_versions = get_comp_versions_dict(export_path_web) |
|
57 |
||
47 | 58 |
for key in [k for k in env.repos if k != 'web']: |
23 | 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 |
||
1 | 64 |
create_config(export_path_web) |
0 | 65 |
clean_export_folder(export_path) |
66 |
relaunch_server() |
|
67 |
||
68 |
@task |
|
193 | 69 |
def create_virtualenv(version, add_dep='no'): |
0 | 70 |
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
|
71 |
export_path = export_version(web=version) |
1 | 72 |
export_path_web = os.path.join(export_path,'web') |
0 | 73 |
venv_remote_export_path = "" |
74 |
try: |
|
1 | 75 |
virtualenv_path = os.path.join(export_path_web, "virtualenv") |
0 | 76 |
|
1 | 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']) |
|
193 | 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) |
|
0 | 84 |
finally: |
85 |
clean_export_folder(export_path) |
|
86 |
if venv_remote_export_path: |
|
87 |
clean_rsync_folder(venv_remote_export_path) |
|
1 | 88 |
|
23 | 89 |
|
90 |
for sync_name in [key for key in env.repos if key != 'web']: |
|
91 |
globals()[sync_name] = SyncComp(sync_name) |