Esempio n. 1
0
def create_archive(revision):
    tmp_folder = dir.temp_local()
    tmp_tar = os.path.join(tmp_folder, 'repo.tar.gz')

    core.local(
        'git archive --format=tar %(rev)s | gzip > %(tar)s'
        % {'rev': revision, 'tar': tmp_tar}
    )

    return tmp_tar
Esempio n. 2
0
def create_archive(revision):
    tmp_folder = dir.temp_local()
    tmp_tar = os.path.join(tmp_folder, 'repo.tar.gz')

    core.local('git archive --format=tar %(rev)s | gzip > %(tar)s' % {
        'rev': revision,
        'tar': tmp_tar
    })

    return tmp_tar
Esempio n. 3
0
def select():
    if not is_running():
        log.abort("Vagrant based VM currently NOT running")
        return

    config_path = os.path.join(dir.temp_local(), "vagrant_ssh_config")
    core.local("vagrant ssh-config > %s" % config_path)

    core.env.hosts = ["default"]
    core.env.password = "******"
    core.env.ssh_config_path = config_path
    core.env.use_ssh_config = True
Esempio n. 4
0
def select():
    if not is_running():
        log.abort("Vagrant based VM currently NOT running")
        return

    config_path = os.path.join(dir.temp_local(), "vagrant_ssh_config")
    core.local("vagrant ssh-config > %s" % config_path)

    core.env.hosts = ["default"]
    core.env.password = "******"
    core.env.ssh_config_path = config_path
    core.env.use_ssh_config = True
Esempio n. 5
0
    def _upload(self):
        # TODO Warn if there are local changes
        tmp_tar = git.create_archive(self.revision)

        try:
            core.put(tmp_tar, "deploy.tar.gz")
            core.run("tar -xzf deploy.tar.gz")
            file.remove("deploy.tar.gz")

            with ctx.unpatched_state():
                file.write("VERSION", git.revparse(self.revision))
        finally:
            core.local("rm -rf %s" % tmp_tar)
Esempio n. 6
0
    def _upload(self):
        # TODO Warn if there are local changes
        tmp_tar = git.create_archive(self.revision)

        try:
            core.put(tmp_tar, "deploy.tar.gz")
            core.run("tar -xzf deploy.tar.gz")
            file.remove("deploy.tar.gz")

            with ctx.unpatched_state():
                file.write("VERSION", git.revparse(self.revision))
        finally:
            core.local("rm -rf %s" % tmp_tar)
Esempio n. 7
0
def _upload(owner, upload_dir, revision):
    tmp_tar = git.create_archive(revision)

    try:
        with ctx.cd(upload_dir):
            with ctx.sudo():
                put(tmp_tar, 'deploy.tar.gz')
                file.attributes('deploy.tar.gz', owner=owner)

            with ctx.sudo(owner):
                run('tar -xzf deploy.tar.gz')
                file.remove('deploy.tar.gz')
                file.write('VERSION', git.revparse(revision))
    finally:
        local('rm -rf %s' % tmp_tar)
Esempio n. 8
0
def is_running():
    with ctx.settings(warn_only=True):
        command = "vagrant status | egrep -o 'running$'"
        vm_running = core.local(command, capture=True)

    if vm_running is None or vm_running == "":
        return False

    return True
Esempio n. 9
0
def is_running():
    with ctx.settings(warn_only=True):
        command = "vagrant status | egrep -o 'running$'"
        vm_running = local(command, capture=True)

    if vm_running == None or vm_running == "":
        return False

    return True
Esempio n. 10
0
def repository_name():
    command = "grep 'url' .git/config | cut -d':' -f2"
    name = core.local(command, capture=True)

    # Get the basename (e.g. github/repo => repo)
    name = name.split("/")[-1]

    # Also strip the sometimes optional .git extension
    if name.endswith(".git"):
        name = name[:-4]

    return name
Esempio n. 11
0
def repository_name():
    command = "grep 'url' .git/config | cut -d':' -f2"
    name = core.local(command, capture=True)

    # Get the basename (e.g. github/repo => repo)
    name = name.split("/")[-1]

    # Also strip the sometimes optional .git extension
    if name.endswith(".git"):
        name = name[:-4]

    return name
Esempio n. 12
0
def ip():
    command = "grep 'config.vm.network' Vagrantfile | egrep -o '[0-9\.]{7,}'"
    return local(command, capture=True)
Esempio n. 13
0
def revparse(revision):
    return core.local('git rev-parse %s' % revision, capture=True)
Esempio n. 14
0
def revparse(revision):
    return core.local('git rev-parse %s' % revision, capture=True)
Esempio n. 15
0
def repository_name():
    command = "grep 'url' .git/config | cut -d':' -f2"
    return local(command, capture=True)