Import 2017-06-07 23:51:09: master bd4ccceb

Author Committer Branch Timestamp Parent
msmolens msmolens master 2016-06-10 13:43:56 master 1f4fa0a8
Changeset

BUG: Fix py_nomainwindow_SlicerOptionIgnoreSlicerRCTest

This commit fixes an error when running py_nomainwindow_SlicerOptionIgnoreSlicerRCTest. On Windows the error message is similar to:

  File "C:/D/N/Slicer-0/Applications/SlicerApp/Testing/Python/SlicerOptionIgnoreSlicerRCTest.py", line 79, in <module>
os.remove(slicerrc)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'c:\\users\\slicer~1\\appdata\\local\\temp\\tmpqu7b2u'

The issue is that tempfile.mkstemp() returns an OS-level handle to an open file.
Using Python's open() function on the filename opens the file a second time.
Therefore, an error occurs when attempting to remove the file, because the
handle opened by tempfile.mkstemp() has not been closed.

Replacing open() with os.fdopen() is one way to fix the issue. In that case, the
file is opened only once.

From: Max Smolens <max.smolens@kitware.com>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@25179 3bd1e089-480b-0410-8dfb-8563597acbee

mod - Applications/SlicerApp/Testing/Python/SlicerOptionIgnoreSlicerRCTest.py Diff File