[{"id":3668943,"web_url":"http://patchwork.ozlabs.org/comment/3668943/","msgid":"<ef81a4fd-91df-4028-b1d0-0f8768d7e642@linaro.org>","list_archive_url":null,"date":"2026-03-25T10:04:14","subject":"Re: [PATCH 3/4] tests/functional/qemu_test: Split huge fetch()\n function in asset.py","submitter":{"id":85046,"url":"http://patchwork.ozlabs.org/api/people/85046/","name":"Philippe Mathieu-Daudé","email":"philmd@linaro.org"},"content":"On 24/3/26 17:35, Thomas Huth wrote:\n> From: Thomas Huth <thuth@redhat.com>\n> \n> The fetch() function has become really huge and pylint complains about\n> that. Extract the internal retry-three-times-download loop into a\n> separate function to make it a little bit more readable and to make\n> pylint happy about this file again.\n> \n> Signed-off-by: Thomas Huth <thuth@redhat.com>\n> ---\n>   tests/functional/qemu_test/asset.py | 43 ++++++++++++++++-------------\n>   1 file changed, 24 insertions(+), 19 deletions(-)\n\n\n> +    def _try_to_fetch(self, tmp_cache_file):\n>           for _retries in range(3):\n\nWhile here, pass the number as argument to the new function?\n\nAnyhow,\nReviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>\n\n> +    def fetch(self):\n> +        '''Download the asset from the internet'''\n> +        if not self.cache_dir.exists():\n> +            self.cache_dir.mkdir(parents=True, exist_ok=True)\n> +\n> +        if self.valid():\n> +            self.log.debug(\"Using cached asset %s for %s\",\n> +                           self.cache_file, self.url)\n> +            self._save_time_stamp()\n> +            return str(self.cache_file)\n> +\n> +        if not self.fetchable():\n> +            raise AssetError(self,\n> +                             \"Asset cache is invalid and downloads disabled\")\n> +\n> +        self.log.info(\"Downloading %s to %s...\", self.url, self.cache_file)\n> +        tmp_cache_file = self.cache_file.with_suffix(\".download\")\n> +\n> +        if self._try_to_fetch(tmp_cache_file):\n> +            return str(self.cache_file)\n>   \n>           if not os.path.exists(tmp_cache_file):\n>               raise AssetError(self, \"Download retries exceeded\", transient=True)","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=C4IACY3Y;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgjFN3g3Cz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 21:04:56 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w5L6J-0004rT-G2; Wed, 25 Mar 2026 06:04:37 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1w5L63-0004ov-O6\n for qemu-devel@nongnu.org; Wed, 25 Mar 2026 06:04:20 -0400","from mail-wr1-x434.google.com ([2a00:1450:4864:20::434])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1w5L62-0000YV-4T\n for qemu-devel@nongnu.org; Wed, 25 Mar 2026 06:04:19 -0400","by mail-wr1-x434.google.com with SMTP id\n ffacd0b85a97d-439b2965d4bso3455491f8f.2\n for <qemu-devel@nongnu.org>; Wed, 25 Mar 2026 03:04:17 -0700 (PDT)","from [192.168.69.206] (88-187-86-199.subs.proxad.net.\n [88.187.86.199]) by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43b646b0b0csm43266521f8f.15.2026.03.25.03.04.15\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Wed, 25 Mar 2026 03:04:15 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1774433056; x=1775037856; darn=nongnu.org;\n h=content-transfer-encoding:in-reply-to:from:references:cc:to\n :content-language:subject:user-agent:mime-version:date:message-id\n :from:to:cc:subject:date:message-id:reply-to;\n bh=8+bpziVQ1ICo4d3elngv8IvJXEGcFLvZcPeTa72w8qc=;\n b=C4IACY3YWsS710EBoNKgNYCTwUJg/qpGcJqmdSX3r6D9btno2ZpN9rx3hsS0UBXSRG\n jyWZraqOlhg6x+hdgLfbpW9Yf41m9A7KxnWjSuUhVk5iIhSO1n8mFrpH2VbyBIIgl/4i\n H8ZTYWQ7GSwUQnE1ET1cyA0omUgaf92fqDSL3qREU6+kKHhnZ3y6sr74UX+/vJ4OIkYv\n XkhsiaFW7u/HKnWhekERhXVZNfzc8r8PeDpe6hvsR+8lhU0n7uq02rkZBy2KCFc7GVEq\n 2fH/itntaMYPCG+wndjSdOq5VovtovHMkLdebZgQejC637LvgCosEwKoJznivffl0SYm\n wD7g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774433056; x=1775037856;\n h=content-transfer-encoding:in-reply-to:from:references:cc:to\n :content-language:subject:user-agent:mime-version:date:message-id\n :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=8+bpziVQ1ICo4d3elngv8IvJXEGcFLvZcPeTa72w8qc=;\n b=okWY4TfmCYXKI7JUDA1iWtQ+kK0jgVKceWSc7PWebSadqx5i7yqCTOXdatNEnn7xE6\n SOoevVH4U+ez2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rJtAfVTLA==","X-Received":"by 2002:a5d:588a:0:b0:43b:86ce:27a6 with SMTP id\n ffacd0b85a97d-43b8898d428mr4213650f8f.9.1774433056152;\n Wed, 25 Mar 2026 03:04:16 -0700 (PDT)","Message-ID":"<ef81a4fd-91df-4028-b1d0-0f8768d7e642@linaro.org>","Date":"Wed, 25 Mar 2026 11:04:14 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 3/4] tests/functional/qemu_test: Split huge fetch()\n function in asset.py","Content-Language":"en-US","To":"Thomas Huth <thuth@redhat.com>, qemu-devel@nongnu.org","Cc":"=?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= <berrange@redhat.com>","References":"<20260324163543.55503-1-thuth@redhat.com>\n <20260324163543.55503-4-thuth@redhat.com>","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>","In-Reply-To":"<20260324163543.55503-4-thuth@redhat.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2a00:1450:4864:20::434;\n envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://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 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"}}]