def _pull(self): if self.subdirectory and self.destination_path: local_path = create_temp_directory() shutil.copytree(os.path.join(HERMES_DIRECTORY, self.subdirectory), os.path.join(local_path, self.subdirectory)) else: local_path = os.path.join(HERMES_DIRECTORY, '.') if not os.path.exists(local_path) or len(os.listdir(local_path)) == 0: raise courier.CourierException("""HERMES_DIRECTORY is empty! Rsync will NOT be run to prevent accidental removal of data at the destination. Please make sure you run courier with parameter like --volume /etc/opt:{0} """.format(HERMES_DIRECTORY)) return local_path
def _pull(self): if self.subdirectory and self.destination_path: local_path = create_temp_directory() shutil.copytree(os.path.join(HERMES_DIRECTORY, self.subdirectory), os.path.join(local_path, self.subdirectory)) else: local_path = os.path.join(HERMES_DIRECTORY, '.') if not os.path.exists(local_path) or len( os.listdir(local_path)) == 0: raise courier.CourierException("""HERMES_DIRECTORY is empty! Rsync will NOT be run to prevent accidental removal of data at the destination. Please make sure you run courier with parameter like --volume /etc/opt:{0} """.format(HERMES_DIRECTORY)) return local_path
def _pull(self): git_ssh_script_name = urllib.quote(self.ssh_key_path, "") + ".sh" # Create unique filename. git_ssh_script_path = os.path.join(GIT_SSH_SCRIPTS_DIR, git_ssh_script_name) if not os.path.exists(git_ssh_script_path): if not os.path.exists(GIT_SSH_SCRIPTS_DIR): os.makedirs(GIT_SSH_SCRIPTS_DIR) git_ssh_command = "ssh -i {self.ssh_key_path} -o StrictHostKeyChecking=no $@ ".format(**locals()) with open(git_ssh_script_path, "w") as git_ssh_script_file: git_ssh_script_file.write(git_ssh_command) os.chmod(git_ssh_script_path, 0o755) local_path = create_temp_directory() clone_command = ( "mkdir -p {local_path} && cd {local_path} && " "GIT_SSH={git_ssh_script_path} " "git clone -b {self.branch} --depth=1 {self.repo_url}" ).format(**locals()) return_code, return_out, return_err = remote.execute_local_command(clone_command) if return_code != 0: raise GitException("Error on fetching from git: {return_err}".format(**locals())) return os.path.join(local_path, self.repo_name)