1 from fabric.api import task, run, local, env, cd, put, prefix, sudo |
1 from fabric.api import task, run, local, env, cd, put, prefix, sudo |
2 from fabric.colors import green |
2 from fabric.colors import green |
3 from fabric.contrib.project import rsync_project |
3 from fabric.contrib.project import rsync_project |
|
4 from fabric.contrib.files import exists, upload_template |
4 from mercurial import commands, ui, hg, cmdutil |
5 from mercurial import commands, ui, hg, cmdutil |
5 import imp |
6 import imp |
6 import os, os.path |
7 import os, os.path |
7 import shutil |
8 import shutil |
8 import sys |
9 import sys |
100 print("Collect static in %s with %s" % (remotepath, remotevirtualenvpath)) |
101 print("Collect static in %s with %s" % (remotepath, remotevirtualenvpath)) |
101 activate_path = os.path.join(remotevirtualenvpath, "bin/activate") |
102 activate_path = os.path.join(remotevirtualenvpath, "bin/activate") |
102 with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath): |
103 with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath): |
103 run("python manage.py collectstatic --noinput") |
104 run("python manage.py collectstatic --noinput") |
104 |
105 |
105 |
106 def create_config(export_path): |
|
107 print("Create config from %s" % (export_path,)) |
|
108 remotepath = env.remote_web_path |
|
109 remote_config_path = os.path.join(remotepath, env.platform_web_module, "config.py") |
|
110 template_path = os.path.join(export_path, "web", env.platform_web_module, "config.py.tmpl") |
|
111 |
|
112 context = { |
|
113 'base_dir': os.path.join(remotepath, env.platform_web_module).rstrip("/")+"/", |
|
114 'base_url': env.base_url, |
|
115 'base_url': env.web_url, |
|
116 'stream_url': env.stream_url, |
|
117 'stream_src_prefix': env.stream_src_prefix, |
|
118 'ffmpeg_path': env.ffmpeg_path, |
|
119 'db_engine': env.db_engine, |
|
120 'db_name': env.db_name, |
|
121 'db_user': env.db_user, |
|
122 'db_password': env.db_password, |
|
123 'db_host': env.db_host, |
|
124 'db_port': env.db_port, |
|
125 'log_file': env.log_file, |
|
126 'index_path': env.index_path, |
|
127 'google_analytics_code': env.google_analytics_code, |
|
128 'email_use_tls': env.email_use_tls, |
|
129 'email_host': env.email_host, |
|
130 'email_host_user': env.email_host_user, |
|
131 'email_host_user': env.email_host_user, |
|
132 'email_port': env.email_port, |
|
133 } |
|
134 |
|
135 if not exists(remote_config_path, verbose=True): |
|
136 upload_template(template_path, remote_config_path, context=context) |
106 |
137 |
107 def export_version(version): |
138 def export_version(version): |
108 print("export version %s" % str(version)) |
139 print("export version %s" % str(version)) |
109 |
140 |
110 export_path = get_export_path(version) |
141 export_path = get_export_path(version) |
154 |
185 |
155 @task |
186 @task |
156 def sync_web(version): |
187 def sync_web(version): |
157 print(green("sync web with version %s" % version)) |
188 print(green("sync web with version %s" % version)) |
158 export_path = export_version(version) |
189 export_path = export_version(version) |
159 do_sync_web(version, export_path) |
190 do_sync_web(version, export_path) |
|
191 create_config(export_path) |
160 clean_export_folder(export_path) |
192 clean_export_folder(export_path) |
161 relaunch_server() |
193 relaunch_server() |
162 |
194 |
163 @task |
195 @task |
164 def sync_ldt(version): |
196 def sync_ldt(version): |