public
Description: Simple, Pythonic remote execution and deployment
Homepage: http://fabfile.org
Clone URL: git://github.com/bitprophet/fabric.git
bitprophet (author)
Wed Nov 04 10:34:21 -0800 2009
commit  16060c6d72d52639becfefeb374be6b0b24329d5
tree    8f7d0f9379a67ed594e86b14390e4681770afa0f
parent  51e9b92c7e24ca0765c81e4e3b09a679e7cd69fc parent  652b430a61bb12cad3f87891de50bfb17fbfe432
fabric / fabfile.py
100644 81 lines (69 sloc) 2.566 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
Fabric's own fabfile.
"""
 
from __future__ import with_statement
 
from fabric.api import *
from fabric.contrib.project import rsync_project
import fabric.version
 
 
def test(args=None):
    """
Run all unit tests and doctests.
 
Specify string argument ``args`` for additional args to ``nosetests``.
"""
    if args is None:
        args = ""
    print(local('nosetests -sv --with-doctest %s' % args, capture=False))
 
 
def build_docs(clean='no', browse='no'):
    """
Generate the Sphinx documentation.
"""
    c = ""
    if clean.lower() in ['yes', 'y']:
        c = "clean "
    b = ""
    if browse.lower() in ['yes', 'y']:
        b = " && open _build/html/index.html"
    local('cd docs; make %shtml%s' % (c, b), capture=False)
 
 
@hosts('jforcier@fabfile.org')
def push_docs():
    """
Build and push the Sphinx docs to docs.fabfile.org
"""
    build_docs()
    branch = fabric.version.get_version(line_only=True)
    remote_loc = '/var/www/docs.fabfile/%s/' % branch
    rsync_project(remote_loc, 'docs/_build/html/', delete=True)
 
 
def tag():
    """
Tag a new release of the software
"""
    with settings(warn_only=True):
        # Get current version string
        version = fabric.version.get_version()
        # Does that tag already exist?
        exists = local("git tag | grep %s" % version)
        if exists:
            # If no work has been done since, what's the point?
            if not local("git log %s.." % version):
                abort("No work done since last tag!")
            # If work *has* been done since, we need to make a new tag. To the
            # editor for version update!
            raw_input("Work has been done since last tag, version update is needed. Hit Enter to load version info in your editor: ")
            local("$EDITOR fabric/version.py", capture=False)
            # Reload version module to get new version
            reload(fabric.version)
        # If the tag doesn't exist, the user has already updated version info
        # and we can just move on.
        else:
            print("Version has already been updated, no need to edit...")
        # Get version strings
        verbose_version = fabric.version.get_version(verbose=True)
        short_version = fabric.version.get_version()
        # Commit the version update
        local("git add fabric/version.py")
        local("git commit -m \"Cut %s\"" % verbose_version)
        # And tag it
        local("git tag -m \"Fabric %s\" %s" % (
            verbose_version,
            short_version
        ))