124 print("Install build %s in %s" % (remotepath, remotevirtualenvpath)) |
124 print("Install build %s in %s" % (remotepath, remotevirtualenvpath)) |
125 activate_path = os.path.join(remotevirtualenvpath, "bin/activate") |
125 activate_path = os.path.join(remotevirtualenvpath, "bin/activate") |
126 |
126 |
127 with prefix("source %s" % activate_path): |
127 with prefix("source %s" % activate_path): |
128 if module_to_uninstall: |
128 if module_to_uninstall: |
129 run("pip uninstall %s" % module_to_uninstall) |
129 with settings(warn_only=True): |
|
130 run("pip uninstall -y %s" % module_to_uninstall) |
130 run("pip install \"%s\"" % remotepath) |
131 run("pip install \"%s\"" % remotepath) |
131 |
132 |
132 def collectstatic(remotepath, remotevirtualenvpath, platform_web_module): |
133 def collectstatic(remotepath, remotevirtualenvpath, platform_web_module): |
133 print("Collect static in %s with %s" % (remotepath, remotevirtualenvpath)) |
134 print("Collect static in %s with %s" % (remotepath, remotevirtualenvpath)) |
134 remotestaticsitepath = get_remote_env(remotepath, remotevirtualenvpath, platform_web_module, "STATIC_ROOT") |
135 remotestaticsitepath = get_remote_env(remotepath, remotevirtualenvpath, platform_web_module, "STATIC_ROOT") |
138 run("rm -fr \"%s\"" % (remotestaticsitepath)) |
139 run("rm -fr \"%s\"" % (remotestaticsitepath)) |
139 run("python manage.py collectstatic --noinput") |
140 run("python manage.py collectstatic --noinput") |
140 |
141 |
141 def create_config(export_path): |
142 def create_config(export_path): |
142 print("Create config from %s" % (export_path,)) |
143 print("Create config from %s" % (export_path,)) |
143 remotepath = env.remote_path['web'] |
144 remotepath = env.remote_path['src'] |
144 remote_config_path = os.path.join(remotepath, env.platform_web_module, "config.py") |
145 remote_config_path = os.path.join(remotepath, env.platform_web_module, "config.py") |
145 template_path = os.path.join(export_path, "web", env.platform_web_module, "config.py.tmpl") |
146 template_path = os.path.join(export_path, "src", env.platform_web_module, "config.py.tmpl") |
146 |
147 |
147 context = { |
148 context = { |
148 'base_dir': os.path.join(remotepath, env.platform_web_module).rstrip("/")+"/", |
149 'base_dir': os.path.join(remotepath, env.platform_web_module).rstrip("/")+"/", |
|
150 'asctime': '%(asctime)s', |
|
151 'levelname': '%(levelname)s', |
|
152 'message': '%(message)s', |
|
153 'module': '%(module)s', |
149 } |
154 } |
150 context.update(env.config['web']) |
155 context.update(env.config['web']) |
151 |
156 |
152 if not exists(remote_config_path, verbose=True): |
157 if not exists(remote_config_path, verbose=True): |
153 upload_template(template_path, remote_config_path, context=context) |
158 upload_template(template_path, remote_config_path, context=context) |
224 @task |
229 @task |
225 def relaunch_server(do_collectstatic=True): |
230 def relaunch_server(do_collectstatic=True): |
226 print("Relaunch server") |
231 print("Relaunch server") |
227 check_folder_access() |
232 check_folder_access() |
228 if do_collectstatic: |
233 if do_collectstatic: |
229 collectstatic(env.remote_path['web'], env.remote_path['virtualenv'], env.platform_web_module) |
234 collectstatic(env.remote_path['src'], env.remote_path['virtualenv'], env.platform_web_module) |
230 sudo(env.web_relaunch_cmd, shell=False) |
235 sudo(env.web_relaunch_cmd, shell=False) |
231 |
236 |
232 @task |
237 @task |
233 def sync_web(version): |
238 def sync_web(version): |
234 print(green("sync web with version %s" % version)) |
239 print(green("sync web with version %s" % version)) |