Displaying 20 results from an estimated 64 matches for "open_temp_file".
2020 Apr 06
0
[v2v PATCH 2/2] Consolidate handling of temporary files/dirs
...ls
open JSON_parser
open Common_gettext.Gettext
+open Utils
+
(* Run qemu-img measure on a disk. *)
let measure ?format filename =
@@ -38,8 +40,7 @@ let measure ?format filename =
List.push_back cmd "--output=json";
List.push_back cmd filename;
- let json, chan = Filename.open_temp_file "v2vmeasure" ".json" in
- unlink_on_exit json;
+ let json, chan = Filename.open_temp_file ~temp_dir:tmpdir "v2vmeasure" ".json" in
let fd = Unix.descr_of_out_channel chan in
if run_command ~stdout_fd:fd !cmd <> 0 then
error (f_"qemu-im...
2020 Apr 06
4
[v2v PATCH 1/2] v2v: nbdkit: change base dir for nbdkit sockets/pidfiles
Since this new temporary directory will contain UNIX sockets for
communicating with nbdkit, then its path must not be too long.
Use the existing directory that libguestfs exposes for this, i.e.
sockdir.
---
v2v/nbdkit.ml | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml
index 65317f9b..46b20c9d 100644
--- a/v2v/nbdkit.ml
+++ b/v2v/nbdkit.ml
2018 Feb 28
1
Re: [PATCH v2 2/3] v2v: utils: Add utility functions for running external Python code.
...> + (* In debug mode output the python code into 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
quote filename
Tomas
> + let lines = external_command cmd in
> + Unix.unlink filename;
> + lines
> +
> +l...
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
2016 Sep 15
1
[PATCH] v2v: -o libvirt: always write pool names (RHBZ#1141631)
...ut_libvirt oc output_pool = object
(* Create the metadata. *)
let doc =
- create_libvirt_xml ~pool:output_pool source target_buses
+ create_libvirt_xml ~pool:pool_name source target_buses
guestcaps target_features target_firmware in
let tmpfile, chan = Filename.open_temp_file "v2vlibvirt" ".xml" in
--
2.7.4
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.
...essed file, returning the
+ * type of the uncompressed content (if known).
+ *)
+let uncompressed_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_op...
2016 Jul 07
0
[PATCH v3 2/8] curl: Change the API to use an abstract data type.
...f --git a/mllib/curl.ml b/mllib/curl.ml
index f0af160..d7983ec 100644
--- a/mllib/curl.ml
+++ b/mllib/curl.ml
@@ -20,10 +20,32 @@ open Printf
open Common_utils
-type curl_args = (string * string option) list
+let quote = Filename.quote
-let run curl_args =
- let config_file, chan = Filename.open_temp_file "v2vcurl" ".conf" in
+type t = {
+ curl : string;
+ args : args;
+}
+and args = (string * string option) list
+
+let safe_args = [
+ "max-redirs", Some "5";
+ "globoff", None; (* Don't glob URLs. *)
+]
+
+type proxy = UnsetProxy | Sy...
2016 Jul 07
0
[PATCH v2 2/8] curl: Change the API to use an abstract data type.
...f --git a/mllib/curl.ml b/mllib/curl.ml
index f0af160..a684fdb 100644
--- a/mllib/curl.ml
+++ b/mllib/curl.ml
@@ -20,10 +20,19 @@ open Printf
open Common_utils
-type curl_args = (string * string option) list
+let quote = Filename.quote
-let run curl_args =
- let config_file, chan = Filename.open_temp_file "v2vcurl" ".conf" in
+type t = {
+ curl : string;
+ args : args;
+}
+and args = (string * string option) list
+
+let create ?(curl = "curl") args =
+ { curl = curl; args = args }
+
+let run { curl = curl; args = args } =
+ let config_file, chan = Filename.open_temp...
2014 Feb 21
2
Re: [PATCH 2/2] builder: use a disposable GPG keyring for every Sigchecker
...let r = Sys.command cmd in
> @@ -188,23 +206,40 @@ and do_verify t args =
> exit 1
> )
>
> -(* Import the default public 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 ke...
2016 Oct 25
2
[PATCH v2 1/2] mllib: curl: add optional tmpdir parameter
...args =
+let create ?(curl = "curl") ?(proxy = SystemProxy) ?tmpdir args =
let args = safe_args @ args_of_proxy proxy @ args in
- { curl = curl; args = args }
+ { curl = curl; args = args; tmpdir = tmpdir }
-let run { curl = curl; args = args } =
- let config_file, chan = Filename.open_temp_file "guestfscurl" ".conf" in
+let run { curl = curl; args = args; tmpdir = tmpdir } =
+ let config_file, chan = Filename.open_temp_file ?temp_dir:tmpdir
+ "guestfscurl" ".conf" in
List.iter (
function
| name, None -> fprintf chan "%s\n&qu...
2016 Jul 07
4
[PATCH 0/3] Move Curl wrapper to mllib and use it for virt-builder.
Move the Curl wrapper module from virt-v2v to mllib. Use the module
when virt-builder issues curl calls.
Rich.
2018 Feb 27
0
[PATCH v2 2/3] v2v: utils: Add utility functions for running external Python code.
...python = "python") code =
+ (* In debug mode output the python code into 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 "\\" "\\...
2019 Aug 13
0
[PATCH 3/3] generator: improve pod2text invocation
...od2text_memo_key = int option * bool * bool * string * string
(* width, trim, discard, name, longdesc *)
type pod2text_memo_value = 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 filenam...
2016 Oct 24
2
[PATCH 1/2] mllib: curl: add optional tmpdir parameter
...args =
+let create ?(curl = "curl") ?(proxy = SystemProxy) ?tmpdir args =
let args = safe_args @ args_of_proxy proxy @ args in
- { curl = curl; args = args }
+ { curl = curl; args = args; tmpdir = tmpdir }
-let run { curl = curl; args = args } =
- let config_file, chan = Filename.open_temp_file "guestfscurl" ".conf" in
+let run { curl = curl; args = args; tmpdir = tmpdir } =
+ let config_file, chan = Filename.open_temp_file ?temp_dir:tmpdir
+ "guestfscurl" ".conf" in
List.iter (
function
| name, None -> fprintf chan "%s\n&qu...
2018 Nov 20
1
[PATCH] v2v: -o openstack: Check openstack binary exists before running it.
...utput_conn output_password output_storage
* '-f json' to the args yourself.
*)
let run_openstack_command_capture_json args =
- let cmd = [ "openstack" ] @ extra_args @ args in
+ let cmd = [ openstack_binary ] @ extra_args @ args in
let json, chan = Filename.open_temp_file "v2vopenstack" ".json" in
unlink_on_exit json;
@@ -366,6 +376,9 @@ object
inherit output
method precheck () =
+ (* Check the openstack command exists. *)
+ error_unless_openstack_command_exists ();
+
(* Run the openstack command simply to check we can con...
2020 Apr 06
0
[PATCH virt-v2v v2 2/2] v2v: Allow large temporary directory to be set on a global basis.
...let t = Mkdtemp.temp_dir ~base_dir:large_tmpdir "ova." in
rmdir_on_exit t;
t in
@@ -221,8 +220,7 @@ and uncompress_head format file =
*)
and uncompressed_type format file =
let head, headlen = uncompress_head format file in
- let tmpfile, chan =
- Filename.open_temp_file "ova.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
diff --git a/v2v/python_script.ml b/v2v/python_script.ml
index 33c5e9a21..127cd0bb2 1...
2017 Jul 19
2
Re: [PATCH 02/27] daemon: Allow parts of the daemon and APIs to be written in OCaml.
...ditions 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 = descr_of_out_channel stdout_chan in
> + let stderr_fd = descr_of_out_channel stderr_chan in
> + let stdin_fd = openfile "/dev/n...
2017 May 08
3
[PATCH 0/3] v2v: -i ova: Prefer pigz or pxz for uncompressing OVA
https://bugzilla.redhat.com/show_bug.cgi?id=1448739
2018 Nov 23
2
[PATCH] v2v: Add support for libosinfo metadata
...(* Create the metadata. *)
let doc =
create_libvirt_xml ~pool:pool_name source targets target_buses
- guestcaps target_features target_firmware in
+ guestcaps target_features target_firmware inspect in
let tmpfile, chan = Filename.open_temp_file "v2vlibvirt" ".xml" in
DOM.doc_to_chan chan doc;
diff --git a/v2v/output_local.ml b/v2v/output_local.ml
index 2f4b4e6c9cfd..3a00ed58a72d 100644
--- a/v2v/output_local.ml
+++ b/v2v/output_local.ml
@@ -49,7 +49,7 @@ class output_local dir = object
error_unless_uefi_fi...