From: Eric Bavier <bavier@member.fsf.org>
To: guix-devel@gnu.org
Cc: Eric Bavier <bavier@member.fsf.org>
Subject: [PATCH 1/2] import: json: Silence json-fetch output.
Date: Sun, 4 Dec 2016 23:03:16 -0600 [thread overview]
Message-ID: <20161205050317.13222-1-bavier@member.fsf.org> (raw)
* 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 © 2014 David Thompson <davet@gnu.org>
-;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2015, 2016 Eric Bavier <bavier@member.fsf.org>
;;;
;;; 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=> (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
next reply other threads:[~2016-12-05 5:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-05 5:03 Eric Bavier [this message]
2016-12-05 5:03 ` [PATCH 2/2] import: cpan: Add CPAN updater Eric Bavier
2016-12-07 11:02 ` Ludovic Courtès
2016-12-08 5:45 ` Eric Bavier
2016-12-07 10:59 ` [PATCH 1/2] import: json: Silence json-fetch output Ludovic Courtès
2016-12-08 5:57 ` Eric Bavier
2016-12-08 9:52 ` Ludovic Courtès
2016-12-14 15:16 ` David Craven
2016-12-15 17:37 ` Ludovic Courtès
2016-12-20 2:50 ` Eric Bavier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161205050317.13222-1-bavier@member.fsf.org \
--to=bavier@member.fsf.org \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.