package bistro

  1. Overview
  2. Docs
A library to build and run distributed scientific workflows

Install

Dune Dependency

Authors

Maintainers

Sources

bistro-0.6.0.tbz
sha256=146177faaaa9117a8e2bf0fd60cb658662c0aa992f35beb246e6fd0766050e66
sha512=553fe0c20f236316449b077a47e6e12626d193ba1916e9da233e5526dd39090e8677277e1c79baace3bdc940cb009f25431730a8efc00ae4ed9cc42a0add9609

doc/src/bistro.unix/bistro_unix.ml.html

Source file bistro_unix.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
open Bistro
open Bistro.Shell_dsl
open Printf

let ident x = x

module Cmd = struct
  let wget ?no_check_certificate ?user_agent ?user ?password ?dest url =
    cmd "wget" [
      option (flag string "--no-check-certificate") no_check_certificate ;
      option (opt "--user-agent" string) user_agent ;
      option (opt "--user" string) user ;
      option (opt "--password" string) password ;
      option (opt "-O" ident) dest ;
      string_dep url ;
    ]

  (* process substitution for gunzip *)
  let gzdep (gz : _ gz file) =
    seq ~sep:"" [
      string "<(gunzip -c " ;
      dep gz ;
      string ")"
    ]

  let gzdest =
    seq ~sep:"" [
      string ">(gzip -c > " ;
      dest ;
      string ")" ;
    ]
end

let wget_dyn ?descr_url ?no_check_certificate ?user_agent ?user ?password url =
  let info = match descr_url with None -> "" | Some i -> sprintf "(%s)" i in
  Workflow.shell ~descr:("unix.wget" ^ info) [
    Cmd.wget ?no_check_certificate ?user_agent ?user ?password ~dest url
  ]

let wget ?descr_url ?no_check_certificate ?user_agent ?user ?password url =
  wget_dyn ?descr_url ?no_check_certificate ?user_agent ?user ?password (Workflow.string url)

let unzip zip =
  Workflow.shell ~descr:"unix.unzip" [
    cmd "unzip" [ opt "-d" ident dest ; dep zip ]
  ]

let gzip x =
  Workflow.shell ~descr:"unix.gunzip" [
    cmd "gzip" [ opt "-c" dep x ] ~stdout:dest
  ]

let gunzip gz =
  Workflow.shell ~descr:"unix.gunzip" [
    cmd "gunzip" [ opt "-c" dep gz ] ~stdout:dest
  ]

let bunzip2 bz2 =
  Workflow.shell ~descr:"unix.bunzip2" [
    cmd "bunzip2" [ opt "-c" dep bz2 ] ~stdout:dest
  ]

let tar_xf ?strip_components tar =
  Workflow.shell ~descr:"unix.tar_xf" [
    mkdir_p dest ;
    cmd "tar" [
      string "xf" ;
      dep tar ;
      opt "-C" ident dest ;
      option (opt "--strip-components" int) strip_components ;
    ] ;
  ]

let tar_xfz ?strip_components tgz =
  Workflow.shell ~descr:"unix.tar_xfz" [
    mkdir_p dest ;
    cmd "tar" [
      string "xfz" ;
      dep tgz ;
      opt "-C" ident dest ;
      option (opt "--strip-components" int) strip_components ;
    ] ;
  ]

let tar_xfj ?strip_components tgj =
  Workflow.shell ~descr:"unix.tar_xfj" [
    mkdir_p dest ;
    cmd "tar" [
      string "xfj" ;
      dep tgj ;
      opt "-C" ident dest ;
      option (opt "--strip-components" int) strip_components ;
    ] ;
  ]

let crlf2lf f =
  Workflow.shell ~descr:"unix.crlf2lf" [
    cmd "tr" [ opt "-d" string "'\r'"] ~stdin:(dep f) ~stdout:dest
  ]

let head ~n f =
  Workflow.shell ~descr:"unix.head" [
    cmd "head" [ opt "-n" int n ] ~stdin:(dep f) ~stdout:dest
  ]
OCaml

Innovation. Community. Security.