flor 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/CREDITS.md +21 -0
- data/LICENSE.txt +4 -1
- data/Makefile +4 -0
- data/README.md +8 -0
- data/flor.gemspec +10 -10
- data/lib/flor.rb +2 -2
- data/lib/flor/changes.rb +3 -3
- data/lib/flor/colours.rb +14 -8
- data/lib/flor/conf.rb +63 -58
- data/lib/flor/core.rb +4 -4
- data/lib/flor/core/executor.rb +65 -29
- data/lib/flor/core/node.rb +37 -20
- data/lib/flor/core/procedure.rb +182 -40
- data/lib/flor/core/texecutor.rb +125 -52
- data/lib/flor/djan.rb +111 -82
- data/lib/flor/dollar.rb +31 -30
- data/lib/flor/flor.rb +314 -237
- data/lib/flor/id.rb +7 -2
- data/lib/flor/log.rb +250 -245
- data/lib/flor/parser.rb +72 -38
- data/lib/flor/pcore/_arr.rb +10 -10
- data/lib/flor/pcore/_att.rb +49 -14
- data/lib/flor/pcore/_coll.rb +18 -0
- data/lib/flor/pcore/_obj.rb +23 -7
- data/lib/flor/pcore/_pat_.rb +1 -1
- data/lib/flor/pcore/_pat_guard.rb +8 -0
- data/lib/flor/pcore/_pat_obj.rb +3 -3
- data/lib/flor/pcore/_pat_or.rb +4 -0
- data/lib/flor/pcore/_pat_regex.rb +24 -0
- data/lib/flor/pcore/_skip.rb +4 -0
- data/lib/flor/pcore/_val.rb +0 -1
- data/lib/flor/pcore/all.rb +111 -0
- data/lib/flor/pcore/any.rb +83 -0
- data/lib/flor/pcore/arith.rb +35 -6
- data/lib/flor/pcore/break.rb +39 -1
- data/lib/flor/pcore/case.rb +82 -4
- data/lib/flor/pcore/cmp.rb +7 -7
- data/lib/flor/pcore/collect.rb +50 -0
- data/lib/flor/pcore/cond.rb +17 -3
- data/lib/flor/pcore/cursor.rb +8 -2
- data/lib/flor/pcore/detect.rb +45 -0
- data/lib/flor/pcore/each.rb +52 -0
- data/lib/flor/pcore/empty.rb +60 -0
- data/lib/flor/pcore/filter.rb +94 -0
- data/lib/flor/pcore/find.rb +67 -0
- data/lib/flor/pcore/for_each.rb +65 -0
- data/lib/flor/pcore/includes.rb +32 -0
- data/lib/flor/pcore/inject.rb +55 -0
- data/lib/flor/pcore/iterator.rb +151 -0
- data/lib/flor/pcore/keys.rb +60 -0
- data/lib/flor/pcore/length.rb +34 -7
- data/lib/flor/pcore/logo.rb +18 -0
- data/lib/flor/pcore/loop.rb +4 -0
- data/lib/flor/pcore/map.rb +77 -46
- data/lib/flor/pcore/match.rb +8 -2
- data/lib/flor/pcore/matchr.rb +4 -5
- data/lib/flor/pcore/move.rb +3 -3
- data/lib/flor/pcore/noeval.rb +13 -0
- data/lib/flor/pcore/not.rb +16 -0
- data/lib/flor/pcore/on.rb +172 -0
- data/lib/flor/pcore/on_cancel.rb +54 -0
- data/lib/flor/pcore/on_error.rb +68 -0
- data/lib/flor/pcore/rand.rb +2 -2
- data/lib/flor/pcore/range.rb +2 -1
- data/lib/flor/pcore/reduce.rb +124 -0
- data/lib/flor/pcore/reverse.rb +46 -0
- data/lib/flor/pcore/select.rb +72 -0
- data/lib/flor/pcore/set.rb +8 -0
- data/lib/flor/pcore/stall.rb +10 -0
- data/lib/flor/pcore/to_array.rb +61 -0
- data/lib/flor/pcore/until.rb +34 -0
- data/lib/flor/punit/cancel.rb +30 -5
- data/lib/flor/punit/ccollect.rb +11 -0
- data/lib/flor/punit/cmap.rb +10 -5
- data/lib/flor/punit/concurrence.rb +42 -51
- data/lib/flor/punit/cron.rb +33 -0
- data/lib/flor/punit/do_trap.rb +42 -0
- data/lib/flor/punit/every.rb +48 -13
- data/lib/flor/punit/graft.rb +3 -3
- data/lib/flor/punit/on_timeout.rb +38 -0
- data/lib/flor/punit/schedule.rb +69 -6
- data/lib/flor/punit/signal.rb +54 -0
- data/lib/flor/punit/sleep.rb +1 -1
- data/lib/flor/punit/task.rb +4 -1
- data/lib/flor/punit/trap.rb +188 -13
- data/lib/flor/tools/shell.rb +408 -62
- data/lib/flor/tools/shell_out.rb +31 -0
- data/lib/flor/unit.rb +1 -1
- data/lib/flor/unit/caller.rb +177 -0
- data/lib/flor/unit/executor.rb +1 -0
- data/lib/flor/unit/ganger.rb +15 -21
- data/lib/flor/unit/hook.rb +1 -1
- data/lib/flor/unit/hooker.rb +22 -10
- data/lib/flor/unit/loader.rb +22 -22
- data/lib/flor/unit/logger.rb +63 -36
- data/lib/flor/unit/models.rb +6 -1
- data/lib/flor/unit/models/execution.rb +12 -1
- data/lib/flor/unit/models/message.rb +7 -0
- data/lib/flor/unit/models/trap.rb +31 -17
- data/lib/flor/unit/scheduler.rb +18 -10
- data/lib/flor/unit/storage.rb +83 -23
- data/lib/flor/unit/waiter.rb +1 -2
- metadata +96 -52
- data/lib/flor/deep.rb +0 -144
- data/lib/flor/punit/on.rb +0 -57
- data/lib/flor/unit/runner.rb +0 -84
- data/match.md +0 -22
data/lib/flor/id.rb
CHANGED
@@ -35,9 +35,14 @@ module Flor
|
|
35
35
|
child_id(nid) + 1
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.sub_nid(nid, subid)
|
38
|
+
def self.sub_nid(nid, subid=nil)
|
39
39
|
|
40
|
-
|
40
|
+
if subid
|
41
|
+
"#{nid.split('-').first}-#{subid}"
|
42
|
+
else
|
43
|
+
ss = nid.split('-')
|
44
|
+
ss.length > 1 ? ss.last.to_i : 0
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
48
|
# Remove the sub_nid if any.
|
data/lib/flor/log.rb
CHANGED
@@ -1,321 +1,326 @@
|
|
1
1
|
|
2
2
|
module Flor
|
3
|
+
class << self
|
3
4
|
|
4
|
-
|
5
|
+
# Turns a flor message into a one line string.
|
6
|
+
# Used when logging messages.
|
7
|
+
#
|
8
|
+
def message_to_one_line_s(executor, m, opts={})
|
5
9
|
|
6
|
-
|
10
|
+
_c = colours(opts)
|
7
11
|
|
8
|
-
|
12
|
+
nid = m['nid']
|
13
|
+
nd = executor.node(nid)
|
9
14
|
|
10
|
-
|
11
|
-
nd = executor.node(nid)
|
15
|
+
a = [ ' ' ]
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
tm =
|
18
|
-
if opts[:date]
|
19
|
-
n.strftime('%Y%m%d.%H:%M:%S') + sprintf('.%06d', n.usec)[0, 4]
|
20
|
-
else
|
17
|
+
n = Time.now.utc
|
18
|
+
a <<
|
19
|
+
opts[:date] ?
|
20
|
+
n.strftime('%Y%m%d.%H:%M:%S') + sprintf('.%06d', n.usec)[0, 4] :
|
21
21
|
n.strftime('%H:%M:%S') + sprintf('.%06d', n.usec)[0, 4]
|
22
|
-
|
23
|
-
a << tm
|
24
|
-
a << ' '
|
25
|
-
a << _c.dg
|
22
|
+
a << ' ' << _c.dg
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
24
|
+
if ex = (m['exid'] || '').split('.').last
|
25
|
+
a << ex[-4..-1] << ' '
|
26
|
+
end
|
31
27
|
|
32
|
-
|
28
|
+
a << "#{nd ? _c.dg : _c.dim + _c.dg}#{nid}#{_c.rs}#{_c.dg} " if nid
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
pt = m['point'][0, 3]
|
31
|
+
_pt =
|
32
|
+
case pt
|
37
33
|
when 'tri', 'sig' then _c.gr
|
38
34
|
when 'cea', 'ter' then _c.lg
|
39
35
|
when 'can' then _c.ma
|
40
36
|
else _c.bl
|
37
|
+
end
|
38
|
+
a << "#{_pt}#{pt}#{_c.dg}"
|
39
|
+
|
40
|
+
fla = m['flavour']
|
41
|
+
a << " #{_c.lg}#{fla}#{_c.dg}" if fla
|
42
|
+
|
43
|
+
st = nd && nd['status'].last
|
44
|
+
a << " #{_c.dim}#{_c.lg}#{st['status']}:#{st['flavour']}#{_c.rs}#{_c.dg}" \
|
45
|
+
if st && st['status']
|
46
|
+
|
47
|
+
t = m['tree']
|
48
|
+
rw = (t && m['rewritten']) ? 'rw->' : ''
|
49
|
+
nt = t || Node.new(executor, nd, m).lookup_tree(nid)
|
50
|
+
a <<
|
51
|
+
if t
|
52
|
+
" [#{rw}#{_c.yl}#{Flor.to_d(t[0], compact: true)}#{_c.dg} L#{t[2]}]"
|
53
|
+
elsif nt
|
54
|
+
" [#{_c.dg}#{Flor.to_d(nt[0], compact: true)}#{_c.dg} L#{nt[2]}]"
|
55
|
+
else
|
56
|
+
''
|
57
|
+
end
|
58
|
+
|
59
|
+
a << m['on_error'] ? " #{_c.rd}on_error" : ''
|
60
|
+
|
61
|
+
tmi = m['timer_id']
|
62
|
+
tmi = tmi ? " #{_c.dg}tmi:#{tmi}" : ''
|
63
|
+
a << tmi
|
64
|
+
#
|
65
|
+
tri = m['trap_id']
|
66
|
+
tri = tri ? " #{_c.dg}tri:#{tri}" : ''
|
67
|
+
a << tri
|
68
|
+
|
69
|
+
cn = t ? " #{_c.dg}#{Flor.to_d(t[1], compact: true, inner: true)}" : ''
|
70
|
+
cn = Flor.truncate_string(cn, 49, "#{_c.dg}...#{_c.rs}")
|
71
|
+
a << cn
|
72
|
+
|
73
|
+
hp = nd && nd['heap']
|
74
|
+
hp = hp && (hp != (t || [])[0]) ? " #{_c.dg}hp:#{nd['heap']}" : ''
|
75
|
+
a << hp
|
76
|
+
|
77
|
+
msr = " #{_c.dg}m#{m['m']}s#{m['sm'] || '_'}"
|
78
|
+
msr << "r#{m['er']}>#{m['pr']}" if m['er'] && m['er'] > -1
|
79
|
+
a << msr
|
80
|
+
|
81
|
+
a << (m['from'] ? " from #{m['from']}" : '')
|
82
|
+
|
83
|
+
if cs = m['cause']
|
84
|
+
a << " <" << cs
|
85
|
+
.collect { |c|
|
86
|
+
[ c['cause'][0, 2], c['nid'], "m#{c['m']}", c['type'] ]
|
87
|
+
.compact.join(':') }
|
88
|
+
.join('<')
|
41
89
|
end
|
42
|
-
a << "#{_pt}#{pt}#{_c.dg}"
|
43
|
-
|
44
|
-
fla = m['flavour']
|
45
|
-
a << " #{_c.lg}#{fla}#{_c.dg}" if fla
|
46
|
-
|
47
|
-
st = nd && nd['status'].last
|
48
|
-
a << " #{_c.dim}#{_c.lg}#{st['status']}:#{st['flavour']}#{_c.rs}#{_c.dg}" \
|
49
|
-
if st && st['status']
|
50
|
-
|
51
|
-
t =
|
52
|
-
m['tree']
|
53
|
-
rw =
|
54
|
-
(t && m['rewritten']) ? 'rw->' : ''
|
55
|
-
nt =
|
56
|
-
t || Node.new(executor, nd, m).lookup_tree(nid)
|
57
|
-
t0 =
|
58
|
-
if t
|
59
|
-
" [#{rw}#{_c.yl}#{Flor.to_d(t[0], compact: true)}#{_c.dg} L#{t[2]}]"
|
60
|
-
elsif nt
|
61
|
-
" [#{_c.dg}#{Flor.to_d(nt[0], compact: true)}#{_c.dg} L#{nt[2]}]"
|
62
|
-
else
|
63
|
-
''
|
64
|
-
end
|
65
|
-
a << t0
|
66
|
-
|
67
|
-
oe = m['on_error'] ? " #{_c.rd}on_error" : ''
|
68
|
-
a << oe
|
69
|
-
|
70
|
-
tmi = m['timer_id']
|
71
|
-
tmi = tmi ? " #{_c.dg}tmi:#{tmi}" : ''
|
72
|
-
a << tmi
|
73
|
-
#
|
74
|
-
tri = m['trap_id']
|
75
|
-
tri = tri ? " #{_c.dg}tri:#{tri}" : ''
|
76
|
-
a << tri
|
77
|
-
|
78
|
-
cn = t ? " #{_c.dg}#{Flor.to_d(t[1], compact: true, inner: true)}" : ''
|
79
|
-
cn = Flor.truncate_string(cn, 49, "#{_c.dg}...#{_c.rs}")
|
80
|
-
a << cn
|
81
|
-
|
82
|
-
hp = nd && nd['heap']
|
83
|
-
hp = hp && (hp != (t || [])[0]) ? " #{_c.dg}hp:#{nd['heap']}" : ''
|
84
|
-
a << hp
|
85
|
-
|
86
|
-
msr = " #{_c.dg}m#{m['m']}s#{m['sm'] || '_'}"
|
87
|
-
msr << "r#{m['er']}>#{m['pr']}" if m['er'] && m['er'] > -1
|
88
|
-
a << msr
|
89
|
-
|
90
|
-
fr = m['from'] ? " from #{m['from']}" : ''
|
91
|
-
a << fr
|
92
|
-
|
93
|
-
rt = ret_to_s(executor, m, _c)
|
94
|
-
rt = rt.length > 0 ? " #{_c.lg}f.ret #{rt}" : ''
|
95
|
-
a << rt
|
96
|
-
|
97
|
-
ta =
|
98
|
-
m['point'] == 'entered' || m['point'] == 'left' ?
|
99
|
-
" #{_c.dg}tags:#{_c.gr}#{m['tags'].join(',')}" :
|
100
|
-
nil
|
101
|
-
a << ta
|
102
|
-
|
103
|
-
vs =
|
104
|
-
(nd && nd['vars']) ?
|
105
|
-
" #{_c.dg}vars:#{_c.gr}#{nd['vars'].keys.join("#{_c.dg},#{_c.gr}")}" :
|
106
|
-
''
|
107
|
-
a << vs
|
108
|
-
|
109
|
-
%w[ fpoint dbg ].each do |k|
|
110
|
-
a << " #{_c.dg}#{k}:#{m[k]}" if m.has_key?(k)
|
111
|
-
end
|
112
90
|
|
113
|
-
|
91
|
+
rt = ret_to_s(executor, m, _c)
|
92
|
+
rt = rt.length > 0 ? " #{_c.lg}f.ret #{rt}" : ''
|
93
|
+
a << rt
|
114
94
|
|
115
|
-
|
116
|
-
|
95
|
+
a << (
|
96
|
+
(m['point'] == 'entered' || m['point'] == 'left') ?
|
97
|
+
" #{_c.dg}tags:#{_c.gr}#{m['tags'].join(',')}" :
|
98
|
+
nil)
|
117
99
|
|
118
|
-
|
100
|
+
a << (
|
101
|
+
(nd && nd['vars']) ?
|
102
|
+
" #{_c.dg}vars:#{_c.gr}#{nd['vars'].keys.join("#{_c.dg},#{_c.gr}")}" :
|
103
|
+
'')
|
119
104
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
o.puts "#{_c.dg}+---#{_c.rs}"
|
105
|
+
%w[ fpoint dbg ].each do |k|
|
106
|
+
a << " #{_c.dg}#{k}:#{m[k]}" if m.has_key?(k)
|
107
|
+
end
|
124
108
|
|
125
|
-
|
109
|
+
a << _c.rs
|
126
110
|
|
127
|
-
|
128
|
-
|
129
|
-
.select { |l| l.strip.length > 0 && l.match(/\A\s*[^#]/) }
|
130
|
-
.each { |l| o.puts "#{_c.dg}| #{_c.yl}#{l}#{_c.rs}" }
|
131
|
-
else
|
132
|
-
Flor.to_pretty_s(src).split("\n")
|
133
|
-
.each { |l| o.puts "#{_c.dg}| #{_c.yl}#{l}#{_c.rs}" }
|
134
|
-
end
|
111
|
+
a.join
|
112
|
+
end # message_to_one_line_s
|
135
113
|
|
136
|
-
|
114
|
+
def src_to_s(src, launch_opts, opts={})
|
137
115
|
|
138
|
-
|
139
|
-
|
116
|
+
o = StringIO.new
|
117
|
+
_c = colours(opts)
|
140
118
|
|
141
|
-
|
119
|
+
o.puts "#{_c.dg}+---#{_c.rs}"
|
142
120
|
|
143
|
-
|
121
|
+
if launch_opts.any?
|
122
|
+
o.puts "#{_c.dg}| #{Flor.to_d(launch_opts, compact: true)}#{_c.rs}"
|
123
|
+
o.puts "#{_c.dg}|#{_c.rs}"
|
124
|
+
end
|
144
125
|
|
145
|
-
|
146
|
-
|
126
|
+
lines =
|
127
|
+
(src.is_a?(String) ? src : Flor.to_pretty_s(src))
|
128
|
+
.split("\n")
|
129
|
+
min = lines
|
130
|
+
.select { |l| l.strip.length > 0 }
|
131
|
+
.collect { |l| l.match(/\A(\s*)/)[1].length }
|
132
|
+
.min
|
133
|
+
lines
|
134
|
+
.each_with_index { |l, i|
|
135
|
+
o.puts "#{_c.dg}|#{"%4d" % (i + 1)} #{_c.yl}#{l[min..-1]}#{_c.rs}" }
|
147
136
|
|
148
|
-
|
137
|
+
o.puts "#{_c.dg}.#{_c.rs}"
|
149
138
|
|
150
|
-
|
151
|
-
|
139
|
+
o.string
|
140
|
+
end # src_to_s
|
152
141
|
|
153
|
-
|
154
|
-
c = t1.is_a?(Array) ? '' : " #{_c.yl}#{t1}"
|
155
|
-
l = " #{_c.dg}L#{t2}"
|
142
|
+
def tree_to_s(tree, nid='0', opts={})
|
156
143
|
|
157
|
-
|
158
|
-
o.puts "#{ind}#{_c.dg}| #{nid} #{h}#{c}#{l}#{_c.rs}"
|
159
|
-
if t1.is_a?(Array)
|
160
|
-
t1.each_with_index { |ct, i| print_tree(ct, Flor.child_nid(nid, i), opts) }
|
161
|
-
end
|
162
|
-
o.puts "#{ind}#{_c.dg}.#{_c.rs}" if headers && nid == '0'
|
144
|
+
t0, t1, t2 = (tree || [])
|
163
145
|
|
164
|
-
|
165
|
-
|
146
|
+
o = StringIO.new
|
147
|
+
_c = colours(opts)
|
166
148
|
|
167
|
-
|
149
|
+
ind = ' ' * (opts[:ind] || 0)
|
168
150
|
|
169
|
-
|
151
|
+
headers = opts[:headers]; headers = true if headers.nil?
|
152
|
+
headers = true if opts[:title]
|
170
153
|
|
171
|
-
|
154
|
+
h = "#{_c.yl}#{Flor.to_d(t0, opts.merge(compact: true))}"
|
155
|
+
c = t1.is_a?(Array) ? '' : " #{_c.yl}#{t1}"
|
156
|
+
l = " #{_c.dg}L#{t2}"
|
172
157
|
|
173
|
-
|
158
|
+
o.puts "#{ind}#{_c.dg}+--- #{opts[:title]}#{_c.rs}" if headers && nid == '0'
|
159
|
+
o.puts "#{ind}#{_c.dg}| #{nid} #{h}#{c}#{l}#{_c.rs}"
|
160
|
+
t1.each_with_index { |ct, i|
|
161
|
+
o.puts tree_to_s(ct, Flor.child_nid(nid, i), opts) } if t1.is_a?(Array)
|
162
|
+
o.puts "#{ind}#{_c.dg}.#{_c.rs}" if headers && nid == '0'
|
174
163
|
|
175
|
-
|
176
|
-
tree[1].each_with_index do |t, i|
|
177
|
-
print_flat_tree(t, "#{nid}_#{i}", opts)
|
178
|
-
end
|
179
|
-
else
|
180
|
-
s << ' ' << tree[1]
|
164
|
+
o.string
|
181
165
|
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def self.print_compact_tree(tree, nid='0', opts={})
|
185
166
|
|
186
|
-
|
167
|
+
def to_flat_tree_s(tree, nid, opts)
|
187
168
|
|
188
|
-
|
189
|
-
|
169
|
+
o = StringIO.new
|
170
|
+
_c = colours(opts)
|
190
171
|
|
191
|
-
|
192
|
-
tree[1].is_a?(Array) ?
|
193
|
-
tree[1].partition { |t| Flor.is_att_tree?(t) } :
|
194
|
-
[ [], [] ]
|
172
|
+
o << ' ' << nid << ' ' << _c.yl << tree[0] << _c.dg
|
195
173
|
|
196
|
-
|
174
|
+
if tree[1].is_a?(Array)
|
175
|
+
tree[1].each_with_index do |t, i|
|
176
|
+
o << to_flat_tree_s(t, "#{nid}_#{i}", opts)
|
177
|
+
end
|
178
|
+
else
|
179
|
+
o << ' ' << tree[1]
|
180
|
+
end
|
197
181
|
|
198
|
-
|
199
|
-
s << ind << _c.dg << '+--- ' << t << "\n"
|
182
|
+
o.string
|
200
183
|
end
|
201
184
|
|
202
|
-
|
203
|
-
s << _c.yl << Flor.to_d(tree[0], compact: true) << _c.dg << ' L' << tree[2]
|
185
|
+
def to_compact_tree_s(tree, nid='0', opts={})
|
204
186
|
|
205
|
-
|
206
|
-
|
207
|
-
end
|
187
|
+
o = StringIO.new
|
188
|
+
_c = colours(opts)
|
208
189
|
|
209
|
-
|
210
|
-
|
211
|
-
s << "\n"
|
212
|
-
print_compact_tree(ct, "#{nid}_#{i}", opts)
|
213
|
-
end
|
190
|
+
#is_root = opts[:s].nil?
|
191
|
+
ind = ' ' * (opts[:ind] || 0)
|
214
192
|
|
215
|
-
|
193
|
+
atts, natts =
|
194
|
+
tree[1].is_a?(Array) ?
|
195
|
+
tree[1].partition { |t| Flor.is_att_tree?(t) } :
|
196
|
+
[ [], [] ]
|
216
197
|
|
217
|
-
|
198
|
+
if t = opts.delete(:title)
|
199
|
+
o << ind << _c.dg << '+--- ' << t << "\n"
|
200
|
+
end
|
218
201
|
|
219
|
-
|
220
|
-
|
202
|
+
o <<
|
203
|
+
ind << _c.dg << '| ' << nid << ' ' <<
|
204
|
+
_c.yl << Flor.to_d(tree[0], opts.merge(compact: true)) <<
|
205
|
+
_c.dg << ' L' << tree[2]
|
221
206
|
|
222
|
-
|
207
|
+
atts.each_with_index do |ct, i|
|
208
|
+
o << to_flat_tree_s(ct, "_#{i}", opts)
|
209
|
+
end
|
223
210
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
211
|
+
natts.each_with_index do |ct, i|
|
212
|
+
i = atts.size + i
|
213
|
+
o << "\n" << to_compact_tree_s(ct, "#{nid}_#{i}", opts)
|
214
|
+
end
|
228
215
|
|
229
|
-
|
216
|
+
#o << "\n" << ind << _c.dg << '\---' if is_root && opts[:close]
|
217
|
+
o << "\n" << ind << _c.dg << '\---' if opts[:close]
|
230
218
|
|
231
|
-
|
219
|
+
o << _c.rs
|
232
220
|
|
233
|
-
|
234
|
-
t = Flor.to_d(t, compact: true) if t
|
235
|
-
t = Flor.truncate_string(t, 42);
|
221
|
+
#opts[:out].puts(s.string) if is_root
|
236
222
|
|
237
|
-
|
238
|
-
%w[ parent cnid noreply dbg ].each do |k|
|
239
|
-
h[k] = n[k] if n.has_key?(k)
|
223
|
+
o.string
|
240
224
|
end
|
241
225
|
|
242
|
-
|
243
|
-
nr = n.has_key?('noreply') ? "nr:#{n['noreply']}" : nil
|
244
|
-
h = h.collect { |k, v| "#{k}:#{v}" }.join(' ')
|
226
|
+
def ret_to_s(executor, m, c)
|
245
227
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
228
|
+
ret = (m['payload'] || {})['ret']
|
229
|
+
s = Flor.to_d(ret, compact: true)
|
230
|
+
Flor.truncate_string(s, 35, Proc.new { |x| "#{c.dg}... (L#{x})#{c.rs}" })
|
231
|
+
end
|
250
232
|
|
251
|
-
|
233
|
+
def nod_to_s(executor, n, opts, here=false)
|
252
234
|
|
253
|
-
|
235
|
+
_c = colours(opts)
|
254
236
|
|
255
|
-
|
256
|
-
|
237
|
+
t = n['tree'] || Node.new(executor, n, nil).lookup_tree(n['nid'])
|
238
|
+
t = Flor.to_d(t, compact: true) if t
|
239
|
+
t = Flor.truncate_string(t, 42);
|
257
240
|
|
258
|
-
|
241
|
+
h = {}
|
242
|
+
%w[ parent cnid noreply dbg ].each do |k|
|
243
|
+
h[k] = n[k] if n.has_key?(k)
|
244
|
+
end
|
259
245
|
|
260
|
-
|
261
|
-
|
246
|
+
dbg = n['dbg'] ? "dbg:#{n['dbg']}" : nil
|
247
|
+
nr = n.has_key?('noreply') ? "nr:#{n['noreply']}" : nil
|
248
|
+
h = h.collect { |k, v| "#{k}:#{v}" }.join(' ')
|
262
249
|
|
263
|
-
|
264
|
-
|
250
|
+
vs = n['vars']
|
251
|
+
vs = 'vars:' + vs.keys.join(',') if vs
|
252
|
+
ts = n['tags']
|
253
|
+
ts = 'tags:' + ts.join(',') if ts
|
265
254
|
|
266
|
-
|
267
|
-
sio.print(nod_to_s(executor, n, opts, nid == msg['nid']))
|
268
|
-
sio.print("\n")
|
269
|
-
cn.each { |c| ncns_to_s(executor, c, msg, opts, sio, ind + ' ', seen) }
|
270
|
-
end
|
255
|
+
flr = n['failure'] ? "#{_c.rd}flre" : ''
|
271
256
|
|
272
|
-
|
257
|
+
here = here ? "#{_c.dg}<---msg['nid']" : nil
|
273
258
|
|
274
|
-
|
259
|
+
[ _c.yl + n['nid'], t, h, ts, vs, flr, here ].compact.join(' ')
|
260
|
+
end
|
275
261
|
|
276
|
-
|
277
|
-
nodes.values.each { |ncn|
|
278
|
-
pa = ncn.first['parent']; next unless pa
|
279
|
-
pan, pacn = nodes[pa]
|
280
|
-
pacn << ncn if pacn
|
281
|
-
}
|
262
|
+
def ncns_to_s(executor, ncn, msg, opts, sio, ind, seen)
|
282
263
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
264
|
+
n, cn = ncn
|
265
|
+
nid = n['nid']
|
266
|
+
|
267
|
+
return if seen.include?(nid)
|
268
|
+
seen << nid
|
269
|
+
|
270
|
+
sio.print(ind)
|
271
|
+
sio.print(nod_to_s(executor, n, opts, nid == msg['nid']))
|
272
|
+
sio.print("\n")
|
273
|
+
cn.each { |c| ncns_to_s(executor, c, msg, opts, sio, ind + ' ', seen) }
|
287
274
|
end
|
288
275
|
|
289
|
-
|
290
|
-
|
276
|
+
def nods_to_s(executor, msg, opts)
|
277
|
+
|
278
|
+
nodes = executor.execution['nodes'].values
|
279
|
+
|
280
|
+
nodes = nodes.inject({}) { |h, n| h[n['nid']] = [ n, [] ]; h }
|
281
|
+
nodes.values.each { |ncn|
|
282
|
+
pa = ncn.first['parent']; next unless pa
|
283
|
+
pan, pacn = nodes[pa]
|
284
|
+
pacn << ncn if pacn
|
285
|
+
}
|
291
286
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
287
|
+
sio = StringIO.new
|
288
|
+
seen = []
|
289
|
+
nodes.values.each do |ncn|
|
290
|
+
ncns_to_s(executor, ncn, msg, opts, sio, ' ', seen)
|
291
|
+
end
|
292
|
+
|
293
|
+
sio.string
|
294
|
+
end
|
295
|
+
|
296
|
+
def msg_to_detail_s(executor, m, opts={})
|
297
|
+
|
298
|
+
return if m['_detail_msg_flag']
|
299
|
+
m['_detail_msg_flag'] = true if opts[:flag]
|
300
|
+
|
301
|
+
o = StringIO.new
|
302
|
+
_c = colours(opts)
|
303
|
+
|
304
|
+
nid = m['nid']
|
305
|
+
n = executor.execution['nodes'][nid]
|
306
|
+
node = n ? Flor::Node.new(executor, n, m) : nil
|
307
|
+
|
308
|
+
o.puts "#{_c.dg}<Flor.msg_to_detail_s>#{_c.rs}#{_c.yl}"
|
309
|
+
o.puts Flor.to_pretty_s(m)
|
310
|
+
o.puts "#{_c.dg}payload:#{_c.yl}"
|
311
|
+
o.puts Flor.to_pretty_s(m['payload'], 0)
|
312
|
+
o.puts "#{_c.dg}tree:"
|
313
|
+
o.puts(tree_to_s(node.lookup_tree(nid), nid, out: o)) if node
|
314
|
+
o.puts "#{_c.dg}node:#{_c.yl}"
|
315
|
+
o.puts(Flor.to_pretty_s(n)) if n
|
316
|
+
o.puts "#{_c.dg}nodes:"
|
317
|
+
o.puts nods_to_s(executor, m, opts)
|
318
|
+
z = executor.execution['nodes'].size
|
319
|
+
o.puts "#{_c.yl}#{z} node#{z == 1 ? '' : 's'}."
|
320
|
+
o.puts "#{_c.dg}</Flor.msg_to_detail_s>#{_c.rs}"
|
321
|
+
|
322
|
+
o.string
|
323
|
+
end
|
319
324
|
end
|
320
325
|
end
|
321
326
|
|