summaryrefslogtreecommitdiff
path: root/guix/import/json.scm
diff options
context:
space:
mode:
authorEric Bavier <bavier@member.fsf.org>2016-12-04 22:42:49 -0600
committerEric Bavier <bavier@member.fsf.org>2016-12-12 22:22:02 -0600
commit63773200d7ac68fcaee6efd9ffe8ea7aa3fafa38 (patch)
treef933667cda574a939fc5728b09f6a795de752567 /guix/import/json.scm
parent7843f276d1c9c2b0c6b6a2c91ddd12500320945e (diff)
downloadgnu-guix-63773200d7ac68fcaee6efd9ffe8ea7aa3fafa38.tar
gnu-guix-63773200d7ac68fcaee6efd9ffe8ea7aa3fafa38.tar.gz
import: json: Silence json-fetch output.
* 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.
Diffstat (limited to 'guix/import/json.scm')
-rw-r--r--guix/import/json.scm17
1 files changed, 10 insertions, 7 deletions
diff --git a/guix/import/json.scm b/guix/import/json.scm
index c3092a5a9d..5940f5e48f 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,17 @@
(define-module (guix import json)
#:use-module (json)
- #:use-module (guix utils)
+ #:use-module (guix http-client)
#:use-module (guix import utils)
+ #:use-module (srfi srfi-34)
#: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))))))
+ (guard (c ((and (http-get-error? c)
+ (= 404 (http-get-error-code c)))
+ #f)) ;"expected" if package is unknown
+ (let* ((port (http-fetch url))
+ (result (hash-table->alist (json->scm port))))
+ (close-port port)
+ result)))