From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Bavier Subject: Re: [PATCH 1/2] import: json: Silence json-fetch output. Date: Wed, 7 Dec 2016 23:57:58 -0600 Message-ID: <20161207235758.455406ed@centurylink.net> References: <20161205050317.13222-1-bavier@member.fsf.org> <8760mw9f9d.fsf@gnu.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]:48578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEriY-0000L4-QQ for guix-devel@gnu.org; Thu, 08 Dec 2016 00:58:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cEriU-0003t6-81 for guix-devel@gnu.org; Thu, 08 Dec 2016 00:58:06 -0500 Received: from mail.centurylink.net ([205.219.233.9]:7528 helo=smtp.centurylink.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cEriU-0003s1-2v for guix-devel@gnu.org; Thu, 08 Dec 2016 00:58:02 -0500 In-Reply-To: <8760mw9f9d.fsf@gnu.org> 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: Ludovic =?UTF-8?B?Q291cnTDqHM=?= Cc: guix-devel@gnu.org On Wed, 07 Dec 2016 11:59:10 +0100 ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > Eric Bavier skribis: >=20 > > * 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. =20 >=20 > [...] >=20 > > (define (json-fetch url) > > "Return an alist representation of the JSON resource URL, or #f on f= ailure." > > - (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)))) =20 >=20 > It=E2=80=99d be better to not catch exceptions raised by =E2=80=98http-fe= tch=E2=80=99 here. > Instead they=E2=80=99d be caught at the top level and a detailed error me= ssage > would be displayed, which is always better than silently ignoring > issues. >=20 > However we=E2=80=99d need to check if there are uses where this is a prob= lem. > 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. >=20 > WDYT? The importers that use json-fetch all do something like '(and=3D> meta ->package)', so a #f result from json-fetch is passed up to (@ (guix scripts import) guix-import) and interpreted as a "import failed". Using the false-if-exception* syntax which prints the exception message, from guix/build/download.scm might be nicer. This is the syntax that url-fetch uses. That syntax would need to be exported from somewhere. WDYT? `~Eric