-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·142 lines (110 loc) · 1.9 KB
/
run.sh
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
#
# Usage:
# ./run.sh <function name>
#
# TODO: Separate out user facing parts?
# webpipe serve?
# webpipe copy?
# two scripts use TNET.
export PYTHONPATH=.:~/hg/tnet/python:~/hg/json-template/python
log() {
echo 1>&2 "$@"
}
unit() {
"$@"
}
#
# Combinations
#
serve-rendered() {
local outdir=remote-out
# Crap, I think I need this.
export PYTHONUNBUFFERED=1
./webpipe.py serve-rendered --out-dir=$outdir "$@"
}
# watch a directory, and print HTML snippets on stdout
print-parts() {
export PYTHONUNBUFFERED=1
local dir=${1:-~/webpipe/default}
print-events $dir | file2html $dir
}
test-file2html() {
csv-demo > ~/webpipe/default/table.csv
{ ./file2html.py ~/webpipe/default <<EOF
Rplot001.png
table.csv
EOF
} | remove-nonprintable
}
# Found here
# http://www.unix.com/shell-programming-scripting/14108-remove-non-printing-chars.html
remove-nonprintable() {
tr -c '[:print:]' '_'
}
test-server() {
./webpipe.py <<EOF
<p>one</p>
<p>two</p>
EOF
}
usage-sink() {
# listen in UDP mode on port 8988
log 'usage sink'
nc -v -u -l localhost 8988
}
usage-send() {
echo foo | nc -u localhost 8988
}
usage-config() {
echo localhost:8988 > usage-address.txt
}
#
# Demo
#
html-demo() {
cat <<EOF
<p>HTML</p>
<ul>
<li> <b>Bold</b> </li>
<li> <i>Italic</i> </li>
<li> <code>Code</code> </li>
</ul>
EOF
}
txt-demo() {
cat <<EOF
This a plain text file. <tags> & stuff aren't special.
Line two.
Line three.
EOF
}
csv-demo() {
cat <<EOF
name,age
<carol>,10
<dave>,20
EOF
}
write-demo() {
local dest=~/webpipe/default
set -x
sleep 1
touch $dest/Rplot001.png
sleep 1
html-demo > $dest/test.html
sleep 1
txt-demo > $dest/test.txt
sleep 1
csv-demo > $dest/test.csv
sleep 1
echo 'file with unknown extension' > $dest/other.other
}
#
# Latch
#
# for doc.sh, use Makefile perhaps?
latch-demo() {
./latch.sh rebuild ./doc.sh README.md doc/*.md
}
"$@"