diff --git a/stdm/composer/composer_wrapper.py b/stdm/composer/composer_wrapper.py index 8508766b..deb93f39 100755 --- a/stdm/composer/composer_wrapper.py +++ b/stdm/composer/composer_wrapper.py @@ -588,7 +588,6 @@ def _configure_data_controls(self, composer_data_source): # Use composer item id since the uuid is stripped off composerItem = self.composition().itemById(composerId) - if composerItem is not None: compFieldSelector = ComposerFieldSelector(self, composerItem, self.mainWindow()) compFieldSelector.selectFieldName(composer_data_source.dataFieldName(composerId)) diff --git a/stdm/scripts/dbbackup.bat b/stdm/scripts/dbbackup.bat index 213cf380..48f6d1d3 100644 --- a/stdm/scripts/dbbackup.bat +++ b/stdm/scripts/dbbackup.bat @@ -21,16 +21,17 @@ set PGPASSWORD=%5 set BACKUP_FOLDER=%6 set PG_BASE_FOLDER=%7 + set BACKUP_FILENAME=%8 REM set log_file=%BACKUP_FOLDER%\backit.log - set BACKUP_FILE="%BACKUP_FOLDER%\%DATABASE_NAME%_%datestr%.backup" - echo backup file name is %BACKUP_FILE% + REM set BACKUP_FILE="%BACKUP_FOLDER%\%DATABASE_NAME%_%datestr%.backup" + echo backup file name is %BACKUP_FILENAME% echo on REM PAUSE - %PG_BASE_FOLDER% -h %PG_SERVER% -p %PG_PORT% -U %PG_USER% -F c -b -v -f %BACKUP_FILE% %DATABASE_NAME% + %PG_BASE_FOLDER% -h %PG_SERVER% -p %PG_PORT% -U %PG_USER% -F c -b -v -f %BACKUP_FILENAME% %DATABASE_NAME% timeout /t 3 diff --git a/stdm/ui/db_profile_backup.py b/stdm/ui/db_profile_backup.py index 04bb35b4..72e689dd 100644 --- a/stdm/ui/db_profile_backup.py +++ b/stdm/ui/db_profile_backup.py @@ -40,7 +40,8 @@ from qgis.PyQt.QtCore import ( Qt, QDir, - QDateTime + QDateTime, + QCoreApplication ) from qgis.gui import QgsGui @@ -108,6 +109,7 @@ def __init__(self, iface): self.db_conn = self.db_config.read() # DatabaseConnection self.txtDBName.setText(self.db_conn.Database) self.txtAdmin.setText('postgres') + self.lblStatus.setText('') self.config_templates = [] @@ -170,8 +172,6 @@ def _profile_templates(self, profile: Profile) ->list[QTreeWidgetItem]: self.config_templates.append(filepath) return template_items - # --------------------------------------------------------------------------- - def backup_folder_clicked(self): self._set_selected_directory(self.edtBackupFolder, self.tr('Configuration file and DB backup folder') @@ -217,6 +217,9 @@ def do_backup(self): db_name = self.db_conn.Database db_backup_filename = self._make_backup_filename(db_name) + self.lblStatus.setText('Backup started, please wait...') + QCoreApplication.processEvents() + path_sep = "/" backup_folder = f"{self.edtBackupFolder.text()}" db_backup_filepath =f"{backup_folder}{path_sep}{db_backup_filename}" @@ -261,6 +264,8 @@ def do_backup(self): if self.compress_backup(db_name, backup_folder, compressed_files): self._remove_compressed_files(compressed_files) + self.lblStatus.setText('Backup completed.') + msg_box = QMessageBox() msg_box.setIcon(QMessageBox.Information) msg_box.setText(self.tr('Backup completed successfully.')) @@ -307,7 +312,6 @@ def backup_database(self, db_conn: DatabaseConnection, user: str, if backup_util == "": return False - script_file = "/scripts/dbbackup.bat" script_filepath = f"{PLUGIN_DIR}{script_file}" backup_folder = f"{self.edtBackupFolder.text()}" @@ -315,7 +319,8 @@ def backup_database(self, db_conn: DatabaseConnection, user: str, startup_info = subprocess.STARTUPINFO() startup_info.dwFlags |=subprocess.STARTF_USESHOWWINDOW process = subprocess.Popen([script_filepath, db_conn.Database, - db_conn.Host, str(db_conn.Port), user, password, backup_folder, backup_util], startupinfo=startup_info) + db_conn.Host, str(db_conn.Port), user, password, backup_folder, backup_util, + backup_filepath], startupinfo=startup_info) stdout, stderr = process.communicate() process.wait() diff --git a/stdm/ui/ui_db_profile_backup.ui b/stdm/ui/ui_db_profile_backup.ui index 8b0110f0..e2db6654 100644 --- a/stdm/ui/ui_db_profile_backup.ui +++ b/stdm/ui/ui_db_profile_backup.ui @@ -156,6 +156,19 @@ + + + + + 75 + true + + + + TextLabel + + +