Displaying 20 results from an estimated 97 matches for "close_out".
2017 Nov 05
3
[PATCH 1/2] common/mlstdutils: Add with_open_in and with_open_out functions.
...rue
let verbose () = !verbose
+let with_open_in filename f =
+ let chan = open_in filename in
+ protect ~f:(fun () -> f chan) ~finally:(fun () -> close_in chan)
+
+let with_open_out filename f =
+ let chan = open_out filename in
+ protect ~f:(fun () -> f chan) ~finally:(fun () -> close_out chan)
+
let read_whole_file path =
let buf = Buffer.create 16384 in
- let chan = open_in path in
- let maxlen = 16384 in
- let b = Bytes.create maxlen in
- let rec loop () =
- let r = input chan b 0 maxlen in
- if r > 0 then (
- Buffer.add_substring buf (Bytes.to_string b) 0 r...
2016 Jul 22
3
[PATCH RFC supermin] ext2_initrd: error out if we can't add anything
...ext2_initrd.ml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/ext2_initrd.ml b/src/ext2_initrd.ml
index d4a4e2f..d9a3a99 100644
--- a/src/ext2_initrd.ml
+++ b/src/ext2_initrd.ml
@@ -151,8 +151,12 @@ let rec build_initrd debug tmpdir modpath initrd =
visit topset;
close_out chan;
+ let num_visted = StringSet.cardinal !visited in
if debug >= 1 then
- printf "supermin: ext2: wrote %d modules to minimal initrd\n%!" (StringSet.cardinal !visited);
+ printf "supermin: ext2: wrote %d modules to minimal initrd\n%!" num_visted;
+
+ if num_vi...
2018 Dec 03
4
[supermin PATCH 0/2] Create a really empty base.tar.gz
See patch #2 for more explanation.
Pino Toscano (2):
prepare: keep config_files available for longer
prepare: create a really empty base.tar.gz with no config files
src/mode_prepare.ml | 87 +++++++++++++++++++++++++++------------------
1 file changed, 52 insertions(+), 35 deletions(-)
--
2.17.2
2015 Oct 22
1
[PATCH] v2v: -o libvirt: dump XML for libvirt if verbose
...virt.ml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index abdd410..f86f336 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -407,6 +407,12 @@ class output_libvirt oc output_pool = object
DOM.doc_to_chan chan doc;
close_out chan;
+ if verbose () then (
+ printf "resulting XML for libvirt:\n%!";
+ DOM.doc_to_chan stdout doc;
+ printf "\n%!";
+ );
+
(* Define the domain in libvirt. *)
let cmd =
match oc with
--
2.1.0
2019 Aug 13
0
[PATCH 3/3] generator: improve pod2text invocation
...string list (* list of lines of POD file *)
let run_pod2text (width, trim, discard, name, longdesc) =
- let filename, chan = Filename.open_temp_file "gen" ".tmp" in
- fprintf chan "=encoding utf8\n\n";
- fprintf chan "=head1 %s\n\n%s\n" name longdesc;
- close_out chan;
let cmd =
match width with
| Some width ->
- sprintf "pod2text -w %d %s" width (Filename.quote filename)
+ sprintf "pod2text -w %d" width
| None ->
- sprintf "pod2text %s" (Filename.quote filename) in
- let chan = ope...
2015 Mar 12
1
[PATCH] generator: small optimization of pod2text cache memoization
..., memo_value) Hashtbl.t =
v
with
_ -> Hashtbl.create 13
-let pod2text_memo_updated () =
+let pod2text_memo_unsaved_count = ref 0
+let pod2text_memo_atexit = ref false
+let pod2text_memo_save () =
let chan = open_out pod2text_memo_filename in
output_value chan pod2text_memo;
close_out chan
+let pod2text_memo_updated () =
+ if not (!pod2text_memo_atexit) then (
+ at_exit pod2text_memo_save;
+ pod2text_memo_atexit := true;
+ );
+ pod2text_memo_unsaved_count := !pod2text_memo_unsaved_count + 1;
+ if !pod2text_memo_unsaved_count >= 100 then (
+ pod2text_memo_save ();...
2009 Nov 19
1
[PATCH] (Alternate?) locking patch
...ACKING" exn;
+ exit 1);
let close = output_to "src/guestfs_protocol.x" in
generate_xdr ();
@@ -10339,4 +10360,7 @@ Run it from the top source directory using the command
*)
let chan = open_out "src/stamp-generator" in
fprintf chan "1\n";
- close_out chan
+ close_out chan;
+
+ (* Release lock. *)
+ Unix.close lock_fd
--
1.6.5.2
2018 Dec 03
0
[supermin PATCH 2/2] prepare: create a really empty base.tar.gz with no config files
...ig_files);
- let files_from =
- (* Put the list of config files into a file, for tar to read. *)
- let files_from = tmpdir // "files-from.txt" in
- let chan = open_out files_from in
- List.iter (fprintf chan ".%s\n") config_files; (* "./filename" *)
- close_out chan;
-
- files_from in
-
- (* Write base.tar.gz. *)
let base = outputdir // "base.tar.gz" in
- if debug >= 1 then printf "supermin: writing %s\n%!" base;
- let cmd =
- sprintf "tar%s -C %s -zcf %s -T %s"
- (if debug >=1 then " -v"...
2018 Feb 28
1
Re: [PATCH v2 2/3] v2v: utils: Add utility functions for running external Python code.
...ing python code using ā%sā:\n%s" python code;
> +
> + (* Write the Python code to a temporary file so we don't have to
> + * quote things.
> + *)
> + let filename, chan = Filename.open_temp_file "py" ".py" in
> + output_string chan code;
> + close_out chan;
> +
> + let cmd = sprintf "%s %s" (quote python) filename in
quote filename
Tomas
> + let lines = external_command cmd in
> + Unix.unlink filename;
> + lines
> +
> +let py_quote str =
> + let str = String.replace str "\\" "\\\\"...
2019 Aug 13
5
[PATCH 0/3] generator: pod2text-related improvements
- refactor memoization code
- pass pod as stdin rather than files
Pino Toscano (3):
generator: isolate memoized cache in own module
generator: adjust variable names
generator: improve pod2text invocation
generator/Makefile.am | 3 ++
generator/memoized_cache.ml | 62 +++++++++++++++++++++
generator/memoized_cache.mli | 29 ++++++++++
generator/utils.ml | 101
2018 Aug 23
2
[PATCH 1/2] mltools: JSON: add json_parser_tree_parse_file
...28 @@ let test_tree_parse_inspect ctx =
assert_is_number 10_L (List.nth a 2);
assert_is_number 2_L (List.assoc "second" l)
+let test_tree_parse_file_basic ctx =
+ begin
+ let tmpfile, chan = bracket_tmpfile ctx in
+ output_string chan "{}\n";
+ flush chan;
+ close_out chan;
+ let value = json_parser_tree_parse_file tmpfile in
+ assert_is_object value
+ end;
+ begin
+ let tmpfile, chan = bracket_tmpfile ctx in
+ output_string chan "{\"foo\":5}\n";
+ flush chan;
+ close_out chan;
+ let value = json_parser_tree_parse_file...
2014 Feb 20
4
[PATCH 1/2] mllib: add an hook to cleanup directories on exit
Much similar to unlink_on_exit, but recursively cleaning directories.
---
mllib/common_utils.ml | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 3943417..f49ede6 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -386,6 +386,35 @@ let unlink_on_exit =
registered_handlers := true
)
2017 Mar 13
0
[PATCH 1/2] v2v: -i ova: Hoist utility functions to the top of the file.
...compressed_type format file =
+ let zcat = match format with `GZip -> "zcat" | `XZ -> "xzcat" in
+ let head, headlen = uncompress_head zcat file in
+ let tmpfile, chan =
+ Filename.open_temp_file "ova.file." "" in
+ output chan head 0 headlen;
+ close_out chan;
+ let ret = detect_file_type tmpfile in
+ Sys.remove tmpfile;
+ ret
+
class input_ova ova =
let tmpdir =
let base_dir = (open_guestfs ())#get_cachedir () in
@@ -52,17 +115,6 @@ object
method as_options = "-i ova " ^ ova
method source () =
- (* Untar part or al...
2018 Dec 03
4
[supermin PATCH v2 0/3] Better handle no config files
This is a "merge" of two previous series:
https://www.redhat.com/archives/libguestfs/2018-December/msg00015.html
https://www.redhat.com/archives/libguestfs/2018-December/msg00020.html
The goal is to handle better situations like:
- empty file in the appliance directory
- no config files available in the packages to include in an appliance
Compared to the two series, the changes are:
-
2014 Feb 21
2
Re: [PATCH 2/2] builder: use a disposable GPG keyring for every Sigchecker
...key. *)
> +(* Import the requested public key. *)
> and import_key t =
> - if not !key_imported then (
> - let filename, chan = Filename.open_temp_file "vbpubkey" ".asc" in
> - unlink_on_exit filename;
> - output_string chan default_pubkey;
> - close_out chan;
> -
> - let cmd = sprintf "%s --import %s%s"
> - t.gpg (quote filename)
> + if not t.key_imported then (
> + let keyfile = ref "" in
> + if equal_fingerprints default_fingerprint t.fingerprint then (
> + let filename, chan = Filenam...
2014 Dec 23
2
[PATCH] v2v: adding --vdsm-ovf-output option
...object
vdsm_params.vm_uuid in
(* Write it to the metadata file. *)
- let file = ovf_dir // vdsm_params.vm_uuid ^ ".ovf" in
+ let file = vdsm_params.ovf_output // vdsm_params.vm_uuid ^ ".ovf" in
let chan = open_out file in
doc_to_chan chan ovf;
close_out chan
diff --git a/v2v/output_vdsm.mli b/v2v/output_vdsm.mli
index 56ddf55..3f63191 100644
--- a/v2v/output_vdsm.mli
+++ b/v2v/output_vdsm.mli
@@ -22,6 +22,7 @@ type vdsm_params = {
image_uuid : string; (* --vdsm-image-uuid *)
vol_uuids : string list; (* --vdsm-vol-uu...
2016 Jul 22
0
Re: [PATCH RFC supermin] ext2_initrd: error out if we can't add anything
...d, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/ext2_initrd.ml b/src/ext2_initrd.ml
> index d4a4e2f..d9a3a99 100644
> --- a/src/ext2_initrd.ml
> +++ b/src/ext2_initrd.ml
> @@ -151,8 +151,12 @@ let rec build_initrd debug tmpdir modpath initrd =
> visit topset;
> close_out chan;
>
> + let num_visted = StringSet.cardinal !visited in
> if debug >= 1 then
> - printf "supermin: ext2: wrote %d modules to minimal initrd\n%!" (StringSet.cardinal !visited);
> + printf "supermin: ext2: wrote %d modules to minimal initrd\n%!" n...
2018 Feb 27
0
[PATCH v2 2/3] v2v: utils: Add utility functions for running external Python code.
...nto the log. *)
+ debug "running python code using ā%sā:\n%s" python code;
+
+ (* Write the Python code to a temporary file so we don't have to
+ * quote things.
+ *)
+ let filename, chan = Filename.open_temp_file "py" ".py" in
+ output_string chan code;
+ close_out chan;
+
+ let cmd = sprintf "%s %s" (quote python) filename in
+ let lines = external_command cmd in
+ Unix.unlink filename;
+ lines
+
+let py_quote str =
+ let str = String.replace str "\\" "\\\\" in
+ let str = String.replace str "'" "\\'...
2017 Nov 07
0
[PATCH] common/mlstdutils: Add with_openfile function.
...std_utils.ml b/common/mlstdutils/std_utils.ml
index ee6bea5af..5d451fae8 100644
--- a/common/mlstdutils/std_utils.ml
+++ b/common/mlstdutils/std_utils.ml
@@ -662,6 +662,10 @@ let with_open_out filename f =
let chan = open_out filename in
protect ~f:(fun () -> f chan) ~finally:(fun () -> close_out chan)
+let with_openfile filename flags perms f =
+ let fd = Unix.openfile filename flags perms in
+ protect ~f:(fun () -> f fd) ~finally:(fun () -> Unix.close fd)
+
let read_whole_file path =
let buf = Buffer.create 16384 in
with_open_in path (
diff --git a/common/mlstdutils/std_u...
2014 Dec 23
2
[PATCH] v2v: adding --vdsm-ovf-output option
...object
vdsm_params.vm_uuid in
(* Write it to the metadata file. *)
- let file = ovf_dir // vdsm_params.vm_uuid ^ ".ovf" in
+ let file = vdsm_params.ovf_output // vdsm_params.vm_uuid ^ ".ovf" in
let chan = open_out file in
doc_to_chan chan ovf;
close_out chan
diff --git a/v2v/output_vdsm.mli b/v2v/output_vdsm.mli
index 3ee5425..26ac15d 100644
--- a/v2v/output_vdsm.mli
+++ b/v2v/output_vdsm.mli
@@ -22,6 +22,7 @@ type vdsm_params = {
image_uuids : string list; (* --vdsm-image-uuid (multiple) *)
vol_uuids : string list; (* --...