Permalink
Browse files

linter fixes

  • Loading branch information...
1 parent 4c973eb commit 6efceb9cd8dc051d94f50f143cefafeae10469e2 @senko senko committed Aug 29, 2012
Showing with 30 additions and 9 deletions.
  1. +20 −0 fabfile.py
  2. +6 −3 skeletor/settings/base.py
  3. +0 −2 skeletor/settings/prod.py
  4. +4 −4 skeletor/settings/test.py
View
@@ -4,10 +4,12 @@
from fabric.api import *
from fabric.contrib.project import rsync_project
+
def _cd_project_root():
assert hasattr(env, 'project_path')
return cd(env.project_path)
+
def _activate():
assert hasattr(env, 'virtualenv')
if '/' in env.virtualenv:
@@ -17,6 +19,7 @@ def _activate():
'source ~/.profile 2>/dev/null || true &&' +
'workon ' + env.virtualenv)
+
def _discover_project_name():
from os import listdir
from os.path import join, dirname, exists
@@ -30,44 +33,52 @@ def _discover_project_name():
# Settings
+
def env(venv):
"""Virtual environment to use on the server"""
env.virtualenv = venv
+
def server(server):
"""Server to use"""
env.hosts = [server]
+
def path(path):
"""Project path on the server"""
env.project_path = path
# Base commands
+
def rsync():
"""Sync remote files to the server using rsync."""
assert hasattr(env, 'project_path')
local_dir = os.path.dirname(__file__) + '/'
rsync_project(remote_dir=env.project_path, local_dir=local_dir,
exclude=['media/', 'static/', '*.pyc', '.git/', 'dev.db'])
+
def manage(cmd):
"""Run Django management command on the server"""
with _activate():
with _cd_project_root():
run('python manage.py ' + cmd)
+
def git_pull(remote='origin'):
"""Pull newest version from the git repository"""
assert hasattr(env, 'project_path')
with _cd_project_root():
run('git pull ' + remote)
+
def git_clone(origin):
"""Create a new project instance by cloning the source repository"""
assert hasattr(env, 'project_path')
run('git clone %s %s' % (origin, env.project_path))
+
def git_tag_now(prefix):
"""Tag the current branch HEAD with a timestamp"""
import datetime
@@ -78,24 +89,29 @@ def git_tag_now(prefix):
# High-level commands
+
def install_requirements():
"""Install required Python packages (from requirements.txt)"""
with _activate():
with _cd_project_root():
run('pip install -r requirements.txt')
+
def collectstatic():
"""Collect static files using collectstatic."""
manage('collectstatic --noinput')
+
def syncdb():
"""Execute initial syncdb"""
manage('syncdb')
+
def migrate():
"""Execute any pending South migrations on the server."""
manage('migrate')
+
def test():
"""Run Django tests"""
assert hasattr(env, 'project_path')
@@ -105,6 +121,7 @@ def test():
else:
manage('test')
+
def update():
"""Do a complete project update.
@@ -119,6 +136,7 @@ def update():
syncdb()
migrate()
+
def setup(origin):
"""Create an initial deployment from the source git repository.
@@ -142,6 +160,7 @@ def setup(origin):
update()
test()
+
def deploy():
"""Deploy a new version of the app from the tracked git branch."""
assert hasattr(env, 'project_path')
@@ -151,6 +170,7 @@ def deploy():
update()
test()
+
def runserver(host='0.0.0.0', port='8000'):
"""Run a development server on host:port (default 0.0.0.0:8000)"""
manage('runserver %s:%s' % (host, port))
@@ -5,6 +5,7 @@
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
PROJECT_NAME = os.path.basename(ROOT_DIR)
+
def ABS_PATH(*args):
return os.path.join(ROOT_DIR, *args)
@@ -74,13 +75,15 @@ def ABS_PATH(*args):
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
+
def ensure_secret_key_file():
"""Checks that secret.py exists in settings dir. If not, creates one
with a random generated SECRET_KEY setting."""
secret_path = os.path.join(ABS_PATH('settings'), 'secret.py')
if not os.path.exists(secret_path):
from django.utils.crypto import get_random_string
- secret_key = get_random_string(50, 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)')
+ secret_key = get_random_string(50,
+ 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)')
with open(secret_path, 'w') as f:
f.write("SECRET_KEY = " + repr(secret_key) + "\n")
@@ -106,8 +109,8 @@ def ensure_secret_key_file():
ROOT_URLCONF = PROJECT_NAME + '.urls'
TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
- # Always use forward slashes, even on Windows.
+ # Put strings here, like "/home/html/django_templates" or
+ # "C:/www/django/templates". Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
ABS_PATH('templates'),
)
@@ -12,5 +12,3 @@
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
-
-
@@ -16,8 +16,8 @@
SKIP_SOUTH_TESTS = True
# Disable Sentry if it was installed
-INSTALLED_APPS = [ app for app in INSTALLED_APPS
- if not app.startswith('raven.') ]
-MIDDLEWARE_CLASSES = [ cls for cls in MIDDLEWARE_CLASSES
- if not cls.startswith('raven.') ]
+INSTALLED_APPS = [app for app in INSTALLED_APPS
+ if not app.startswith('raven.')]
+MIDDLEWARE_CLASSES = [cls for cls in MIDDLEWARE_CLASSES
+ if not cls.startswith('raven.')]
LOGGING = BASE_LOGGING

0 comments on commit 6efceb9

Please sign in to comment.