summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2014-09-20 14:56:26 -0700
committerJoshua Harlow <harlowja@gmail.com>2014-09-20 20:39:13 -0700
commit96014cbba3bcb471d36796d2dc9662d22bd89552 (patch)
tree6f4eff50edc10056e4d0093e4f1cdd332b752bfe /tools
parentce628870acd0b278f399ef80745c9c0966cc1630 (diff)
downloadtaskflow-96014cbba3bcb471d36796d2dc9662d22bd89552.tar.gz
Color some of the states depending on there meaning
Instead of just having black text color adjust some of the states text color depending on there type/name and highlight some as red, green, orange depending on there underlying meaning. Color names are from: http://www.graphviz.org/doc/info/colors.html Change-Id: I89f8f90837551a257936d254516ada6130e7b6da
Diffstat (limited to 'tools')
-rwxr-xr-xtools/state_graph.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/tools/state_graph.py b/tools/state_graph.py
index e83426b..c5d72d0 100755
--- a/tools/state_graph.py
+++ b/tools/state_graph.py
@@ -57,6 +57,18 @@ def make_machine(start_state, transitions, disallowed):
return machine
+def map_color(internal_states, state):
+ if state in internal_states:
+ return 'blue'
+ if state == states.FAILURE:
+ return 'red'
+ if state == states.REVERTED:
+ return 'darkorange'
+ if state == states.SUCCESS:
+ return 'green'
+ return None
+
+
def main():
parser = optparse.OptionParser()
parser.add_option("-f", "--file", dest="filename",
@@ -119,14 +131,16 @@ def main():
for (start_state, _on_event, end_state) in source:
if start_state not in nodes:
start_node_attrs = node_attrs.copy()
- if start_state in internal_states:
- start_node_attrs['fontcolor'] = 'blue'
+ text_color = map_color(internal_states, start_state)
+ if text_color:
+ start_node_attrs['fontcolor'] = text_color
nodes[start_state] = pydot.Node(start_state, **start_node_attrs)
g.add_node(nodes[start_state])
if end_state not in nodes:
end_node_attrs = node_attrs.copy()
- if end_state in internal_states:
- end_node_attrs['fontcolor'] = 'blue'
+ text_color = map_color(internal_states, end_state)
+ if text_color:
+ end_node_attrs['fontcolor'] = text_color
nodes[end_state] = pydot.Node(end_state, **end_node_attrs)
g.add_node(nodes[end_state])
g.add_edge(pydot.Edge(nodes[start_state], nodes[end_state]))