From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 1/2] import: json: Silence json-fetch output. Date: Wed, 07 Dec 2016 11:59:10 +0100 Message-ID: <8760mw9f9d.fsf@gnu.org> References: <20161205050317.13222-1-bavier@member.fsf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEZwT-0006ir-AI for guix-devel@gnu.org; Wed, 07 Dec 2016 05:59:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cEZwP-0000hG-Bk for guix-devel@gnu.org; Wed, 07 Dec 2016 05:59:17 -0500 In-Reply-To: <20161205050317.13222-1-bavier@member.fsf.org> (Eric Bavier's message of "Sun, 4 Dec 2016 23:03:16 -0600") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Eric Bavier Cc: guix-devel@gnu.org Eric Bavier skribis: > * guix/import/json.scm (json-fetch): Use http-fetch instead of url-fetch > to avoid writing to stdout and a temporary file for each invocation. > * guix/import/gem.scm (rubygems-fetch): Do not redirect json-fetch > output to /dev/null. > * guix/import/pypi.scm (pypi-fetch): Likewise. [...] > (define (json-fetch url) > "Return an alist representation of the JSON resource URL, or #f on fai= lure." > - (call-with-temporary-output-file > - (lambda (temp port) > - (and (url-fetch url temp) > - (hash-table->alist > - (call-with-input-file temp json->scm)))))) > + (and=3D> (false-if-exception (http-fetch url)) > + (lambda (port) > + (let ((result (hash-table->alist (json->scm port)))) > + (close-port port) > + result)))) It=E2=80=99d be better to not catch exceptions raised by =E2=80=98http-fetc= h=E2=80=99 here. Instead they=E2=80=99d be caught at the top level and a detailed error mess= age would be displayed, which is always better than silently ignoring issues. However we=E2=80=99d need to check if there are uses where this is a proble= m. For example, there might be updaters or importers that assume that #f means that the package doesn=E2=80=99t exist or something like that. WDYT? > diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm > index 68153d5..9794ff9 100644 > --- a/guix/import/pypi.scm > +++ b/guix/import/pypi.scm > @@ -51,14 +51,8 @@ > (define (pypi-fetch name) > "Return an alist representation of the PyPI metadata for the package N= AME, > or #f on failure." > - ;; XXX: We want to silence the download progress report, which is espe= cially > - ;; annoying for 'guix refresh', but we have to use a file port. > - (call-with-output-file "/dev/null" > - (lambda (null) > - (with-error-to-port null > - (lambda () > - (json-fetch (string-append "https://pypi.python.org/pypi/" > - name "/json"))))))) > + (json-fetch (string-append "https://pypi.python.org/pypi/" > + name "/json"))) The rest LGTM, thanks! Ludo=E2=80=99.