debug.ml 962 Bytes
Newer Older
Philippe Veber's avatar
Philippe Veber committed
1
open Core
Philippe Veber's avatar
Philippe Veber committed
2 3 4 5 6 7
open Bistro
open Bistro_engine

let with_workflow w ~f =
  let open Scheduler in
  let db = Db.init_exn "_bistro" in
Philippe Veber's avatar
Philippe Veber committed
8 9
  let loggers = [ Bistro_utils.Console_logger.create () ] in
  let sched = create ~np:8 ~mem:(`GB 8) ~loggers db in
Philippe Veber's avatar
Philippe Veber committed
10 11
  let thread = eval_exn sched w in
  start sched ;
12 13 14 15 16 17 18 19
  try
    Lwt_main.run thread
    |> f
  with Failure msg -> (
      print_endline msg ;
      failwith "Failed!"
    )
     | exn -> raise exn
Philippe Veber's avatar
Philippe Veber committed
20

Philippe Veber's avatar
Philippe Veber committed
21 22 23
let eval w =
  with_workflow w ~f:Fn.id

Philippe Veber's avatar
Philippe Veber committed
24
let path w =
Philippe Veber's avatar
Philippe Veber committed
25
  with_workflow (Workflow.eval_path w) ~f:(fun x -> x)
Philippe Veber's avatar
Philippe Veber committed
26 27 28 29 30

let less w =
  Sys.command (sprintf "less %s" (path w))
  |> ignore

31 32 33 34
let firefox w =
  Sys.command (sprintf "firefox %s" (path w))
  |> ignore

LANORE Vincent's avatar
LANORE Vincent committed
35 36 37 38
let seaview w =
  Sys.command (sprintf "seaview %s" (path w))
  |> ignore

Philippe Veber's avatar
Philippe Veber committed
39 40 41 42
let evince w =
  Sys.command (sprintf "evince %s" (path w))
  |> ignore

Philippe Veber's avatar
Philippe Veber committed
43
let workflow_of_template t =
Philippe Veber's avatar
Philippe Veber committed
44 45
  let open Bistro.Shell_dsl in
  Workflow.shell [
Philippe Veber's avatar
Philippe Veber committed
46 47 48
    cmd "cp" [ file_dump t ; dest ]
  ]

49