search for: read_whole_file

Displaying 20 results from an estimated 206 matches for "read_whole_file".

2019 Sep 23
6
[PATCH v2 0/5] remove unused gnulib modules
...an extended version of: https://www.redhat.com/archives/libguestfs/2019-September/msg00178.html It adds a couple of simple code changes, so it makes it possible to drop more modules. In addition, more unused modules were dropped. Pino Toscano (5): tests: switch away from xgetcwd daemon: move read_whole_file to common utils daemon: switch from read_file to read_whole_file daemon: remove unused include build: remove unused gnulib modules bootstrap | 17 --------- daemon/9p.c | 58 +----------------------------- daemon/Makefile.am |...
2019 Nov 27
7
[PATCH v3 0/6] remove unused build stuff
...s an extended version of: https://www.redhat.com/archives/libguestfs/2019-September/msg00288.html Apparently I forgot it on my tree, so I'm posting that series again, adding an extra cleanup more due to the v2v/common splits. Pino Toscano (6): tests: switch away from xgetcwd daemon: move read_whole_file to common utils daemon: switch from read_file to read_whole_file daemon: remove unused include build: remove unused gnulib modules build: ignore unused submodules Makefile.am | 4 --- bootstrap | 17 --------- configure.ac...
2017 Oct 11
1
Re: [PATCH] v2v: -i vmx: Refuse to load a disk image by accident.
...; > > + error (f_"-i vmx: %s: this may be a disk image. You must specify the .vmx file only on the command line.") > > + vmx_filename > > + | _ -> () in > > + > > (* Read the whole file as a list of lines. *) > > let str = read_whole_file vmx_filename in > > if verbose () then eprintf "VMX file:\n%s\n" str; > > Hm I'm not sure about this, since we don't do this for other parameters > (e.g. the XML for -i libvirtxml). Let's drop this for now, since it's user error. What's probably ne...
2017 Jun 20
2
[PATCH v2 1/2] mllib: add new Common_utils.run_commands
...n_command ctx = + assert_equal_int 0 (run_command ["true"]); + begin + let tmpfile, chan = bracket_tmpfile ctx in + let res = run_command ["echo"; "this is a test"] ~stdout_chan:(Unix.descr_of_out_channel chan) in + assert_equal_int 0 res; + let content = read_whole_file tmpfile in + assert_equal_string "this is a test\n" content + end; + begin + let tmpfile, chan = bracket_tmpfile ctx in + let res = run_command ["ls"; "/this-directory-is-unlikely-to-exist"] ~stderr_chan:(Unix.descr_of_out_channel chan) in + assert_equal_...
2017 Oct 11
2
[PATCH] v2v: -i vmx: Refuse to load a disk image by accident.
..._ when String.find line "disk image" >= 0 -> + error (f_"-i vmx: %s: this may be a disk image. You must specify the .vmx file only on the command line.") + vmx_filename + | _ -> () in + (* Read the whole file as a list of lines. *) let str = read_whole_file vmx_filename in if verbose () then eprintf "VMX file:\n%s\n" str; -- 2.13.2
2020 Jan 23
2
[common PATCH] Trim whitespaces from commands read from file
...1 file changed, 1 insertion(+) diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml index c062379879e2..67e85af2ad93 100644 --- a/mlcustomize/customize_cmdline.ml +++ b/mlcustomize/customize_cmdline.ml @@ -481,6 +481,7 @@ let rec argspec () = ] in let lines = read_whole_file filename in let lines = String.lines_split lines in + let lines = List.map String.trim lines in let lines = List.filter ( fun line -> String.length line > 0 && line.[0] <> '#' -- 2.25.0
2019 Dec 03
0
[p2v PATCH 6/6] Remove whole-file.c
The only function in it, read_whole_file(), is not used anymore. (And anyway, the GLib function g_file_get_contents() can be used instead.) --- Makefile.am | 3 +- p2v.h | 3 -- whole-file.c | 94 ---------------------------------------------------- 3 files changed, 1 insertion(+), 99 deletions(-) delete mode 100644 whole-file...
2019 Nov 26
0
[PATCH libguestfs 1/3] podwrapper: __INCLUDE:file.pod__ and __VERBATIM:file.txt__ in POD files.
...t; \$section, "strict-checks!" => \$strict_checks, "text=s" => \$text, @@ -314,6 +346,10 @@ foreach (@inserts) { if $content eq $oldcontent; } +# Perform INCLUDE directives. +$content =~ s{__INCLUDE:([-a-z0-9_]+\.pod)__} + {read_whole_file ("$1", path => $path)}ge; + # Turn external links to this man page into simple cross-section links. $content =~ s,\QL<$name($section)/\E,L</,g; @@ -328,6 +364,10 @@ foreach (@verbatims) { if $content eq $oldcontent; } +# Perform VERBATIM directives. +$content =~ s...
2020 Jan 29
2
Re: [PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
...t; diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml > index c062379879e2..abd21a4cbca5 100644 > --- a/mlcustomize/customize_cmdline.ml > +++ b/mlcustomize/customize_cmdline.ml > @@ -481,6 +481,7 @@ let rec argspec () = > ] in > let lines = read_whole_file filename in > let lines = String.lines_split lines in > + let lines = List.map String.triml lines in > let lines = List.filter ( > fun line -> > String.length line > 0 && line.[0] <> '#' Seems OK to me, so ACK. Rich. -- Ric...
2015 Nov 16
0
[PATCH] p2v: Send physical server 'dmesg' output to debug dir on conversion server.
...;dmesg' output from the physical server (more precisely: from the virt-p2v ISO's kernel running on the physical server) to the virt-v2v conversion server debugging directory, so that this information is available for debugging later. Unfortunately this involves yet another copy of the 'read_whole_file' function. --- p2v/Makefile.am | 3 +- p2v/conversion.c | 32 ++++++++++++++++++- p2v/p2v.h | 5 ++- p2v/ssh.c | 21 ++++++++++++- p2v/virt-p2v.pod | 8 +++++ p2v/whole-file.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES | 1 + 7 files chan...
2020 Jan 23
6
Re: [common PATCH] Trim whitespaces from commands read from file
...omize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml > >index c062379879e2..67e85af2ad93 100644 > >--- a/mlcustomize/customize_cmdline.ml > >+++ b/mlcustomize/customize_cmdline.ml > >@@ -481,6 +481,7 @@ let rec argspec () = > > ] in > > let lines = read_whole_file filename in > > let lines = String.lines_split lines in > >+ let lines = List.map String.trim lines in I wonder if String.triml is safer? However I cannot think of a way that it's likely to be useful to have trailing whitespace be meaningful. Please put this in the subject...
2017 Apr 07
1
[PATCH 1/2] mllib: add new Common_utils.run_commands
..., None, None)] in + assert_equal_intlist [127] res + end; + begin + let tmpfile, chan = bracket_tmpfile ctx in + let res = run_commands [(["echo"; "this is a test"], Some (Unix.descr_of_out_channel chan), None)] in + assert_equal_intlist [0] res; + let content = read_whole_file tmpfile in + assert_equal_string "this is a test\n" content + end; + begin + let tmpfile, chan = bracket_tmpfile ctx in + let res = run_commands [(["ls"; "/this-directory-is-unlikely-to-exist"], None, Some (Unix.descr_of_out_channel chan))] in + assert_eq...
2015 May 11
3
[PATCH 1/3] builder: move gpg status parsing within import_keyfile
...builder/sigchecker.ml @@ -43,7 +43,17 @@ let import_keyfile ~gpg ~gpghome ~verbose keyfile = let r = Sys.command cmd in if r <> 0 then error (f_"could not import public key\nUse the '-v' option and look for earlier error messages."); - status_file + let status = read_whole_file status_file in + let status = string_nsplit "\n" status in + let fingerprint = ref "" in + List.iter ( + fun line -> + let line = string_nsplit " " line in + match line with + | "[GNUPG:]" :: "IMPORT_OK" :: _ :: fp :: _ ->...
2020 Jan 17
1
[v2v PATCH] -i ova: use Xml.parse_file for the OVF
...file changed, 1 insertion(+), 2 deletions(-) diff --git a/v2v/parse_ovf_from_ova.ml b/v2v/parse_ovf_from_ova.ml index 27761d23..5acf7070 100644 --- a/v2v/parse_ovf_from_ova.ml +++ b/v2v/parse_ovf_from_ova.ml @@ -36,8 +36,7 @@ type ovf_disk = { } let xpathctx_of_ovf ovf_filename = - let xml = read_whole_file ovf_filename in - let doc = Xml.parse_memory xml in + let doc = Xml.parse_file ovf_filename in (* Handle namespaces. *) let xpathctx = Xml.xpath_new_context doc in -- 2.24.1
2019 Sep 16
0
[PATCH 6/8] v2v: -o rhv-upload: collect disks UUIDs right after copy
...ov_source.s_disk_id in - let diskid_file = diskid_file_of_id id in - if not (wait_for_file diskid_file finalization_timeout) then - error (f_"transfer of disk %d/%d failed, see earlier error messages") - (i+1) nr_disks; - let diskid = read_whole_file diskid_file in - diskid - ) targets in + let id = t.target_overlay.ov_source.s_disk_id in + let diskid_file = diskid_file_of_id id in + if not (wait_for_file diskid_file finalization_timeout) then + error (f_"transfer of disk %d/%d failed, see earlier error messages...
2017 Nov 07
0
[PATCH] common/mlstdutils: Add with_openfile function.
...t 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_utils.mli b/common/mlstdutils/std_utils.mli index 7af6c2111..e30d8eec3 100644 --- a/common/mlstdutils/std_utils.mli +++ b/common/mlstdutils/std_utils.mli @@ -399,6 +399,12 @@ val with_open_out : str...
2017 Nov 05
0
[PATCH 2/2] common/mlstdutils: Add with_openfile function.
...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 = + let fd = Unix.openfile filename flags perms in + protect ~f:(fun () -> f fd) ~finally:(fun () -> close fd) + let read_whole_file path = let buf = Buffer.create 16384 in with_open_in path ( diff --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli index 7af6c2111..178762819 100644 --- a/common/mlstdutils/std_utils.mli +++ b/common/mlstdutils/std_utils.mli @@ -399,6 +399,12 @@ val with_open_out : str...
2015 Sep 29
8
[PATCH 0/7] copy-in/copy-out: Capture errors from tar subprocess (RHBZ#1267032).
Commits 3c27f3d91e1566854747bbe844186783fc84f3a8 and 1b6f0daa9ae7fcc94e389232d0c397816cda973d added an internal API for running commands asynchronously. It is only used by the copy-in and copy-out APIs. Unfortunately this made the command code very complex: it was almost impossible to redirect stderr to a file, and there were a lot of long-range dependencies through the file. It was also buggy:
2018 Aug 23
2
[PATCH 1/2] mltools: JSON: add json_parser_tree_parse_file
Easy way to parse JSON from a file, without reading it all to string first. --- common/mltools/JSON_parser-c.c | 25 +++++++++++++++++++++++++ common/mltools/JSON_parser.ml | 1 + common/mltools/JSON_parser.mli | 3 +++ common/mltools/JSON_parser_tests.ml | 23 +++++++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/common/mltools/JSON_parser-c.c
2017 Jan 03
0
[PATCH 4/5] mllib: add libosinfo DB reading helpers
...( + List.map ( + fun distro -> + let distro_path = os_path // distro in + let os_files = Array.to_list (Sys.readdir distro_path) in + List.map ( + fun os_file -> + let file_path = distro_path // os_file in + let xml = read_whole_file file_path in + let doc = Xml.parse_memory xml in + let xpathctx = Xml.xpath_new_context doc in + filter xpathctx + ) os_files + ) distros + ) + ) + +let osinfo_db_read_flat os_path filter = + let os_files = Array.to_list (Sys.readdir os_path...