def archive_local_media(self): local_dir_ensure(self.local_media_dump_dir) media_dump_basename = "%s_media_%s.tar.gz" % (self.django.project_name, timestamp_str()) media_dump_local_path = self.local_media_dump_dir.joinpath(media_dump_basename) with lcd(self.local_media_root): cuisine.local("tar -cvzf %s ." % media_dump_local_path)
def upload_code(self, update_submodules=True): self.before_upload_code() # we need to ensure the directory is open for writing with cuisine_sudo(): dir_attribs(self.remote_project_path, mode="777") temp_dir_prefix = "django_temp_" # zip and upload file temp_dir = temp_dir_prefix + self.project_name + "_" + timestamp_str() temp_remote_path = path(remote_home()).joinpath("tmp").joinpath(temp_dir) temp_local_path = path(self.project_local_path).joinpath(temp_dir) local_dir_ensure(temp_local_path) with cuisine_sudo(): dir_ensure(temp_remote_path, recursive=True, mode="666") files = self.scm.local_archive(temp_local_path, include_submodules=update_submodules) # upload files for dir, file in files.iteritems(): local_archive_path = temp_local_path.joinpath(file) remote_archive_path = temp_remote_path.joinpath(file) operations.put(str(local_archive_path), str(temp_remote_path), use_sudo=True) local_file_delete(local_archive_path) # reset project dir self.reset_project_dir() # unpack files for dir, file in files.iteritems(): remote_archive_path = temp_remote_path.joinpath(file) # unzip file with cuisine_sudo(): if self.webserver: self.webserver.stop() extdir = path(self.remote_project_path).joinpath(dir).abspath() dir_ensure(extdir, recursive=True, mode="777") file_unzip(remote_archive_path, extdir) file_delete(remote_archive_path) cuisine.run("cd %s" % self.src_root) cuisine.run("pwd") with cuisine_sudo(): cuisine.dir_attribs(self.remote_project_path, mode="777", recursive=True) for precomp in self.precompilers: precomp.compile() # clear old archives local_dirs_delete(self.project_local_path, "%s%s.*" % (temp_dir_prefix, self.project_name)) ## upload ends here self.after_upload_code()
def upload_code(self, update_submodules=True): if self.webserver: self.webserver.stop() self.before_upload_code() # we need to ensure the directory is open for writing with cuisine_sudo(): dir_attribs(self.remote_project_path, mode='777') self.clear_remote_project_path_save_site() temp_dir_prefix = 'django_temp_' # zip and upload file temp_dir = temp_dir_prefix + self.project_name + '_' + timestamp_str() temp_remote_path = path(self.remote_project_path).joinpath(temp_dir) temp_local_path = path(self.project_local_path).joinpath(temp_dir) local_dir_ensure(temp_local_path) dir_ensure(temp_remote_path) files = self.scm.local_archive(temp_local_path, include_submodules=update_submodules) for dir, file in files.iteritems(): local_archive_path = temp_local_path.joinpath(file) remote_archive_path = temp_remote_path.joinpath(file) put(str(local_archive_path), str(temp_remote_path), use_sudo=True) local_file_delete(local_archive_path) #unzip file with cuisine_sudo(): extdir = path(self.remote_project_path).joinpath(dir).abspath() dir_ensure(extdir, recursive=True, mode='777') file_unzip(remote_archive_path, extdir) file_delete(remote_archive_path) cuisine.run("cd %s" % self.src_root) cuisine.run("pwd") with cuisine_sudo(): cuisine.dir_attribs(self.remote_project_path, mode="777", recursive=True) for precomp in self.precompilers: precomp.compile() # clear old archives local_dirs_delete(self.project_local_path, '%s%s.*' % (temp_dir_prefix, self.project_name)) ## upload ends here self.after_upload_code() if self.webserver: self.webserver.start()
def download_db_dump(self): remote_file_basename = self._create_db_backup_name() remote_dir = "/tmp" remote_file_path = "%s/%s" % (remote_dir, remote_file_basename) dir_ensure(remote_dir, mode='777') self.database.backup_database(remote_file_basename, folder=remote_dir, zip=True) local_dir_ensure(self.local_db_dump_dir) get(remote_file_path, self.local_db_dump_dir) with cuisine_sudo(): file_delete(remote_file_path)