Пример #1
0
def __fabdir(branch, filepath='', release=None):
    # only a function taking the split up branch/filepath can be decorated
    release = release or base.current_release()
    directory = _join(env.releases_path, release, env.github_repo_name)

    for root, dirs, files in walk("fab/%s" % branch):
        subdir = re.sub("^fab/%s/?" % branch,'',root)
        for name in dirs:
            joinpath = _join(subdir, name)
            # only make the dirs you need
            if re.match(re.escape(filepath), joinpath) \
            or re.match(re.escape(joinpath)+'/', filepath):
                if joinpath[0:1]!='.' \
                or joinpath.split('/')[0] == filepath.split('/')[0]:
                    # ignore or trim 'hidden' dirs in fab/<branch>/
                    run("mkdir -p %s" %  _join(directory, re.sub('^\.[^/]*/?', '', joinpath)))
        for name in files:
            joinpath = _join(subdir, name)
            if filepath == '' or re.match(re.escape(filepath), joinpath):
                if joinpath[0:1]!='.' \
                or joinpath.split('/')[0] == filepath.split('/')[0] \
                or subdir == '':
                    # ignore or trim filepaths within 'hidden' dirs in fab/<branch>/
                    put(_join(root, name),
                        _join(directory, re.sub('^\.[^/]*/', '', joinpath)))
Пример #2
0
def execute(branch, command, release=None):
    """
    Execute a shell command in the virtualenv
    
        $ fab execute:staging,"tail logs/*.log"
    
    If no release is specified it defaults to the latest release.
    
    """
    release = release or base.current_release()
    directory = _join(env.releases_path, release, env.github_repo_name)
    return _virtualenv(directory, command)
Пример #3
0
def copy_settings_file(branch, release=None):
    """
    Copy the settings file for this branch to the server
    
        $ fab copy_settings_file:staging
        
    If no release is specified it defaults to the latest release.
    
    
    """
    release = release or base.current_release()
    directory = _join(env.releases_path, release, env.github_repo_name)
    put(
        "environments/%(branch)s.py" % env, 
        _join(directory, "environments/%(branch)s.py" % env)
    )
Пример #4
0
def create_virtualenv(branch, release=None):
    """
    Create the virtualenv and install the PIP requirements
    
        $ fab create_virtualenv:staging
    
    If no release is specified it defaults to the latest release
    
    """
    release = release or base.current_release()
    directory = _join(env.releases_path, release, env.github_repo_name)
    with cd(directory):
        return run(" && ".join([
            "virtualenv --no-site-packages ve",
            "source ve/bin/activate",
            "pip -E ve install --download-cache=%(pip_cache_path)s -r requirements.pip" % env,
            "python setup.py develop",
        ]))