Add a function to attempt to 'blindly' remove a file, without throwing an error if the file doesn't exist.
Signed-off-by: Jeff Cody <jc...@redhat.com> --- tests/qemu-iotests/iotests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7233983..a2088c7 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -57,6 +57,13 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') debug = False +def blind_remove(filename): + try: + os.remove(filename) + except OSError, error: + if error.errno != errno.ENOENT: + raise + def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull = open('/dev/null', 'r+') -- 2.9.5