From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Bavier Subject: [PATCH 1/2] import: json: Silence json-fetch output. Date: Sun, 4 Dec 2016 23:03:16 -0600 Message-ID: <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]:56413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDlRM-0002FP-7n for guix-devel@gnu.org; Mon, 05 Dec 2016 00:03:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDlRI-0003yp-8a for guix-devel@gnu.org; Mon, 05 Dec 2016 00:03:48 -0500 Received: from mail.centurylink.net ([205.219.233.9]:48851 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 1cDlRI-0003yl-3b for guix-devel@gnu.org; Mon, 05 Dec 2016 00:03:44 -0500 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: guix-devel@gnu.org Cc: Eric Bavier * 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. --- guix/import/gem.scm | 10 ++-------- guix/import/json.scm | 14 +++++++------- guix/import/pypi.scm | 10 ++-------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/guix/import/gem.scm b/guix/import/gem.scm index 3d0c190..3ad7fac 100644 --- a/guix/import/gem.scm +++ b/guix/import/gem.scm @@ -38,14 +38,8 @@ (define (rubygems-fetch name) "Return an alist representation of the RubyGems metadata for the package NAME, or #f on failure." - ;; XXX: We want to silence the download progress report, which is especially - ;; 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://rubygems.org/api/v1/gems/" name ".json"))))))) + (json-fetch + (string-append "https://rubygems.org/api/v1/gems/" name ".json"))) (define (ruby-package-name name) "Given the NAME of a package on RubyGems, return a Guix-compliant name for diff --git a/guix/import/json.scm b/guix/import/json.scm index c3092a5..f0d75fd 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2014 David Thompson -;;; Copyright =C2=A9 2015 Eric Bavier +;;; Copyright =C2=A9 2015, 2016 Eric Bavier ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,14 +19,14 @@ (define-module (guix import json) #:use-module (json) - #:use-module (guix utils) + #:use-module (guix http-client) #:use-module (guix import utils) #:export (json-fetch)) (define (json-fetch url) "Return an alist representation of the JSON resource URL, or #f on failure." - (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)))) 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 NAME, or #f on failure." - ;; XXX: We want to silence the download progress report, which is especially - ;; 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"))) ;; For packages found on PyPI that lack a source distribution. (define-condition-type &missing-source-error &error -- 2.10.2