Skip to content

Instantly share code, notes, and snippets.

@notanumber
Created August 23, 2011 02:25
Show Gist options
  • Save notanumber/1164179 to your computer and use it in GitHub Desktop.
Save notanumber/1164179 to your computer and use it in GitHub Desktop.
from fabric.api import abort, hide, lcd, local, settings
from fabric.contrib.console import confirm
from fabric.contrib import django
django.project('foo')
def check_repository():
"""
Checks local repository to ensure there are no uncommitted
changes or files that have not been added to the repository.
"""
with settings(hide('warnings'), warn_only=True):
result = local('git diff-index --quiet HEAD', capture=True) # Check for uncommitted changes
if result.return_code and not confirm('Repository has uncommitted changes. Ignore?'):
abort('Aborted')
with settings(hide('warnings'), warn_only=True):
result = local('git ls-files --others --exclude-standard --error-unmatch .', capture=True)
if len(result) and not confirm('Untracked files: \n%s\nIgnore?' % result):
abort('Aborted')
def check_tests():
""" Run the project test suite. """
local('django-admin.py test')
def check_pep8():
""" Check the project for PEP8 compliance using `pep8` """
with settings(hide('warnings'), warn_only=True):
local('pep8 .')
def check_pylint():
""" Check the project for PEP8 compliance using `pylint`. """
with settings(hide('warnings'), warn_only=True):
with(lcd('..')):
local('pylint --reports=n --rcfile=.pylintrc foo')
def pre_deployment_check():
""" Run through the pre-deployment check list. """
check_repository()
check_tests()
check_pep8()
check_pylint()
def build_html_docs():
""" Create HTML docs """
with(lcd('../docs')):
local('sphinx-build -b html -d _build/doctrees . _build/html')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment