From 8b3baf433f328d6f7e1cf378f2570e3975acd27e Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Mon, 27 Nov 2023 14:31:04 +0100 Subject: [PATCH 1/3] Solver run: Used merged channels to get stderr. --- src/View/RunSolver/Window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/View/RunSolver/Window.py b/src/View/RunSolver/Window.py index c940b6ac..96ada16e 100644 --- a/src/View/RunSolver/Window.py +++ b/src/View/RunSolver/Window.py @@ -156,6 +156,7 @@ class SolverLogWindow(PamhyrWindow): def new_process(self, parent): new = QProcess(parent) new.setWorkingDirectory(self._workdir) + new.setProcessChannelMode(QProcess.MergedChannels) return new def setup_action(self): From 51858597cdcb459edf0d20a15d1e43af5a0598fe Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Mon, 27 Nov 2023 14:49:42 +0100 Subject: [PATCH 2/3] Mage: ST export minor change. --- src/Solver/Mage.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Solver/Mage.py b/src/Solver/Mage.py index 4afaf59f..3a785e4e 100644 --- a/src/Solver/Mage.py +++ b/src/Solver/Mage.py @@ -200,9 +200,9 @@ class Mage(CommandLineSolver): wfile.write(f"{num}{c1}{c2}{t} {kp} {pname} {sediment}\n") def _export_ST_point_line(self, wfile, files, point): - x = f"{point.x:<12f}"[0:12] - y = f"{point.y:<12f}"[0:12] - z = f"{point.z:<12f}"[0:12] + x = f"{point.x:<12.4f}"[0:12] + y = f"{point.y:<12.4f}"[0:12] + z = f"{point.z:<12.4f}"[0:12] n = f"{point.name:<3}" # Generate sediment additional data if available From d891c9783db6adbaf32aee8ac60dc7738bd1a67a Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Mon, 27 Nov 2023 16:58:46 +0100 Subject: [PATCH 3/3] Model: Fix possible data removing durring save. --- src/Model/Friction/FrictionList.py | 4 +++- src/Model/Geometry/ProfileXYZ.py | 4 +++- src/Model/Geometry/Reach.py | 5 +++-- src/Model/InitialConditions/InitialConditionsDict.py | 10 +++++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Model/Friction/FrictionList.py b/src/Model/Friction/FrictionList.py index 6f585fcc..20c33197 100644 --- a/src/Model/Friction/FrictionList.py +++ b/src/Model/Friction/FrictionList.py @@ -57,12 +57,14 @@ class FrictionList(PamhyrModelList): return new def _db_save(self, execute, data=None): + frictions = self.lst + reach = data["reach"] execute(f"DELETE FROM friction WHERE reach = {reach.id}") ok = True ind = 0 - for friction in self._lst: + for friction in frictions: data["ind"] = ind ok &= friction._db_save(execute, data=data) ind += 1 diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index f19100bc..4375d18c 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -173,11 +173,13 @@ class ProfileXYZ(Profile, SQLSubModel): ) execute(sql) + points = self.points + data["profile"] = self execute(f"DELETE FROM geometry_pointXYZ WHERE profile = {self.id}") ind = 0 - for point in self.points: + for point in points: data["ind"] = ind ok &= point._db_save(execute, data) ind += 1 diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py index b6a5952d..c3ee413c 100644 --- a/src/Model/Geometry/Reach.py +++ b/src/Model/Geometry/Reach.py @@ -71,15 +71,16 @@ class Reach(SQLSubModel): return new def _db_save(self, execute, data=None): + profiles = self.profiles + # Delete old data execute(f"DELETE FROM geometry_profileXYZ WHERE reach = {self.id}") - # execute(f"DELETE FROM geometry_pointXYZ") if data is None: data = {} ind = 0 - for profile in self.profiles: + for profile in profiles: data["ind"] = ind profile._db_save(execute, data) ind += 1 diff --git a/src/Model/InitialConditions/InitialConditionsDict.py b/src/Model/InitialConditions/InitialConditionsDict.py index 86655e36..0cc75293 100644 --- a/src/Model/InitialConditions/InitialConditionsDict.py +++ b/src/Model/InitialConditions/InitialConditionsDict.py @@ -55,14 +55,18 @@ class InitialConditionsDict(PamhyrModelDict): if data is None: data = {} - execute("DELETE FROM initial_conditions") - - for reach in self._dict: + ics = self._dict + for reach in ics: data["reach"] = reach v = self._dict[reach] if isinstance(v, types.GeneratorType): self._dict[reach] = list(v)[0] + execute( + "DELETE FROM initial_conditions " + + f"WHERE reach = '{reach.id}'" + ) + ok &= self._dict[reach]._db_save(execute, data) return ok