pamhyr: End switch print to logging.

results
Pierre-Antoine Rouby 2023-07-07 10:50:17 +02:00
parent a8bd871f94
commit 504ef7ec48
15 changed files with 71 additions and 31 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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):

View File

@ -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()

View File

@ -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):

View File

@ -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()

View File

@ -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")

View File

@ -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()

View File

@ -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")

View File

@ -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()

View File

@ -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