From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>, Jeff Cody <jcody@redhat.com>,
qemu-devel@nongnu.org
Cc: stefanha@redhat.com, kwolf@redhat.com, armbru@redhat.com,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove' for python tests
Date: Wed, 30 Aug 2017 18:21:32 -0400 [thread overview]
Message-ID: <4c0570ce-8632-dcbc-86d5-a84be57ce0d7@redhat.com> (raw)
In-Reply-To: <627b615e-b42d-f59c-7b9f-e02fd139a85b@redhat.com>
On 08/30/2017 02:13 PM, Eric Blake wrote:
> On 08/30/2017 11:52 AM, Jeff Cody wrote:
>> 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 <jcody@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:
>
> I'm assuming this works for both python 2 and 3?
>
Appears to be python2 specific syntax, actually. using "as error"
appears to work in both 2.7 and 3.whatever, and according to
http://python3porting.com/differences.html will work in 2.6 too.
>> + if error.errno != errno.ENOENT:
>> + raise
>> +
>
> Weak, since I'm not the strongest at python, but you can add:
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
next prev parent reply other threads:[~2017-08-30 22:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 16:52 [Qemu-devel] [PATCH v3 0/5] qemu-iotests: place output in unique dir Jeff Cody
2017-08-30 16:52 ` [Qemu-devel] [PATCH v3 1/5] qemu-iotests: set TEST_DIR to a unique dir for each test Jeff Cody
2017-08-30 22:15 ` John Snow
2017-08-30 22:39 ` Jeff Cody
2017-08-30 16:52 ` [Qemu-devel] [PATCH v3 2/5] qemu-iotests: remove file cleanup from bash tests Jeff Cody
2017-08-30 22:17 ` John Snow
2017-09-05 11:17 ` Kevin Wolf
2017-08-30 16:52 ` [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove' for python tests Jeff Cody
2017-08-30 18:13 ` Eric Blake
2017-08-30 22:21 ` John Snow [this message]
2017-08-30 16:52 ` [Qemu-devel] [PATCH v3 4/5] qemu-iotests: make python tests attempt to leave intermediate files Jeff Cody
2017-08-30 18:33 ` Eric Blake
2017-08-30 22:28 ` John Snow
2017-08-30 22:35 ` Eric Blake
2017-08-30 22:40 ` John Snow
2017-08-31 15:39 ` Stefan Hajnoczi
2017-08-31 15:47 ` Jeff Cody
2017-09-04 9:51 ` Stefan Hajnoczi
2017-09-04 14:42 ` Jeff Cody
2017-08-30 16:52 ` [Qemu-devel] [PATCH v3 5/5] qemu-iotests: add option to save temp files on error Jeff Cody
2017-08-30 18:49 ` Eric Blake
2017-08-30 22:38 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c0570ce-8632-dcbc-86d5-a84be57ce0d7@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).