diff --git a/src/View/BoundaryCondition/Edit/Table.py b/src/View/BoundaryCondition/Edit/Table.py index 6c94b9282d27a0e40f9043bef3a30c7eae90a2b8..dfe805e1c60ae19e067463b2ed060303effc95e5 100644 --- a/src/View/BoundaryCondition/Edit/Table.py +++ b/src/View/BoundaryCondition/Edit/Table.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from datetime import date, time, datetime, timedelta from tools import trace, timer @@ -32,6 +34,7 @@ from View.BoundaryCondition.Edit.translate import * _translate = QCoreApplication.translate +logger = logging.getLogger() class ExtendedTimeEdit(AWidget): def __init__(self, parent=None): @@ -108,7 +111,7 @@ class ExTimeDelegate(QItemDelegate): self.editor = ExtendedDateTimeEdit(parent=parent) value = index.data(Qt.DisplayRole) self.editor.set_time(value) - print(value) + logger.debug(str(value)) return self.editor def setModelData(self, editor, model, index): @@ -116,7 +119,7 @@ class ExTimeDelegate(QItemDelegate): if self._mode == "time": model.setData(index, int(time.total_seconds())) else: - print(time.timestamp()) + logger.debug(str(time.timestamp())) model.setData(index, int(time.timestamp())) editor.close() editor.deleteLater() diff --git a/src/View/BoundaryCondition/Window.py b/src/View/BoundaryCondition/Window.py index 62d823d71ef69518663acaf24a6748963b605f96..2e7dd43025a1937a378b77268d6b2121ad20f415 100644 --- a/src/View/BoundaryCondition/Window.py +++ b/src/View/BoundaryCondition/Window.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import trace, timer from View.ASubWindow import ASubMainWindow @@ -43,6 +45,7 @@ from View.BoundaryCondition.Edit.Window import EditBoundaryConditionWindow _translate = QCoreApplication.translate +logger = logging.getLogger() class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow): def __init__(self, title="Boundary conditions", study=None, parent=None): @@ -184,10 +187,10 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow): self._table[tab].move_down(row) def copy(self): - print("TODO") + logger.info("TODO: copy") def paste(self): - print("TODO") + logger.info("TODO: paste") def undo(self): tab = self.current_tab() diff --git a/src/View/Geometry/PlotAC.py b/src/View/Geometry/PlotAC.py index da5f1149cf89dacb35d5d6c4254e97e8e50f82cf..9709d3bc740597841d2e6107708c88b562fea43f 100644 --- a/src/View/Geometry/PlotAC.py +++ b/src/View/Geometry/PlotAC.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import timer from View.Plot.APlot import APlot @@ -9,6 +11,8 @@ from PyQt5.QtCore import ( _translate = QCoreApplication.translate +logger = logging.getLogger() + class PlotAC(APlot): def __init__(self, canvas=None, data=None, toolbar=None, plot_xy=None): super(PlotAC, self).__init__( @@ -284,7 +288,7 @@ class PlotAC(APlot): self.color_incomplete_gl[lincomplete.index(txt)] ) except Exception as e: - print(f"{e}") + logger.warning(f"{e}") self.canvas.figure.canvas.draw_idle() diff --git a/src/View/Geometry/PlotKPC.py b/src/View/Geometry/PlotKPC.py index d48381c4cfadc0cdc01e70666b4be1f87e35703b..f3e883f376716aa156228efdb635962c90847562 100644 --- a/src/View/Geometry/PlotKPC.py +++ b/src/View/Geometry/PlotKPC.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import timer from View.Plot.APlot import APlot @@ -9,6 +11,8 @@ from PyQt5.QtCore import ( _translate = QCoreApplication.translate +logger = logging.getLogger() + class PlotKPC(APlot): def __init__(self, canvas=None, data=None, toolbar=None, display_current=True): @@ -214,7 +218,7 @@ class PlotKPC(APlot): kp, z_complete[i] ) except Exception as e: - print(f"Failed to update graphic 2: {e}") + logger.warning(f"Failed to update graphic KPC: {e}") self.canvas.axes.autoscale_view(True, True, True) self.canvas.figure.canvas.draw_idle() diff --git a/src/View/Geometry/Profile/Plot.py b/src/View/Geometry/Profile/Plot.py index 100426f871206f3c4733d00ec174be424ee06f9b..2dc7f52276ca37918b48bb486bdc04a852b97115 100644 --- a/src/View/Geometry/Profile/Plot.py +++ b/src/View/Geometry/Profile/Plot.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import timer, trace from View.Plot.APlot import APlot from View.Plot.mpl_canvas_onpick_event import OnpickEvent @@ -10,6 +12,8 @@ from PyQt5.QtCore import ( _translate = QCoreApplication.translate +logger = logging.getLogger() + class Plot(APlot): def __init__(self, canvas=None, data=None, toolbar=None, table=None): super(Plot, self).__init__( @@ -123,5 +127,5 @@ class Plot(APlot): @timer def update(self, ind=None): - print("TODO: implemente update") + logger.info("TODO: implemente update") self.draw() diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 0428a006578ffc819b1d456ab876d8d49711dd3a..37f83aff3aeaaad6781e7603e805e510cecf54e9 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -150,8 +150,8 @@ class GeometryWindow(QMainWindow, WindowToolKit): msg_box.setStandardButtons(QtWidgets.QMessageBox.Ok) return_value = msg_box.exec() - if return_value == QtWidgets.QMessageBox.Ok: - print('OK clicked') + # if return_value == QtWidgets.QMessageBox.Ok: + # print('OK clicked') def edit_profile(self): self.tableView.model().blockSignals(True) diff --git a/src/View/InitialConditions/Window.py b/src/View/InitialConditions/Window.py index 22cade03e426052fb4589194b74d78ff1b0da151..358228119b599fe0c0317a5a51f9ce5bb1939729 100644 --- a/src/View/InitialConditions/Window.py +++ b/src/View/InitialConditions/Window.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import trace, timer from View.ASubWindow import ASubMainWindow @@ -39,6 +41,7 @@ from View.InitialConditions.DialogDischarge import DischargeDialog _translate = QCoreApplication.translate +logger = logging.getLogger() class InitialConditionsWindow(ASubMainWindow, ListedSubWindow): def __init__(self, title="Initial condition", @@ -197,11 +200,11 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow): self._update_plot() def copy(self): - print("TODO") + logger.info("TODO: copy") self._update_plot() def paste(self): - print("TODO") + logger.info("TODO: paste") self._update_plot() def undo(self): diff --git a/src/View/LateralContribution/Edit/Table.py b/src/View/LateralContribution/Edit/Table.py index e3e74483e3531c2b262fea08be83af0a4294949d..4101995ccf279b8c288f35a459fecead49d082fd 100644 --- a/src/View/LateralContribution/Edit/Table.py +++ b/src/View/LateralContribution/Edit/Table.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import logging from datetime import date, time, datetime, timedelta from tools import trace, timer @@ -31,6 +32,7 @@ from View.LateralContribution.Edit.translate import * _translate = QCoreApplication.translate +logger = logging.getLogger() class ExtendedTimeEdit(AWidget): def __init__(self, parent=None): @@ -107,7 +109,7 @@ class ExTimeDelegate(QItemDelegate): self.editor = ExtendedDateTimeEdit(parent=parent) value = index.data(Qt.DisplayRole) self.editor.set_time(value) - print(value) + logger.debug(str(value)) return self.editor def setModelData(self, editor, model, index): @@ -115,7 +117,7 @@ class ExTimeDelegate(QItemDelegate): if self._mode == "time": model.setData(index, int(time.total_seconds())) else: - print(time.timestamp()) + logger.debug(str(time.timestamp())) model.setData(index, int(time.timestamp())) editor.close() editor.deleteLater() diff --git a/src/View/LateralContribution/Window.py b/src/View/LateralContribution/Window.py index a6b7b03e0ec081e746cd45931618aed34a907abd..b87e9968050cb9ca75e67033d3739bd0b2535fed 100644 --- a/src/View/LateralContribution/Window.py +++ b/src/View/LateralContribution/Window.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import trace, timer from View.ASubWindow import ASubMainWindow @@ -43,6 +45,7 @@ from View.LateralContribution.Edit.Window import EditLateralContributionWindow _translate = QCoreApplication.translate +logger = logging.getLogger() class LateralContributionWindow(ASubMainWindow, ListedSubWindow): def __init__(self, title="Lateral contribution", study=None, parent=None): @@ -226,11 +229,11 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow): self._set_current_reach() def copy(self): - print("TODO") + logger.info("TODO: copy") self._set_current_reach() def paste(self): - print("TODO") + logger.info("TODO: paste") self._set_current_reach() def undo(self): diff --git a/src/View/Plot/mpl_canvas_onpick_event.py b/src/View/Plot/mpl_canvas_onpick_event.py index 6415aee70d0437021eb7a43729e7a4ac060800a6..010959bc699d205365ff51b05e112cfa2a2b955b 100644 --- a/src/View/Plot/mpl_canvas_onpick_event.py +++ b/src/View/Plot/mpl_canvas_onpick_event.py @@ -1,3 +1,5 @@ +import logging + from time import time import numpy as np @@ -6,6 +8,7 @@ from PyQt5.QtCore import QItemSelectionModel, Qt from PyQt5.QtWidgets import QApplication from shapely.geometry.polygon import Polygon as ShapelyPolygon +logger = logging.getLogger() class OnpickEvent(object): def __init__(self, ax, x, y, x_carto, y_carto, tableview=None): @@ -105,14 +108,13 @@ class OnpickEvent(object): [pl[0].set_data([], []) for pl in self.pt if len(self.pt) > 1] except: - print("Probleme de mise à jour ... update_select_point_point()") + logger.info("update_select_point_point: Update issue") try: self.update_select_point_point_bis(self.x[row], self.y[row]) except: - print("index introuvable pour la mise à jour de l'affichage de la sélection du point." - "Editer les cases en 'nan'.") + logger.info("update_select_point_point_bis: Update issue, possible index missing") self.ax.figure.canvas.draw_idle() diff --git a/src/View/Plot/navigation_toolbar_2qt.py b/src/View/Plot/navigation_toolbar_2qt.py index d07386de6d05d4c251613940c5c3803184a995d1..371864502ffcfea4b977e91bedb351d34b5584de 100644 --- a/src/View/Plot/navigation_toolbar_2qt.py +++ b/src/View/Plot/navigation_toolbar_2qt.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import logging import matplotlib as mpl from matplotlib.backends import qt_compat from PyQt5 import QtCore, QtGui, QtWidgets @@ -10,6 +11,7 @@ from PyQt5.QtCore import pyqtSignal, QSize _translate = QtCore.QCoreApplication.translate +logger = logging.getLogger() file_path = os.path.abspath(os.path.dirname(__file__)) @@ -123,7 +125,7 @@ class PamHyrNavigationToolbar2QT(NavigationToolbar2QT): ) def cursor1(self): - print("TODO") + logger.info("TODO: cursor1") def isometric_view(self): self.my_canvas.axes.axis("equal") diff --git a/src/View/Sections/Window.py b/src/View/Sections/Window.py index 5690b4729ab0575b0dc81d8db0b5beae40a917e4..63eb4b7e4d6b26325e1b29ecabeb549c05ac4e59 100644 --- a/src/View/Sections/Window.py +++ b/src/View/Sections/Window.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import trace, timer from View.ASubWindow import ASubMainWindow @@ -39,6 +41,8 @@ from View.Stricklers.Window import StricklersWindow _translate = QCoreApplication.translate +logger = logging.getLogger() + class SectionsWindow(ASubMainWindow, ListedSubWindow): def __init__(self, title="Sections", study=None, parent=None): self._study = study @@ -214,10 +218,10 @@ class SectionsWindow(ASubMainWindow, ListedSubWindow): self._table.move_down(row) def copy(self): - print("TODO") + logger.info("TODO: copy") def paste(self): - print("TODO") + logger.info("TODO: paste") def undo(self): self._table.undo() diff --git a/src/View/SolverParameters/Window.py b/src/View/SolverParameters/Window.py index e2ceae2b495a434971698eab9b97466283cd28bc..4e154a54b2caf130bea146db9179f73f25e55226 100644 --- a/src/View/SolverParameters/Window.py +++ b/src/View/SolverParameters/Window.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import trace, timer from View.ASubWindow import ASubMainWindow @@ -31,6 +33,7 @@ from Solver.Solvers import solver_long_name, solver_type_list _translate = QCoreApplication.translate +logger = logging.getLogger() class SolverParametersWindow(ASubMainWindow, ListedSubWindow): def __init__(self, title="Solver parameters", study=None, parent=None): @@ -120,7 +123,7 @@ class SolverParametersWindow(ASubMainWindow, ListedSubWindow): self._set_current_reach() def copy(self): - print("TODO") + logger.info("TODO: copy") def paste(self): - print("TODO") + logger.info("TODO: paste") diff --git a/src/View/Stricklers/Window.py b/src/View/Stricklers/Window.py index be02f4e7649abff99a7ec470f74004e2b68cdbca..1d2bfe43bbd710974ef8cbd539463e1897bb32ae 100644 --- a/src/View/Stricklers/Window.py +++ b/src/View/Stricklers/Window.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import logging + from tools import trace, timer from View.ASubWindow import ASubMainWindow @@ -29,6 +31,7 @@ from View.Stricklers.Table import TableModel _translate = QCoreApplication.translate +logger = logging.getLogger() class StricklersWindow(ASubMainWindow, ListedSubWindow): def __init__(self, title="Stricklers", study=None, config=None, parent=None): @@ -115,10 +118,10 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow): self._table['study'].sort(False) def copy(self): - print("TODO") + logger.info("TODO: copy") def paste(self): - print("TODO") + logger.info("TODO: paste") def undo(self): self._table['study'].undo() diff --git a/src/tools.py b/src/tools.py index 701dd23686b18d68c3f0fb1b74aa6b962ab389bb..0e7a48d6e872a164e1f389e450e519f42a43177d 100644 --- a/src/tools.py +++ b/src/tools.py @@ -53,7 +53,7 @@ def display_timers(): for t in range(fmax + 26): head += "-" head += "+" - print(head) + logger.debug(head) lst = sorted( map( @@ -67,13 +67,13 @@ def display_timers(): for func, time, calls in lst: name = (f"{Fore.BLUE}{func.__module__}{Style.RESET_ALL}" + f".{Style.BRIGHT}{Fore.GREEN}{func.__qualname__:<{fmax - len(func.__module__)}}{Style.RESET_ALL}") - print(f" | {name} | {time:>10.6f} sec | {calls:>5} calls |") + logger.debug(f" | {name} | {time:>10.6f} sec | {calls:>5} calls |") tail = " +--" for t in range(fmax + 32): tail += "-" tail += "+" - print(tail) + logger.debug(tail) def timer(func): """Function wrapper to register function runtime""" @@ -85,7 +85,7 @@ def timer(func): try: value = func(*args, **kwargs) except Exception as e: - print(f"[{Fore.RED}ERROR{Style.RESET_ALL}]" + + logger.debug(f"[{Fore.RED}ERROR{Style.RESET_ALL}]" + f"[{func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}]: " + f"{Fore.RED}{e}{Style.RESET_ALL}") traceback.print_exc() @@ -113,13 +113,13 @@ def trace(func): t = time.ctime() head = f"[{Fore.BLUE}TRACE{Style.RESET_ALL}]" c = f"{head}[{t}] Call {func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}({args}, {kwargs})" - print(c) + logger.debug(c) value = func(*args, **kwargs) t = time.ctime() r = f"{head}[{t}] Return {func.__module__}.{Fore.GREEN}{func.__qualname__}{Style.RESET_ALL}: {value}" - print(r) + logger.debug(r) return value