Browse Source

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.
version-0.12.0
Eric Bavier 5 years ago
parent
commit
63773200d7
No known key found for this signature in database GPG Key ID: 1EBBD204781F962C
  1. 10
      guix/import/gem.scm
  2. 17
      guix/import/json.scm
  3. 10
      guix/import/pypi.scm

10
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

17
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)))

10
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

Loading…
Cancel
Save