From 813f255b1d5e6007ed1448f3e1da7e5b42d99c03 Mon Sep 17 00:00:00 2001 From: Carlos Pascual Date: Wed, 2 Sep 2020 14:49:35 +0200 Subject: [PATCH 1/3] Ensure that (internal) files are closed in {save,load}ConfigFile The {save,load}ConfigFile methods accept either a file name or a file object as their argument. If a name is passed, a file object is internally created and opened, but it is not closed. This may cause trouble. Make sure the file is closed if it was internally created. Note that, in order not to break backwards compatibility, the file won't be closed if it was passed already as a file object (the responsibility for closing lies in the opener) --- .../qt/qtcore/configuration/configuration.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/taurus/qt/qtcore/configuration/configuration.py b/lib/taurus/qt/qtcore/configuration/configuration.py index fef4ef51e..411185f77 100644 --- a/lib/taurus/qt/qtcore/configuration/configuration.py +++ b/lib/taurus/qt/qtcore/configuration/configuration.py @@ -444,11 +444,13 @@ def saveConfigFile(self, ofile=None): ) if not ofile: return - if isinstance(ofile, string_types): - ofile = open(ofile, 'wb') - configdict = self.createConfig(allowUnpickable=False) self.info("Saving current settings in '%s'" % ofile.name) - pickle.dump(configdict, ofile) + configdict = self.createConfig(allowUnpickable=False) + if isinstance(ofile, string_types): + with open(ofile, 'wb') as ofile: + pickle.dump(configdict, ofile) + else: + pickle.dump(configdict, ofile) return ofile.name def loadConfigFile(self, ifile=None): @@ -466,8 +468,9 @@ def loadConfigFile(self, ifile=None): if not ifile: return if isinstance(ifile, string_types): - ifile = open(ifile, 'rb') - - configdict = pickle.load(ifile) + with open(ifile, 'rb') as ifile: + configdict = pickle.load(ifile) + else: + configdict = pickle.load(ifile) self.applyConfig(configdict) return ifile.name From f59a0a6a9df762131acd2cbfa5b3aebe56a233f0 Mon Sep 17 00:00:00 2001 From: Carlos Pascual Date: Mon, 14 Sep 2020 14:33:44 +0200 Subject: [PATCH 2/3] Move docs build to py38 As an attempt to work around an issue with installation of guiqwt in py37 with conda (which breaks the CI for the docs), update the environment in which the docs are built. Also, activate py38 tests in Travis --- .travis.yml | 5 +++-- tox.ini | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 708029f6a..2264e7db6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,9 @@ matrix: - env: TOXENV=py35-qt5 - env: TOXENV=py36-qt5 - env: TOXENV=py37-qt5 + - env: TOXENV=py38-qt5 - env: TOXENV=py37-ps2 - - env: TOXENV=py37-qt5-docs + - env: TOXENV=py38-qt5-docs allow_failures: #- env: TOXENV=flake8 #- env: TOXENV=py27-qt4 @@ -54,7 +55,7 @@ script: after_success: # Deploy docs to taurus-org/taurus-doc - - if [[ "$TOXENV" == "py37-qt5-docs" && "$TRAVIS_REPO_SLUG" == "taurus-org/taurus" ]]; then + - if [[ "$TOXENV" == "py38-qt5-docs" && "$TRAVIS_REPO_SLUG" == "taurus-org/taurus" ]]; then pip install doctr ; touch build/sphinx/html/.nojekyll; if [[ "${TRAVIS_BRANCH}" == "develop" ]]; then diff --git a/tox.ini b/tox.ini index ccdab2468..2004c844d 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist = py27-qt4 py{27,35,36,37}-qt5 py37-ps2 - py37-qt5-docs + py38-qt5-docs flake8 [testenv] @@ -25,6 +25,7 @@ conda_deps= py35: cython py36: guiqwt py37: guiqwt + py38: guiqwt lxml future pillow @@ -52,7 +53,7 @@ deps= commands= python -m pytest lib/taurus -[testenv:py37-qt5-docs] +[testenv:py38-qt5-docs] commands= sphinx-build -qW doc/source/ build/sphinx/html From 036951cb016a3ba9fe7aca2ec8961031b82f80eb Mon Sep 17 00:00:00 2001 From: Carlos Pascual Date: Mon, 14 Sep 2020 15:25:49 +0200 Subject: [PATCH 3/3] Fix TypeError in QLoggingTableModel for py38 py38 tests are failing due to an stricter type checking in QObject.startTimer() Cast float argument to int to fix it. --- lib/taurus/qt/qtgui/table/qlogtable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/taurus/qt/qtgui/table/qlogtable.py b/lib/taurus/qt/qtgui/table/qlogtable.py index bf9e691dd..18824608c 100644 --- a/lib/taurus/qt/qtgui/table/qlogtable.py +++ b/lib/taurus/qt/qtgui/table/qlogtable.py @@ -156,7 +156,7 @@ def __init__(self, parent=None, capacity=500000, freq=0.25): self._records = [] self._accumulated_records = [] Logger.addRootLogHandler(self) - self.startTimer(freq * 1000) + self.startTimer(int(freq * 1000)) # --------------------------------- # Qt.QAbstractTableModel overwrite