[{"id":1760395,"web_url":"http://patchwork.ozlabs.org/comment/1760395/","msgid":"<627b615e-b42d-f59c-7b9f-e02fd139a85b@redhat.com>","list_archive_url":null,"date":"2017-08-30T18:13:44","subject":"Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove'\n\tfor python tests","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 08/30/2017 11:52 AM, Jeff Cody wrote:\n> Add a function to attempt to 'blindly' remove a file, without\n> throwing an error if the file doesn't exist.\n> \n> Signed-off-by: Jeff Cody <jcody@redhat.com>\n> ---\n>  tests/qemu-iotests/iotests.py | 7 +++++++\n>  1 file changed, 7 insertions(+)\n> \n> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py\n> index 7233983..a2088c7 100644\n> --- a/tests/qemu-iotests/iotests.py\n> +++ b/tests/qemu-iotests/iotests.py\n> @@ -57,6 +57,13 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')\n>  socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')\n>  debug = False\n>  \n> +def blind_remove(filename):\n> +    try:\n> +        os.remove(filename)\n> +    except OSError, error:\n\nI'm assuming this works for both python 2 and 3?\n\n> +        if error.errno != errno.ENOENT:\n> +            raise\n> +\n\nWeak, since I'm not the strongest at python, but you can add:\nReviewed-by: Eric Blake <eblake@redhat.com>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjDH763RCz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 04:16:51 +1000 (AEST)","from localhost ([::1]:52089 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dn7Xk-00025g-KS\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 14:16:48 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:55337)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dn7Uz-00082j-Ri\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 14:13:58 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dn7Uy-0003aV-KR\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 14:13:57 -0400","from mx1.redhat.com ([209.132.183.28]:39748)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dn7Us-0003Y6-Qn; Wed, 30 Aug 2017 14:13:51 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id D8E29356D9;\n\tWed, 30 Aug 2017 18:13:49 +0000 (UTC)","from [10.10.122.186] (ovpn-122-186.rdu2.redhat.com [10.10.122.186])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 5A3C45D722;\n\tWed, 30 Aug 2017 18:13:45 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com D8E29356D9","To":"Jeff Cody <jcody@redhat.com>, qemu-devel@nongnu.org","References":"<cover.1504111803.git.jcody@redhat.com>\n\t<aea3a5d63b6937d8bd87afb3741db6c09ea7436e.1504111803.git.jcody@redhat.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<627b615e-b42d-f59c-7b9f-e02fd139a85b@redhat.com>","Date":"Wed, 30 Aug 2017 13:13:44 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<aea3a5d63b6937d8bd87afb3741db6c09ea7436e.1504111803.git.jcody@redhat.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"HMINxs5hu1J01tMeAAT9IOu1tOKOXD8Vm\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tWed, 30 Aug 2017 18:13:50 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove'\n\tfor python tests","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"stefanha@redhat.com, kwolf@redhat.com, jsnow@redhat.com,\n\tarmbru@redhat.com, qemu-block@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1760537,"web_url":"http://patchwork.ozlabs.org/comment/1760537/","msgid":"<4c0570ce-8632-dcbc-86d5-a84be57ce0d7@redhat.com>","list_archive_url":null,"date":"2017-08-30T22:21:32","subject":"Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove'\n\tfor python tests","submitter":{"id":64343,"url":"http://patchwork.ozlabs.org/api/people/64343/","name":"John Snow","email":"jsnow@redhat.com"},"content":"On 08/30/2017 02:13 PM, Eric Blake wrote:\n> On 08/30/2017 11:52 AM, Jeff Cody wrote:\n>> Add a function to attempt to 'blindly' remove a file, without\n>> throwing an error if the file doesn't exist.\n>>\n>> Signed-off-by: Jeff Cody <jcody@redhat.com>\n>> ---\n>>  tests/qemu-iotests/iotests.py | 7 +++++++\n>>  1 file changed, 7 insertions(+)\n>>\n>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py\n>> index 7233983..a2088c7 100644\n>> --- a/tests/qemu-iotests/iotests.py\n>> +++ b/tests/qemu-iotests/iotests.py\n>> @@ -57,6 +57,13 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE')\n>>  socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')\n>>  debug = False\n>>  \n>> +def blind_remove(filename):\n>> +    try:\n>> +        os.remove(filename)\n>> +    except OSError, error:\n> \n> I'm assuming this works for both python 2 and 3?\n> \n\nAppears to be python2 specific syntax, actually. using \"as error\"\nappears to work in both 2.7 and 3.whatever, and according to\nhttp://python3porting.com/differences.html will work in 2.6 too.\n\n>> +        if error.errno != errno.ENOENT:\n>> +            raise\n>> +\n> \n> Weak, since I'm not the strongest at python, but you can add:\n> Reviewed-by: Eric Blake <eblake@redhat.com>\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jsnow@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjKkN14w3z9sN5\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 08:22:18 +1000 (AEST)","from localhost ([::1]:53006 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnBNI-00088Z-Hu\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 18:22:16 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:55599)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dnBMl-000871-59\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 18:21:44 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dnBMj-0008Qu-Ta\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 18:21:43 -0400","from mx1.redhat.com ([209.132.183.28]:40082)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <jsnow@redhat.com>)\n\tid 1dnBMf-0008Pz-CL; Wed, 30 Aug 2017 18:21:37 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 0D024C04B924;\n\tWed, 30 Aug 2017 22:21:36 +0000 (UTC)","from [10.18.17.130] (dhcp-17-130.bos.redhat.com [10.18.17.130])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 6C63A5DD64;\n\tWed, 30 Aug 2017 22:21:33 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 0D024C04B924","To":"Eric Blake <eblake@redhat.com>, Jeff Cody <jcody@redhat.com>,\n\tqemu-devel@nongnu.org","References":"<cover.1504111803.git.jcody@redhat.com>\n\t<aea3a5d63b6937d8bd87afb3741db6c09ea7436e.1504111803.git.jcody@redhat.com>\n\t<627b615e-b42d-f59c-7b9f-e02fd139a85b@redhat.com>","From":"John Snow <jsnow@redhat.com>","Message-ID":"<4c0570ce-8632-dcbc-86d5-a84be57ce0d7@redhat.com>","Date":"Wed, 30 Aug 2017 18:21:32 -0400","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<627b615e-b42d-f59c-7b9f-e02fd139a85b@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tWed, 30 Aug 2017 22:21:36 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: add 'blind_remove'\n\tfor python tests","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"kwolf@redhat.com, qemu-block@nongnu.org, armbru@redhat.com,\n\tstefanha@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]