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
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
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
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)
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)
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
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
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
def ip(): command = "grep 'config.vm.network' Vagrantfile | egrep -o '[0-9\.]{7,}'" return local(command, capture=True)
def revparse(revision): return core.local('git rev-parse %s' % revision, capture=True)
def repository_name(): command = "grep 'url' .git/config | cut -d':' -f2" return local(command, capture=True)