diff options
-rw-r--r-- | fabfile/__init__.py | 4 | ||||
-rw-r--r-- | fabfile/helpers.py | 23 | ||||
-rw-r--r-- | fabfile/setups.py | 5 |
3 files changed, 19 insertions, 13 deletions
diff --git a/fabfile/__init__.py b/fabfile/__init__.py index d6733aa..3cb9bb0 100644 --- a/fabfile/__init__.py +++ b/fabfile/__init__.py @@ -21,10 +21,10 @@ def deploy(): Updates the sources, links the appropriate settings, collects the static files and synchronizes/migrates the database. - Installing/updating Python packages or loading fixtures needs to be done - manually. + Loading fixtures needs to be done manually. """ helpers.update_project() + helpers.install_requirements() helpers.link_settings() helpers.collect_static() helpers.manage('supervisor stop gunicorn') diff --git a/fabfile/helpers.py b/fabfile/helpers.py index 9409ca0..ddeb7b8 100644 --- a/fabfile/helpers.py +++ b/fabfile/helpers.py @@ -26,8 +26,12 @@ def update_project(): """ require('src_root', provided_by=['setups.stage', 'setups.production']) require('git_branch', provided_by=['setups.stage', 'setups.production']) - with cd(env.src_root): - run('git pull origin %(git_branch)s' % env) + + if files.exists(env.src_root): + with cd(env.src_root): + run('git pull origin %(git_branch)s' % env) + else: + run('git clone -b %(git_branch)s %(git_url)s %(src_root)s' % env) def link_settings(): @@ -41,32 +45,33 @@ def link_settings(): else: host_settings = join_path(env.config, '%(host)s.py' % env) settings = join_path(env.proj_root, 'local_settings.py') - if files.exists(settings): - run('rm %s' % settings) if files.exists(host_settings): - run('ln -s %s %s' % (host_settings, settings)) + run('ln -sf %s %s' % (host_settings, settings)) else: - print 'No host specific settings file found. Create one at %s' % host_settings + abort('No host specific settings file found. Create one at %s' % host_settings) def collect_static(): """Collects all static files. """ - manage('collectstatic') + manage('collectstatic --noinput') @task def syncdb(): """Runs the syncdb management command. """ - manage('syncdb') + manage('syncdb --noinput') @task def migrate(app_name=None): """Runs the migrations for one or all apps. """ - manage('migrate %s' % app_name) + if app_name is None: + manage('migrate') + else: + manage('migrate %s' % app_name) @task(alias='id') diff --git a/fabfile/setups.py b/fabfile/setups.py index f4d1de8..264b237 100644 --- a/fabfile/setups.py +++ b/fabfile/setups.py @@ -11,7 +11,7 @@ def stage(): """ env.stage = True env.git_branch = 'master' - env.hosts = ['oberon.sublab.org'] + env.hosts = ['subweb@oberon.sublab.org'] env.home = '/home/subweb' env.root = join_path(env.home, 'stage') finalize() @@ -23,7 +23,7 @@ def production(): """ env.stage = False env.git_branch = 'master' - env.hosts = ['oberon.sublab.org'] + env.hosts = ['subweb@oberon.sublab.org'] env.home = '/home/subweb' env.root = join_path(env.home, 'production') finalize() @@ -37,3 +37,4 @@ def finalize(): env.pip_file = join_path(env.src_root, 'requirements.txt') env.proj_root = join_path(env.src_root, 'sublab_project') env.manage_py = join_path(env.proj_root, 'manage.py') + env.git_url = 'git://git.sublab.org/subweb.git' |