[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 48/324: scripts: download-store: download json container
From: |
gnunet |
Subject: |
[gnunet-scheme] 48/324: scripts: download-store: download json container |
Date: |
Tue, 21 Sep 2021 13:21:28 +0200 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
commit 69f8df63b1342a2eea7efc0f6597dfb88b9c0fdc
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Jan 23 23:31:19 2021 +0100
scripts: download-store: download json container
* gnu/gnunet/scripts/download-store.scm
(main, download-nar): change argument format of
'gnunet-download'
(gnunet-download): new procedure, downloading a file to disk
(gnunet-download/bytevector): new procedure, downloading to
a fresh bytevector
(download-nar): download the JSON container
---
gnu/gnunet/scripts/download-store.scm | 62 ++++++++++++++++++++++++++++++-----
1 file changed, 53 insertions(+), 9 deletions(-)
diff --git a/gnu/gnunet/scripts/download-store.scm
b/gnu/gnunet/scripts/download-store.scm
index d17f9e0..093ef58 100644
--- a/gnu/gnunet/scripts/download-store.scm
+++ b/gnu/gnunet/scripts/download-store.scm
@@ -16,15 +16,21 @@
;;
;; SPDX-License-Identifier: AGPL-3.0-or-later
+;; TODO: parallel downloads
(library (gnu gnunet scripts download-store)
(export main)
- (import (ice-9 optargs)
+ (import (gnu gnunet scripts guix-stuff)
+ (ice-9 optargs)
(ice-9 getopt-long)
(rnrs base)
(rnrs io simple)
+ (rnrs io ports)
+ (rnrs bytevectors)
+ (only (rnrs control) unless)
(only (rnrs programs) exit)
- (only (guile) string-prefix?)
- (srfi srfi-1)
+ (only (guile)
+ string-prefix? system* status:exit-val)
+ (json) (srfi srfi-1)
(srfi srfi-26))
(begin
(define %supported-formats
@@ -96,8 +102,8 @@ GNUnet options
(newline))
((member (option-ref options 'format "gnunet-nix-archive-json/0")
'("gnunet-nix-archive-json/0" "any"))
- (download-nar #:input (option-ref options 'input #f)
- #:output (option-ref options 'output #f)
+ (download-nar (option-ref options 'input #f)
+ (option-ref options 'output #f)
#:config (option-ref options 'config #f)
#:no-network (option-ref options 'no-network #f)
#:anonymity
@@ -105,7 +111,45 @@ GNUnet options
(option-ref options 'anonymity "1"))))
(else ???))))
- (define* (download-nar #:key
- #:allow-other-keys
- #:rest r)
- ???)))
+ (define* (gnunet-download uri
+ output-filename
+ #:key
+ (config (string-append
+ (getenv "HOME")
+ "/.config/gnunet.conf"))
+ (anonymity 1)
+ (no-network #f))
+ "Download URI to the file OUTPUT, which is
+created if needed, as a single file."
+ (let* ((*binary* "gnunet-download")
+ (cmd `(,*binary*
+ ,@(if config
+ `("-c" ,config)
+ '())
+ ,@(if no-network
+ '("-n")
+ '())
+ "-a" ,(number->string anonymity)
+ "-o" ,output-filename
+ ,uri))
+ (result (apply system* cmd)))
+ (unless (= (status:exit-val result) 0)
+ ;; XXX proper error message
+ (throw 'gnunet-download-eep 'gnunet-download-???))
+ (values)))
+
+ (define* (gnunet-download/bytevector uri #:rest r)
+ "Like gnunet-download, but return a bytevector
+instead of writing to a file."
+ (call-with-temporary-output-file
+ (lambda (filename out)
+ (apply gnunet-download uri filename r)
+ (get-bytevector-all out))))
+
+ (define* (download-nar uri output #:rest r)
+ (let* ((container/bv (apply gnunet-download/bytevector uri r))
+ (container/json (utf8->string container/bv))
+ (container/scm (json-string->scm container/json)))
+ (display container/scm)
+ (display 'do-stuff-please)
+ ???))))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 33/324: include some notes on reverse-engineering GNUdirs, (continued)
- [gnunet-scheme] 33/324: include some notes on reverse-engineering GNUdirs, gnunet, 2021/09/21
- [gnunet-scheme] 36/324: scripts: publish-store: eliminate add-name, gnunet, 2021/09/21
- [gnunet-scheme] 32/324: remove some uses of old accessors, gnunet, 2021/09/21
- [gnunet-scheme] 41/324: scripts: publish-store: fix predicate of --format option, gnunet, 2021/09/21
- [gnunet-scheme] 38/324: scripts: publish-store: publish whole trees, gnunet, 2021/09/21
- [gnunet-scheme] 37/324: scripts: publish-store: publish individual files, gnunet, 2021/09/21
- [gnunet-scheme] 40/324: scripts: publish-store: allow setting all options, gnunet, 2021/09/21
- [gnunet-scheme] 39/324: guix: suggest a package definition, gnunet, 2021/09/21
- [gnunet-scheme] 35/324: scripts: publish-store: compute file tree, gnunet, 2021/09/21
- [gnunet-scheme] 43/324: scripts: publish-store: exit after main function, gnunet, 2021/09/21
- [gnunet-scheme] 48/324: scripts: download-store: download json container,
gnunet <=
- [gnunet-scheme] 45/324: scripts: publish-store: fix '--config' option parsing, gnunet, 2021/09/21
- [gnunet-scheme] 46/324: scripts: download-store: parse input arguments, gnunet, 2021/09/21
- [gnunet-scheme] 42/324: scripts: publish-store: export some procedures, gnunet, 2021/09/21
- [gnunet-scheme] 44/324: doc: document publish-store.scm, gnunet, 2021/09/21
- [gnunet-scheme] 53/324: doc: add a section on Guix in the roadmap, gnunet, 2021/09/21
- [gnunet-scheme] 51/324: scripts: publish-store: add option for printing generated JSON, gnunet, 2021/09/21
- [gnunet-scheme] 52/324: scripts: download-store: add downloading procedure, gnunet, 2021/09/21
- [gnunet-scheme] 47/324: scripts: publish-store: don't index temporary files, gnunet, 2021/09/21
- [gnunet-scheme] 50/324: scripts: download-store: (partially) validate entries, gnunet, 2021/09/21
- [gnunet-scheme] 49/324: scripts: publish-store: correct file name creation, gnunet, 2021/09/21