Permalink
Browse files

add djangofab.api which imports common fabric and djangofab functions

updated examples to simplify imports
  • Loading branch information...
hbussell committed Sep 22, 2009
1 parent 1f197a3 commit dbe07401a4ec087d5f79432a1d3ed4019756b15a
Showing with 16 additions and 43 deletions.
  1. +2 −5 djangofab/decorator.py
  2. +2 −4 djangofab/django.py
  3. +5 −11 djangofab/util.py
  4. +1 −3 djangofab/vcs/git.py
  5. +2 −3 djangofab/vcs/svn.py
  6. +3 −10 examples/fabfile-git.py
  7. +1 −7 examples/fabfile-svn.py
View
@@ -2,17 +2,14 @@
import sys
import ConfigParser
import subprocess
-from fabric.api import *
-from fabric.context_managers import *
-
-from djangofab.util import _apply_settings
+from djangofab.util import apply_settings
def user_settings(file='fab.cfg', group='default'):
"Decorator to load user settings from a config file into the env"
def wrap(f=None):
def wrapped_f(*args):
f(*args)
- _apply_settings(file,group)
+ apply_settings(file,group)
return wrapped_f
return wrap
View
@@ -1,8 +1,7 @@
+
from __future__ import with_statement
-from fabric.context_managers import cd
-from fabric.api import env, run, get, sudo
-from djangofab.util import local as local
import os
+from djangofab.api import *
def get_remote_db():
"Download the latest database from the server and load it onto your local database"
@@ -37,7 +36,6 @@ def put_local_db():
(settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME))
def get_db_settings():
- from fabric.operations import _handle_failure
try:
from fabfile import settings
except ImportError:
View
@@ -2,24 +2,18 @@
import sys
import ConfigParser
import subprocess
-#from fabric.api import *
-#from fabric.context_managers import *
-
-from fabric.api import local as _local
-from fabric.api import env
-
-
-from fabric.state import env, connections, output
-#def local_out(cmd):
-# return local(cmd,False)
+from djangofab.api import *
def local(cmd):
if hasattr(env,'capture_default'):
_local(cmd, env.capture_default)
else:
_local(cmd)
-def _apply_settings(file='fab.cfg', group='default'):
+def apply_settings(file='fab.cfg', group='default'):
+ if not os.path.exists(file):
+ _handle_failure(message='Configuration file %s does not exist' % file)
+ return
config = ConfigParser.ConfigParser()
config.readfp(open(file))
user_settings = {}
View
@@ -1,7 +1,5 @@
from __future__ import with_statement
-from fabric.api import run, env
-from fabric.context_managers import cd
-from djangofab.util import local as local, safe_local
+from djangofab.api import *
def update_remote():
"Update remote checkout to the latest version"
View
@@ -1,7 +1,6 @@
+
from __future__ import with_statement
-from fabric.api import run, env
-from fabric.context_managers import cd
-from djangofab.util import local as local
+from djangofab.api import *
def update_remote():
"Update remote checkout to the latest version"
View
@@ -1,18 +1,11 @@
-from __future__ import with_statement
-import sys
-from fabric.api import *
-from fabric.context_managers import *
+from djangofab.api import *
from django.conf import settings
from djangofab.vcs.git import update_remote, update_local, push, commit, add
-from djangofab.decorator import user_settings
-from djangofab.util import local as local, _apply_settings
-from djangofab.django import get_remote_db, put_local_db, change_ownership, touch_wsgi
env.capture_default = False
-
# apply the settings from fab.cfg default section
-# sets the DJANGO_SETTINGS which allows access to settings values
-_apply_settings()
+# sets DJANGO_SETTINGS which allows access to django.conf.settings values
+apply_settings()
#use the default section of fab.cfg
@user_settings()
View
@@ -1,11 +1,5 @@
-from __future__ import with_statement
-from fabric.api import *
-from fabric.context_managers import *
-from django.conf import settings
+from djangofab.api import *
from djangofab.vcs.svn import update_remote, update_local, commit, add
-from djangofab.decorator import user_settings
-from djangofab.util import local as local
-from djangofab.django import get_remote_db, put_local_db, change_ownership, touch_wsgi
env.capture_default = False
#use the default section of fab.cfg

0 comments on commit dbe0740

Please sign in to comment.