search for: echo_cmd

Displaying 20 results from an estimated 44 matches for "echo_cmd".

2019 Jan 16
0
[PATCH 2/5] mltools: create a new external_command_code
...4c5a..e6b2b5713 100644 --- a/common/mltools/tools_utils.ml +++ b/common/mltools/tools_utils.ml @@ -338,7 +338,13 @@ let create_standard_options argspec ?anon_fun ?(key_opts = false) ?(machine_read } (* Run an external command, slurp up the output as a list of lines. *) -let external_command ?(echo_cmd = true) cmd = +let rec external_command ?(echo_cmd = true) cmd = + let lines, exitcode = external_command_code ~echo_cmd cmd in + if exitcode <> 0 then + error (f_"external command ā€˜%sā€™ exited with error %d") cmd exitcode; + lines + +and external_command_code ?(echo_cmd = true...
2019 Jan 16
2
Re: [PATCH 2/5] mltools: create a new external_command_code
...ommon/mltools/tools_utils.ml > +++ b/common/mltools/tools_utils.ml > @@ -338,7 +338,13 @@ let create_standard_options argspec ?anon_fun ?(key_opts = false) ?(machine_read > } > > (* Run an external command, slurp up the output as a list of lines. *) > -let external_command ?(echo_cmd = true) cmd = > +let rec external_command ?(echo_cmd = true) cmd = > + let lines, exitcode = external_command_code ~echo_cmd cmd in > + if exitcode <> 0 then > + error (f_"external command ā€˜%sā€™ exited with error %d") cmd exitcode; > + lines > + > +and exte...
2017 Jun 20
2
[PATCH v2 1/2] mllib: add new Common_utils.run_commands
...tils_tests.ml | 70 ++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 18 deletions(-) diff --git a/mllib/common_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, s...
2019 Jan 16
10
[PATCH 0/5] [RFC] builder: handle unavailable repos
In case a repository of virt-builder references files (e.g. the index) that cannot be downloaded (network issues, 404, etc) then virt-builder errors out on this situation. This is not a nice situation, from an user POV. This series does some refactoring to allow to better handle downloading failures, and handle the failures gracefully in virt-builder. RFC because I'm not yet too convinced
2017 Apr 07
1
[PATCH 1/2] mllib: add new Common_utils.run_commands
...b/common_utils_tests.ml | 50 ++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 22 deletions(-) diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 73546d7..0008d3a 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -825,29 +825,70 @@ let external_command ?(echo_cmd = true) cmd = ); lines +let run_commands ?(echo_cmd = true) cmds = + let res = Array.make (List.length cmds) 0 in + let get_fd default = function + | None -> + default + | Some fd -> + Unix.set_close_on_exec fd; + fd + in + let pids = + mapi ( + fun i...
2016 Aug 02
0
[PATCH] mllib: check for executable existance in run_command (RHBZ#1362357)
...lib/common_utils.ml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --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...
2016 May 23
7
[PATCH 1/5] mllib: make external_command echo the command executed
...ib/common_utils.ml index 0ffa92c..32071f4 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -649,7 +649,9 @@ let compare_lvm2_uuids uuid1 uuid2 = loop 0 0 (* Run an external command, slurp up the output as a list of lines. *) -let external_command cmd = +let external_command ?(echo_cmd = true) cmd = + if echo_cmd then + debug "%s" cmd; let chan = Unix.open_process_in cmd in let lines = ref [] in (try while true do lines := input_line chan :: !lines done diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli index 666e023..a216e21 100644 --- a/mllib/co...
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
2003 May 22
1
readmes
...5:39 2003 +++ bsd.port.mk Thu May 22 21:00:53 2003 @@ -3969,26 +3969,27 @@ @cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} ${.CURDIR}/README.html .endif ${.CURDIR}/README.html: @${ECHO_MSG} "===> Creating README.html for ${PKGNAME}" - @${SED} -e 's|%%PORT%%|'$$(${ECHO_CMD} ${.CURDIR} | \ + @__softMAKEFLAGS='${__softMAKEFLAGS:S/'/'\''/g}'; \ + ${SED} -e 's|%%PORT%%|'$$(${ECHO_CMD} ${.CURDIR} | \ ${SED} -e 's|.*/\([^/]*/[^/]*\)$$|\1|')'|g' \ -e 's|%%PKG%%|${PKGNAME}|g' \ -e 's|%%COMMENT%%|...
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 May 23
0
[PATCH 5/5] mllib: add a new run_command helper
...tring.length str > 0 && str.[String.length str - 1] <> '\n' then str ^ "\n" diff --git a/mllib/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 + | Un...
2016 May 23
0
[PATCH 4/5] mllib: move stringify_args from dib
...unction + | [] -> "" + | x :: xs -> " " ^ (Filename.quote x) ^ quote_args xs + in + match args with + | [] -> "" + | app :: xs -> app ^ quote_args xs + (* Run an external command, slurp up the output as a list of lines. *) let external_command ?(echo_cmd = true) cmd = if echo_cmd then diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli index 7f288b4..5bcc692 100644 --- a/mllib/common_utils.mli +++ b/mllib/common_utils.mli @@ -239,6 +239,10 @@ val compare_version : string -> string -> int val compare_lvm2_uuids : string -> stri...
2003 Dec 31
0
3.01 & FreeBSD Port/Install Makefile Config
...${SAMBA_PRIVATE}/smbpasswd ; \ ${CHMOD} 600 ${SAMBA_PRIVATE}/smbpasswd ; \ fi ${CHMOD} 500 ${SAMBA_PRIVATE} ${CHOWN} root:wheel ${PREFIX}/bin/smbpasswd ${CHMOD} 111 ${PREFIX}/bin/smbpasswd .if defined(PACKAGE_BUILDING) ${ECHO_CMD} "private/smbpasswd" >> ${TMPPLIST} ${ECHO_CMD} "@dirrm private" >> ${TMPPLIST} .else ${ECHO_CMD} "@unexec ${ECHO_CMD} \"Warning: If you will *NOT* use this package anymore, please remove %D/private/smbpasswd manually.\"" >>...
2018 Nov 19
2
[PATCH] common/mltools: Add a debug statement when we try to run a non-existent program.
...ltools/tools_utils.ml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml index ad08d05eb..298d89b4d 100644 --- a/common/mltools/tools_utils.ml +++ b/common/mltools/tools_utils.ml @@ -420,9 +420,11 @@ and do_run ?(echo_cmd = true) ?stdout_fd ?stderr_fd args = Either (pid, app, stdout_fd, stderr_fd) with | Executable_not_found _ -> - Or 127 - | Unix.Unix_error (errcode, _, _) when errcode = Unix.ENOENT -> - Or 127 + debug "%s: executable not found" app; + Or 127 + | Unix.Unix...
2019 Jan 08
1
[PATCH] v2v: -o openstack: Don't echo full commands (RHBZ#1664310).
...; [O_WRONLY] 0) in - (* Note that run_command will close stdout_fd if defined. *) - Tools_utils.run_command ?stdout_fd cmd + (* Note that run_command will close stdout_fd if defined. + * Don't echo the command because it can contain passwords. + *) + Tools_utils.run_command ~echo_cmd:false ?stdout_fd cmd in (* Similar to above, run the openstack command and capture the @@ -192,8 +194,10 @@ class output_openstack output_conn output_password output_storage unlink_on_exit json; let fd = descr_of_out_channel chan in - (* Note that Tools_utils.run_command clos...
2019 Jan 11
0
[PATCH 3/3] OCaml: use the new behaviour of Std_utils.which
...| 12 +----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml index 3c7e1b846..24641369e 100644 --- a/common/mltools/tools_utils.ml +++ b/common/mltools/tools_utils.ml @@ -408,9 +408,7 @@ and do_run ?(echo_cmd = true) ?stdout_fd ?stderr_fd args = fd in try - let app = - if Filename.is_relative app then which app - else (Unix.access app [Unix.X_OK]; app) in + let app = which app in let outfd = get_fd Unix.stdout stdout_fd in let errfd = get_fd Unix.stderr stderr_fd i...
2019 Jan 16
0
[PATCH 4/5] mltools: curl: turn Curl.run to raise exceptions
...= let args = safe_args @ args_of_proxy proxy @ args in { curl = curl; args = args; tmpdir = tmpdir } @@ -71,8 +73,19 @@ let run { curl; args; tmpdir } = close_out chan; let cmd = sprintf "%s -q --config %s" (quote curl) (quote config_file) in - let lines = external_command ~echo_cmd:false cmd in + let lines, exitcode = external_command_code ~echo_cmd:false cmd in Unix.unlink config_file; + if exitcode <> 0 then ( + let url = + try + List.find_map ( + function + | "url", Some url -> Some url + | _, _ -> None +...
2019 Jan 11
3
[PATCH 1/3] mlstdutils: add a very simple test for Std_utils.which
--- common/mlstdutils/std_utils_tests.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/mlstdutils/std_utils_tests.ml b/common/mlstdutils/std_utils_tests.ml index 81f512cbf..f7b0247a4 100644 --- a/common/mlstdutils/std_utils_tests.ml +++ b/common/mlstdutils/std_utils_tests.ml @@ -29,6 +29,11 @@ let assert_equal_int = assert_equal ~printer:(fun x -> string_of_int x)
2018 Sep 19
0
[PATCH 1/2] mltools: create a cmdline_options struct
...s_"Make output machine readable"; ] else []) in - Getopt.create argspec ?anon_fun usage_msg + let getopt = Getopt.create argspec ?anon_fun usage_msg in + { + getopt; + } (* Run an external command, slurp up the output as a list of lines. *) let external_command ?(echo_cmd = true) cmd = diff --git a/common/mltools/tools_utils.mli b/common/mltools/tools_utils.mli index 2b8c2b78a..99984bfa1 100644 --- a/common/mltools/tools_utils.mli +++ b/common/mltools/tools_utils.mli @@ -74,7 +74,13 @@ val machine_readable : unit -> machine_readable_fn option readable output...
2018 Nov 20
0
Re: [PATCH] common/mltools: Add a debug statement when we try to run a non-existent program.
...> 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml > index ad08d05eb..298d89b4d 100644 > --- a/common/mltools/tools_utils.ml > +++ b/common/mltools/tools_utils.ml > @@ -420,9 +420,11 @@ and do_run ?(echo_cmd = true) ?stdout_fd ?stderr_fd args = > Either (pid, app, stdout_fd, stderr_fd) > with > | Executable_not_found _ -> > - Or 127 > - | Unix.Unix_error (errcode, _, _) when errcode = Unix.ENOENT -> > - Or 127 > + debug "%s: executable not found&quo...