From 545a83dd2133ca8f48439c675405589e4c8c8a81 Mon Sep 17 00:00:00 2001 From: Luan Pablo Date: Mon, 18 Jan 2016 22:29:44 -0200 Subject: [PATCH 1/2] removed os.path.join from fabfile allows the usage of the django-project-template in a windows environment --- fabfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fabfile.py b/fabfile.py index c8d11d7..f4ed35c 100644 --- a/fabfile.py +++ b/fabfile.py @@ -16,7 +16,7 @@ env.user = APP_USER env.use_shell = False -PROJECT_PATH = os.path.join(os.path.dirname(__file__)) +PROJECT_PATH = os.path.dirname(__file__) REPO_PATH = '/home/{}/{}'.format(APP_USER, APP_NAME) SOURCE_VENV = 'source /usr/local/bin/virtualenvwrapper.sh' WORKON_ENV = '{} && workon {}'.format(SOURCE_VENV, VENV_NAME) @@ -140,8 +140,8 @@ def bootstrap(): )) sudo('chown -fR {0}:{0} {1}'.format(APP_USER, ssh_dir)) - sudoers_file = os.path.join('/etc/sudoers.d/', APP_USER) - tmp_file = os.path.join('/tmp', APP_USER) + sudoers_file = '/etc/sudoers.d/{}'.format(APP_USER) + tmp_file = '/tmp/{}'.format(APP_USER) if not exists(sudoers_file): sudo('echo "{} ALL=NOPASSWD: ALL" > {}'.format(APP_USER, tmp_file)) sudo('chown root:root {}'.format(tmp_file)) @@ -157,8 +157,8 @@ def provision(branch='master'): update_code(branch) - puppet_path = os.path.join(REPO_PATH, 'puppet/') - modules_path = os.path.join(puppet_path, 'modules') + puppet_path = '{}/puppet/'.format(REPO_PATH) + modules_path = '{}/modules'.format(puppet_path) puppet_modules = '{}:/etc/puppet/modules'.format(modules_path) if not exists('/usr/bin/puppet'): @@ -169,7 +169,7 @@ def provision(branch='master'): run('sudo python bootstrap.py') if env.is_vagrant: - cmd = os.path.join(puppet_path, 'manifests', 'site.pp') + cmd = '{}/manifests/site.pp'.format(puppet_path) else: cmd = '-e "include {}"'.format(APP_NAME) From 0d1af4ccaf9cbfb1f6db97127ecd76648b7709de Mon Sep 17 00:00:00 2001 From: Luan Pablo Date: Mon, 18 Jan 2016 22:33:45 -0200 Subject: [PATCH 2/2] added DJANGO_SETTINGS_MODULE to .bashrc if it doesn't exist --- fabfile.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fabfile.py b/fabfile.py index f4ed35c..85761c2 100644 --- a/fabfile.py +++ b/fabfile.py @@ -80,7 +80,9 @@ def mkvirtualenv(): def manage(command): - default_settings = '{{ project_name }}.settings.{0}'.format(env.environment) + default_settings = '{{ project_name }}.settings.{0}'.format( + env.environment + ) django_settings = env.get('django_settings', default_settings) with shell_env(DJANGO_SETTINGS_MODULE=django_settings): @@ -150,6 +152,15 @@ def bootstrap(): sudo('apt-get update --fix-missing') + with settings(user=env.user): + bashrc = run('cat ~/.bashrc') + if 'DJANGO_SETTINGS_MODULE' not in bashrc: + default_settings = '{{ project_name }}.settings.{0}'.format( + env.environment + ) + run('echo "export DJANGO_SETTINGS_MODULE={0}" >> ~/.bashrc'.format( + default_settings)) + @task def provision(branch='master'):