From 52f981da45054b90fbc3e172a4b0beef4fadcb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=2E=20Armando=20Sol=C3=A9?= Date: Thu, 8 Apr 2021 15:00:49 +0200 Subject: [PATCH 1/3] Verify if there is a risk of overwriting the input file. --- PyMca5/PyMcaGui/pymca/PyMcaBatch.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PyMca5/PyMcaGui/pymca/PyMcaBatch.py b/PyMca5/PyMcaGui/pymca/PyMcaBatch.py index fa2c9a7ec..b24b86a2e 100644 --- a/PyMca5/PyMcaGui/pymca/PyMcaBatch.py +++ b/PyMca5/PyMcaGui/pymca/PyMcaBatch.py @@ -1098,6 +1098,22 @@ def __goodOutputDir(self,outputdir): else: self.raise_() return False + if len(self.fileList) == 1: + if HDF5SUPPORT: + try: + if h5py.is_hdf5(self.fileList[0]): + if os.path.dirname(os.path.abspath(self.fileList[0])) == \ + os.path.abspath(outputdir): + msg = "Please specify a different output directory.\n" + msg += "Risk of overwritting input file." + qt.QMessageBox.critical(self,"ERROR", msg) + if QTVERSION < '4.0.0': + self.raiseW() + else: + self.raise_() + return False + except: + _logger.warning("Cannot verify suitability of output directory") return True def __getFileType(self,inputfile): From ce9da0412bb76d454d63b2d5f5a1bf00c0ed1c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=2E=20Armando=20Sol=C3=A9?= Date: Thu, 8 Apr 2021 15:15:28 +0200 Subject: [PATCH 2/3] Add missing file from PR #802 --- PyMca5/PyMcaPhysics/xrf/McaAdvancedFitBatch.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PyMca5/PyMcaPhysics/xrf/McaAdvancedFitBatch.py b/PyMca5/PyMcaPhysics/xrf/McaAdvancedFitBatch.py index 51b5f801d..2efd0df73 100644 --- a/PyMca5/PyMcaPhysics/xrf/McaAdvancedFitBatch.py +++ b/PyMca5/PyMcaPhysics/xrf/McaAdvancedFitBatch.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2020 European Synchrotron Radiation Facility +# Copyright (c) 2004-2021 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -330,8 +330,13 @@ def getFileHandle(self, inputfile): # if (len(self._filelist) == 1) && (self.mcaStep > 1) # it should attempt to avoid loading many times # the stack into memory in case of multiple processes + if len(self._filelist) == 1: + scanlist = self.selection.get("entry", None) + else: + scanlist = None return HDF5Stack1D.HDF5Stack1D(self._filelist, - self.selection) + self.selection, + scanlist=scanlist) except: raise From 4d7311aa39e19ca3d25fd1407ce281d4cba5d495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=2E=20Armando=20Sol=C3=A9?= Date: Thu, 8 Apr 2021 15:54:04 +0200 Subject: [PATCH 3/3] Make sure the dialog is wide enough when called from PyMcaBatch --- PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py b/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py index efbd0b651..60de33fee 100644 --- a/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py +++ b/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py @@ -124,6 +124,14 @@ def __init__(self, parent=None, mca=False, buttons=False): self._BUTTONS = buttons self.build() + def sizeHint(self): + originalHint = qt.QWidget.sizeHint(self) + if isinstance(self.parent(), qt.QDialog): + return qt.QSize(2 * originalHint.width(), + originalHint.height()) + else: + return qt.QSize(originalHint.width(), + originalHint.height()) def build(self): self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setContentsMargins(5, 5, 5, 0)