Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Ensure that (internal) files are closed in {save,load}ConfigFile #1146

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions lib/taurus/qt/qtcore/configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/taurus/qt/qtgui/table/qlogtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist =
py27-qt4
py{27,35,36,37}-qt5
py37-ps2
py37-qt5-docs
py38-qt5-docs
flake8

[testenv]
Expand All @@ -25,6 +25,7 @@ conda_deps=
py35: cython
py36: guiqwt
py37: guiqwt
py38: guiqwt
lxml
future
pillow
Expand Down Expand Up @@ -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

Expand Down