3 from fabric.api import env, require
4 from fabric.tasks import Task
5 from fnpdjango.deploy import Command
8 class Environment(Task):
9 def __init__(self, *args, **kwargs):
10 super(Environment, self).__init__(*args, **kwargs)
11 self.npm_bin = kwargs.pop('npm_bin', 'npm')
12 self.host = kwargs.pop('host')
13 self.env_vars = kwargs
14 self.env_vars['skip_collect_static'] = True
16 def run(self, *args, **kwargs):
17 env.project_name = 'redakcja'
18 env.hosts = [self.host]
19 for k,v in self.env_vars.items():
24 build_cmd = '../../ve/bin/python manage.py build --npm-bin=%s --editor-npm-env=%s' \
25 % (self.npm_bin, os.path.join(env['app_path'], 'npm_env'))
26 if 'node_bin_path' in self.env_vars:
27 build_cmd += ' --node-bin-path=%s' % self.env_vars['node_bin_path']
28 if 'editor_optimize' in self.env_vars:
29 build_cmd += ' --editor-optimize=%s' % self.env_vars['editor_optimize']
31 env.pre_collectstatic = [
32 Command([build_cmd], '')