search for: stringify_arg

Displaying 20 results from an estimated 28 matches for "stringify_arg".

Did you mean: stringify_args
2016 May 23
0
[PATCH 4/5] mllib: move stringify_args from dib
Move the make_dib_args helper function to Common_utils as stringify_args, so it can be used also within Common_utils itself. This is mostly code motion. --- dib/dib.ml | 12 +----------- mllib/common_utils.ml | 10 ++++++++++ mllib/common_utils.mli | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/dib/dib.ml b/dib/dib.ml index b...
2016 Aug 02
0
[PATCH] mllib: check for executable existance in run_command (RHBZ#1362357)
...f --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 14f4935..fdca713 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -677,18 +677,26 @@ let external_command ?(echo_cmd = true) cmd = let run_command ?(echo_cmd = true) args = if echo_cmd then debug "%s" (stringify_args args); - let pid = - Unix.create_process (List.hd args) (Array.of_list args) Unix.stdin - Unix.stdout Unix.stderr in - let _, stat = Unix.waitpid [] pid in - match stat with - | Unix.WEXITED i -> i - | Unix.WSIGNALED i -> - error (f_"external command '%s' killed...
2016 Aug 02
2
[PATCH] mllib: move which and its exception from dib
Rename it from "tool" to "executable" in the process, but otherwise it is just code motion (with minimal adjustments in dib). --- dib/dib.ml | 2 +- dib/utils.ml | 16 +--------------- mllib/common_utils.ml | 14 ++++++++++++++ mllib/common_utils.mli | 9 +++++++++ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/dib/dib.ml b/dib/dib.ml
2016 Nov 04
0
[PATCH 4/5] v2v: ova: don't extract files from OVA if it's not needed
...e outdir = + let cmd1 = [ "tar"; "-tf" ; file ] in + let cmd2 = [ "grep"; "\\.\\(ovf\\|mf\\)$" ] in + let cmd3 = [ "xargs"; "tar"; "-xf" ; file; "-C"; outdir ] in + if shell_command ((stringify_args cmd1) ^ " | " ^ (stringify_args cmd2) ^ " | " ^ (stringify_args cmd3)) <> 0 then + error (f_"error unpacking %s, see earlier error messages") ova in + match detect_file_type ova with | `Tar -> (* Normal ovas are tar fil...
2017 Apr 07
1
[PATCH 1/2] mllib: add new Common_utils.run_commands
...try + let app = + if Filename.is_relative app then which app + else (Unix.access app [Unix.X_OK]; app) in + let outfd = get_fd Unix.stdout out in + let errfd = get_fd Unix.stderr err in + if echo_cmd then + debug "%s" (stringify_args args); + let pid = Unix.create_process app (Array.of_list args) Unix.stdin + outfd errfd in + Some (i, pid, app, out, err) + with + | Executable_not_found _ -> + res.(i) <- 127; + None + | Unix.Unix_error (errcode,...
2017 Jun 20
2
[PATCH v2 1/2] mllib: add new Common_utils.run_commands
...ommon_utils.ml b/mllib/common_utils.ml index 6a9b089..60b43a3 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -846,29 +846,82 @@ let external_command ?(echo_cmd = true) cmd = ); lines -let run_command ?(echo_cmd = true) args = - if echo_cmd then - debug "%s" (stringify_args args); +let rec run_commands ?(echo_cmd = true) cmds = + let res = Array.make (List.length cmds) 0 in + let pids = + mapi ( + fun i (args, stdout_chan, stderr_chan) -> + let run_res = do_run args ?stdout_chan ?stderr_chan in + match run_res with + | Either (pid, a...
2016 Nov 04
10
[PATCH 0/5] Import directly from OVA tar archive if possible
This is still a draft, not ready for commit yet. But feedback is welcomed. This series is related to the problem of inefficient import of OVA files. The needed enhancements of QEMU was merged into the codebase and should be available in QEMU 2.8. From there we can use 'size' and 'offset' options in raw driver to tell QEMU to use only subset of a file as an image. The first three
2016 May 23
7
[PATCH 1/5] mllib: make external_command echo the command executed
Add an optional parameter to disable this behaviour, so the Curl module in v2v won't print user-sensible data (like passwords). --- builder/checksums.ml | 1 - builder/downloader.ml | 1 - builder/sigchecker.ml | 1 - mllib/common_utils.ml | 4 +++- mllib/common_utils.mli | 7 +++++-- v2v/curl.ml | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git
2016 May 23
0
[PATCH 5/5] mllib: add a new run_command helper
...common_utils.ml b/mllib/common_utils.ml index 0332510..2fcbbae 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -679,6 +679,21 @@ let external_command ?(echo_cmd = true) cmd = ); lines +let run_command ?(echo_cmd = true) args = + if echo_cmd then + debug "%s" (stringify_args args); + let pid = + Unix.create_process args.(0) args Unix.stdin Unix.stdout Unix.stderr in + let _, stat = Unix.waitpid [] pid in + match stat with + | Unix.WEXITED i -> i + | Unix.WSIGNALED i -> + error (f_"external command '%s' killed by signal %d") + (s...
2017 Jun 20
0
[PATCH v2 2/2] dib: use Common_utils.run_commands
...fn ^ "." ^ csum in let csum_tool = tool_of_checksum csum in let outfd = Unix.openfile csum_fn file_flags 0o640 in - Unix.set_close_on_exec outfd; - let args = [| csum_tool; fn; |] in - Common_utils.debug "%s" (stringify_args (Array.to_list args)); - let pid = Unix.create_process csum_tool args Unix.stdin - outfd Unix.stderr in - (pid, csum_tool, outfd) + [ csum_tool; fn ], Some outfd, None ) checksums in - let pids = ref pids in -...
2016 Nov 21
2
Re: [PATCH v2 4/5] v2v: ova: don't extract files from OVA if it's not needed
...) > @@ -135,6 +183,59 @@ object > loop [dir] > in > > + (* Find file in [tar] archive and return at which byte it starts and how > + * long it is. > + *) > + let find_file_in_tar tar filename = > + let lines = external_command (stringify_args [ "tar"; "tRvf"; tar ]) in stringify_args is meant to be used for displaying, rather than passing it back as shell command. Please just build a command string as done in the rest of the places. > + let rec loop lines = > + match lines with > + | []...
2016 Nov 12
0
[PATCH v2 4/5] v2v: ova: don't extract files from OVA if it's not needed
...ed, compress with gzip or xz), zip") ova ) @@ -135,6 +183,59 @@ object loop [dir] in + (* Find file in [tar] archive and return at which byte it starts and how + * long it is. + *) + let find_file_in_tar tar filename = + let lines = external_command (stringify_args [ "tar"; "tRvf"; tar ]) in + let rec loop lines = + match lines with + | [] -> raise Not_found + | line :: lines -> ( + (* Lines have the form: + * block <offset>: <perms> <owner>/<group> <size> &l...
2016 Nov 12
9
[PATCH v2 0/5] Import directly from OVA tar archive if possible
This series is related to the problem of inefficient import of OVA files. The needed enhancements of QEMU were merged into the codebase and should be available in QEMU 2.8. From there we can use 'size' and 'offset' options in raw driver to tell QEMU to use only subset of a file as an image. The patch set is more or less complete. The only outstanding issue is the missing detection
2017 Jul 19
2
Re: [PATCH 02/27] daemon: Allow parts of the daemon and APIs to be written in OCaml.
...r option here, instead of the manual implementation, would be to bind the C command* APIs -- this way there is no need to do fixes & additions in both places. > + if verbose () then > + eprintf "command: %s %s\n%!" > + prog (String.concat " " args); stringify_args could help here. > + let argv = Array.of_list (prog :: args) in > + > + let stdout_file, stdout_chan = Filename.open_temp_file "cmd" ".out" in > + let stderr_file, stderr_chan = Filename.open_temp_file "cmd" ".err" in > + let stdout_fd =...
2017 Jun 15
0
[PATCH v6 04/41] mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
...i1+1) i2 (* ignore '-' characters *) + else if uuid2.[i2] = '-' then loop i1 (i2+1) + else ( + let c = compare uuid1.[i1] uuid2.[i2] in + if c <> 0 then c (* not matching *) + else loop (i1+1) (i2+1) + ) + in + loop 0 0 + +let stringify_args args = + let rec quote_args = function + | [] -> "" + | x :: xs -> " " ^ Filename.quote x ^ quote_args xs + in + match args with + | [] -> "" + | app :: xs -> app ^ quote_args xs + +(* Unlink a temporary file on exit. *) +let unlink_on_exit = +...
2016 Dec 08
4
[PATCH] generator: Share Common_utils code.
...else []) in Getopt.create argspec ?anon_fun usage_msg +(*<stdlib>*) + (* Compare two version strings intelligently. *) let rex_numbers = Str.regexp "^\\([0-9]+\\)\\(.*\\)$" let rex_letters = Str.regexp_case_fold "^\\([a-z]+\\)\\(.*\\)$" @@ -684,6 +772,8 @@ let stringify_args args = | [] -> "" | app :: xs -> app ^ quote_args xs +(*</stdlib>*) + (* Run an external command, slurp up the output as a list of lines. *) let external_command ?(echo_cmd = true) cmd = if echo_cmd then @@ -748,6 +838,8 @@ let uuidgen () = if len < 10 then...
2017 Feb 02
7
[PATCH 0/6] dib: various improvements
Hi, this series improves virt-dib, adding some upstream changes, and refactoring the handling of output formats. Thanks, Pino Toscano (6): dib: clear up "already provided" message dib: add --checksum dib: pass custom mkfs options after the filesystem type dib: refactor output formats handling dib: clarify "output:" lines in --machine-readable documentation dib:
2018 Aug 17
8
[PATCH v3 4/4] v2v: Add --print-estimate option to print copy size
I rethought this again, as I think that it's a dangerous assumption to bake qemu-img measure output into our API. This patch series runs qemu-img measure behind the scenes, but then parses the output and sums it to a single number which we print. Doing that required a bit of reworking, moving the Jansson [JSON parser] bindings from virt-builder into the common directory and a couple of other
2017 Jul 21
0
[PATCH v2 01/23] daemon: Allow parts of the daemon and APIs to be written in OCaml.
...+let commandr ?(flags = []) prog args = + let fold_stdout_on_stderr = List.mem CommandFlagFoldStdoutOnStderr flags in + + if verbose () then + eprintf "command: %s %s\n%!" + (if fold_stdout_on_stderr then " fold-stdout-on-stderr" else "") + (stringify_args (prog :: args)); + + let argv = Array.of_list (prog :: args) in + + let stdout_file, stdout_chan = Filename.open_temp_file "cmd" ".out" in + let stderr_file, stderr_chan = Filename.open_temp_file "cmd" ".err" in + let stdout_fd = descr_of_out_channel std...
2017 Jun 19
16
[PATCH v7 00/13] Refactor utilities
This is just the utilities part of the patch series from: https://www.redhat.com/archives/libguestfs/2017-June/msg00103.html I believe this addresses everything raised in comments on that patch series. Rich.