10 import sys |
10 import sys |
11 |
11 |
12 import config |
12 import config |
13 |
13 |
14 def get_export_path(version): |
14 def get_export_path(version): |
15 base_path = os.path.join(env.base_export_path,env.export_prefix).lstrip("/") |
15 base_path = os.path.join(env.base_export_path,env.export_prefix).rstrip("/") |
16 return os.path.expanduser(base_path) + "_%s" % (str(version)) |
16 return os.path.expanduser(base_path) + "_%s" % (str(version)) |
17 |
17 |
18 def clean_export_folder(path): |
18 def clean_export_folder(path): |
19 print("Removing %s" % path) |
19 print("Removing %s" % path) |
20 if os.path.isdir(path): |
20 if os.path.isdir(path): |
29 |
29 |
30 def get_remote_env(remotepath, remotevirtualenvpath, platform_web_module, settings_key): |
30 def get_remote_env(remotepath, remotevirtualenvpath, platform_web_module, settings_key): |
31 activate_path = os.path.join(remotevirtualenvpath, "bin/activate") |
31 activate_path = os.path.join(remotevirtualenvpath, "bin/activate") |
32 res = "" |
32 res = "" |
33 with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath): |
33 with prefix("source \"%s\"" % activate_path), prefix("export PYTHONPATH=\"%s\"" % remotepath), cd(remotepath): |
34 tempfilepath = run("mktemp --tmpdir ldtplatform.XXXXXX") |
34 tempfilepath = run("mktemp -t ldtplatform.XXXXXX") |
35 with settings(warn_only=True): |
35 with settings(warn_only=True): |
36 run("echo \"import os\" > %s" % (tempfilepath)) |
36 run("echo \"import os\" > %s" % (tempfilepath)) |
37 map(lambda str: run("echo \"%s\" >> %s" % (str, tempfilepath)), |
37 map(lambda str: run("echo \"%s\" >> %s" % (str, tempfilepath)), |
38 ["os.environ.setdefault('DJANGO_SETTINGS_MODULE', '%s.settings')" % (platform_web_module), |
38 ["os.environ.setdefault('DJANGO_SETTINGS_MODULE', '%s.settings')" % (platform_web_module), |
39 "from django.conf import settings", |
39 "from django.conf import settings", |
139 'db_user': env.db_user, |
139 'db_user': env.db_user, |
140 'db_password': env.db_password, |
140 'db_password': env.db_password, |
141 'db_host': env.db_host, |
141 'db_host': env.db_host, |
142 'db_port': env.db_port, |
142 'db_port': env.db_port, |
143 'log_file': env.log_file, |
143 'log_file': env.log_file, |
144 'index_path': env.index_path, |
|
145 'google_analytics_code': env.google_analytics_code, |
144 'google_analytics_code': env.google_analytics_code, |
146 'email_use_tls': env.email_use_tls, |
145 'email_use_tls': env.email_use_tls, |
147 'email_host': env.email_host, |
146 'email_host': env.email_host, |
148 'email_host_user': env.email_host_user, |
147 'email_host_user': env.email_host_user, |
149 'email_host_user': env.email_host_user, |
148 'email_host_user': env.email_host_user, |
150 'email_port': env.email_port, |
149 'email_port': env.email_port, |
|
150 'forbidden_stream_url': env.forbidden_stream_url, |
151 } |
151 } |
152 |
152 |
153 if not exists(remote_config_path, verbose=True): |
153 if not exists(remote_config_path, verbose=True): |
154 upload_template(template_path, remote_config_path, context=context) |
154 upload_template(template_path, remote_config_path, context=context) |
155 |
155 |
215 run("chown -R -c :%s \"%s\"" % (env.web_group, folder_path)) |
215 run("chown -R -c :%s \"%s\"" % (env.web_group, folder_path)) |
216 run("chmod -R -c g+w \"%s\"" % folder_path) |
216 run("chmod -R -c g+w \"%s\"" % folder_path) |
217 @task |
217 @task |
218 def relaunch_server(do_collectstatic=True): |
218 def relaunch_server(do_collectstatic=True): |
219 print("Relaunch server") |
219 print("Relaunch server") |
|
220 check_folder_access() |
220 if do_collectstatic: |
221 if do_collectstatic: |
221 collectstatic(env.remote_web_path, env.remote_virtualenv_path, env.platform_web_module) |
222 collectstatic(env.remote_web_path, env.remote_virtualenv_path, env.platform_web_module) |
222 check_folder_access() |
|
223 sudo(env.web_relaunch_cmd, shell=False) |
223 sudo(env.web_relaunch_cmd, shell=False) |
224 |
224 |
225 @task |
225 @task |
226 def sync_web(version): |
226 def sync_web(version): |
227 print(green("sync web with version %s" % version)) |
227 print(green("sync web with version %s" % version)) |