From dc9264cd6533301a5cd81446afe5c517bc4d926c Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 4 Mar 2025 13:35:10 +0100 Subject: [PATCH 1/5] git: Update project depencencies to fix #5. --- manifest.scm | 2 +- requirements.txt | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 requirements.txt diff --git a/manifest.scm b/manifest.scm index 3f7d914..5d35665 100644 --- a/manifest.scm +++ b/manifest.scm @@ -210,4 +210,4 @@ user-defined extensions).") "python-scipy" "python-scikit-learn" "python-pyqt@5" "python-pyqt5-sip" "python-numpy@1" "python-pandas@1.5" - "python-matplotlib")))) + "python-matplotlib" "python-odfpy")))) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..10a565e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,13 @@ +matplotlib==3.6.3 +numpy==1.23.5 +pandas==1.5.3 +PyQt5==5.15.9 +PyQt5-Qt5==5.15.2 +PyQt5-sip==12.11.0 +python-dateutil==2.8.2 +scikit-learn==1.2.1 +scipy==1.10.0 +pyqt-file-list-widget==0.0.1 +qtrangeslider==0.1.5 +astropy==6.1.7 +odfpy==1.4.1 From 769fd8581ecc9eaa1a41881d74e1867344f8677b Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Wed, 5 Mar 2025 09:25:32 +0100 Subject: [PATCH 2/5] Mainwindow: Fix #7 sqlitebrowser call with QProcess. --- View/mainwindow.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/View/mainwindow.py b/View/mainwindow.py index 3a9abe2..da13162 100644 --- a/View/mainwindow.py +++ b/View/mainwindow.py @@ -39,7 +39,7 @@ from View.about_window import AboutWindow import settings as stg import numpy as np -from subprocess import check_call, run +from subprocess import run import time @@ -269,7 +269,21 @@ class Ui_MainWindow(object): cc_kt.exec() def db_browser_for_sqlite(self): - check_call("/usr/bin/sqlitebrowser") + proc = QtCore.QProcess() + if stg.filename_save_as != "": + print(f"Set working directory to: '{stg.filename_save_as}'") + proc.setWorkingDirectory( + os.path.dirname(stg.filename_save_as) + ) + + proc.start("sqlitebrowser", []) + proc.waitForFinished() + + if proc.exitCode() != 0: + print(f"'sqlitebrowser' return with error code : {proc.exitCode()}") + print("-error------") + print(f"{proc.readAllStandardError()}") + print("------------") def about_window(self): print("about") From 9c5b76e45186ed63b9d143e1b03ce03f8f80e9aa Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Wed, 5 Mar 2025 09:40:18 +0100 Subject: [PATCH 3/5] Mainwindow: Fix #11 pdf file open, use QDesktopServices instead of open cmd. --- View/mainwindow.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/View/mainwindow.py b/View/mainwindow.py index da13162..74d3332 100644 --- a/View/mainwindow.py +++ b/View/mainwindow.py @@ -280,7 +280,7 @@ class Ui_MainWindow(object): proc.waitForFinished() if proc.exitCode() != 0: - print(f"'sqlitebrowser' return with error code : {proc.exitCode()}") + print(f"'sqlitebrowser' return with error code: {proc.exitCode()}") print("-error------") print(f"{proc.readAllStandardError()}") print("------------") @@ -290,17 +290,29 @@ class Ui_MainWindow(object): aw = AboutWindow() aw.exec() + def current_file_path(self, filename): + return os.path.abspath( + os.path.join( + os.path.dirname(__file__), + "..", filename + ) + ) + + def open_doc_file(self, filename): + QtGui.QDesktopServices.openUrl( + QtCore.QUrl( + f"file://{self.current_file_path(filename)}" + ) + ) + def user_manual(self): - open('AcouSed_UserManual.pdf') - run(["open", 'AcouSed_UserManual.pdf']) + self.open_doc_file('AcouSed_UserManual.pdf') def inversion_acoustic_theory(self): - open('Acoustic_Inversion_theory.pdf') - run(["open", 'Acoustic_Inversion_theory.pdf']) + self.open_doc_file('Acoustic_Inversion_theory.pdf') def tutorial_AQUAscat_software(self): - open('Tutorial_AQUAscat_software.pdf') - run(["open", 'Tutorial_AQUAscat_software.pdf']) + self.open_doc_file('Tutorial_AQUAscat_software.pdf') def export_table_of_acoustic_BS_values_to_excel_or_libreOfficeCalc_file(self): From 3e5ef5d2bc5faffffbe5abda3a72da8889ebaaad Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Wed, 5 Mar 2025 11:22:06 +0100 Subject: [PATCH 4/5] Mainwindow: Revert 'sqlitebrowser' QProcess to Popen (run as async). --- View/mainwindow.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/View/mainwindow.py b/View/mainwindow.py index 74d3332..7f64019 100644 --- a/View/mainwindow.py +++ b/View/mainwindow.py @@ -39,7 +39,7 @@ from View.about_window import AboutWindow import settings as stg import numpy as np -from subprocess import run +from subprocess import Popen import time @@ -269,21 +269,7 @@ class Ui_MainWindow(object): cc_kt.exec() def db_browser_for_sqlite(self): - proc = QtCore.QProcess() - if stg.filename_save_as != "": - print(f"Set working directory to: '{stg.filename_save_as}'") - proc.setWorkingDirectory( - os.path.dirname(stg.filename_save_as) - ) - - proc.start("sqlitebrowser", []) - proc.waitForFinished() - - if proc.exitCode() != 0: - print(f"'sqlitebrowser' return with error code: {proc.exitCode()}") - print("-error------") - print(f"{proc.readAllStandardError()}") - print("------------") + Popen(f"sqlitebrowser", shell=True) def about_window(self): print("about") From 1c3f6fb0155b1a125eed70d6af317b3d247b5936 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Wed, 5 Mar 2025 14:53:29 +0100 Subject: [PATCH 5/5] main: Add 'logging' basic config. --- main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.py b/main.py index 0972456..9d45c0d 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import sys +import logging import traceback from PyQt5.QtWidgets import QApplication, QMainWindow @@ -26,6 +27,13 @@ import matplotlib.pyplot as plt PERCENT_SCREEN_SIZE = 0.85 _translate = QCoreApplication.translate +logging.basicConfig( + level=logging.DEBUG, + format=('[AcouSed][%(levelname)s] %(message)s') +) + +logger = logging.getLogger() +logger.setLevel(logging.INFO) class MainApplication(QMainWindow): @@ -90,6 +98,9 @@ class MainApplication(QMainWindow): # ---------------- Text File Error ----------------- except Exception as e: + logger.error(str(e)) + logger.error(traceback.format_exc()) + with open("Error_file.txt", "w", encoding="utf-8") as sortie: sortie.write(str(e)) sortie.write(traceback.format_exc())