Merge lp:~jamesh-f/ensoft-sextant/ensoft-sextant into lp:ensoft-sextant

Proposed by James
Status: Merged
Approved by: Patrick Stevens
Approved revision: 194
Merged at revision: 10
Proposed branch: lp:~jamesh-f/ensoft-sextant/ensoft-sextant
Merge into: lp:ensoft-sextant
Diff against target: 129 lines (+40/-11)
3 files modified
src/sextant/export.py (+29/-6)
src/sextant/query.py (+4/-0)
src/sextant/web/server.py (+7/-5)
To merge this branch: bzr merge lp:~jamesh-f/ensoft-sextant/ensoft-sextant
Reviewer Review Type Date Requested Status
Patrick Stevens Approve
Review via email: mp+231215@code.launchpad.net

Commit message

When asking for the shortest path between two nodes the graph now doesn't display calls where a node calls its self
Also a change where when a connection can't be made to the web server or the neo4j database a sane output is given.

Description of the change

When asking for the shortest path between two nodes the graph now doesn't display calls where a node calls its self
Also a change where when a connection can't be made to the web server or the neo4j database a sane output is given.

To post a comment you must log in.
Revision history for this message
Patrick Stevens (patrickas) wrote :

Comments inline - nothing particularly major, apart from a point about separating the changes out (this commit is two changes, one about the error handling and one about the shortest-path stuff).

review: Needs Fixing
Revision history for this message
Patrick Stevens (patrickas) wrote :

I think there's a bug where get_plot ignores its remove_self_calls argument.

review: Needs Fixing
Revision history for this message
Patrick Stevens (patrickas) :
review: Approve
Revision history for this message
Martin Morrison (isoschiz) wrote :

Attempt to merge into lp:ensoft-sextant failed due to conflicts:

text conflict in src/sextant/export.py
text conflict in src/sextant/query.py
text conflict in src/sextant/web/server.py

Revision history for this message
Patrick Stevens (patrickas) wrote :

You probably want to check out these merge conflicts.

review: Needs Fixing
Revision history for this message
Patrick Stevens (patrickas) :
review: Approve
Revision history for this message
Martin Morrison (isoschiz) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Patrick Stevens (patrickas) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sextant/export.py' (properties changed: -x to +x)
2--- src/sextant/export.py 2014-08-19 09:20:45 +0000
3+++ src/sextant/export.py 2014-08-22 14:50:12 +0000
4@@ -10,7 +10,7 @@
5
6 class ProgramConverter:
7 # Given our internal program representation, converts it to output formats.
8- # Currently supported: GraphML
9+ # Currently supported: GraphML, dot
10
11 @staticmethod
12 def get_supported_outputs():
13@@ -36,11 +36,14 @@
14 def to_dot(program, suppress_common_nodes=False):
15 """
16 Convert the program to DOT output format.
17+ program: Nodes and edges to be outputted
18+ suppress_common_nodes: If true doesn't output connections to common nodes
19+ remove_self_calls: If is True doesn't output edges back to original func.
20 """
21 output_str = 'digraph "{}" {{\n '.format(program.program_name)
22 output_str += 'overlap=false; \n'
23
24- font_name = "helvetica"
25+ font_name = "Helvetica"
26
27 for func in program.get_functions():
28 if func.type == "plt_stub":
29@@ -58,6 +61,13 @@
30 if func.is_common:
31 output_str += ' "{}" [fillcolor=lightgreen, style=filled]\n'.format(func.name)
32
33+ functions_called = func.functions_i_call
34+ if remove_self_calls is True:
35+ #remove calls where a function calls to itself
36+ for func_called in functions_called:
37+ if func_called == func:
38+ functions_called.remove(func_called)
39+
40 for func_called in func.functions_i_call:
41 if not (suppress_common_nodes and func_called.is_common):
42 output_str += ' "{}" -> "{}"\n'.format(func.name, func_called.name)
43@@ -65,11 +75,16 @@
44 output_str += '}'
45 return output_str
46
47-
48-
49 @staticmethod
50- def to_yed_graphml(program, suppress_common_nodes=False):
51+ def to_yed_graphml(program, suppress_common_nodes=False, remove_self_calls=False):
52+ """
53+ Convert the program to GraphML output format.
54+ program: Nodes and edges to be outputted
55+ suppress_common_nodes: If true doesn't output connections to common nodes
56+ remove_self_calls: If is True doesn't output edges back to original func.
57+ """
58 commonly_called = []
59+
60 output_str = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
61 <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
62 xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" \
63@@ -120,7 +135,15 @@
64 </y:ShapeNode>
65 </data>
66 </node>\n""".format(func.name, 20, len(display_func)*8, colour, display_func)
67- for callee in func.functions_i_call:
68+
69+ functions_called = func.functions_i_call
70+ if remove_self_calls is True:
71+ #remove calls where a function calls itself
72+ for func_called in functions_called:
73+ if func_called == func:
74+ functions_called.remove(func_called)
75+
76+ for callee in functions_called:
77 if callee not in commonly_called:
78 if not(suppress_common_nodes and callee.is_common):
79 output_str += """<edge source="{}" target="{}"> <data key="d9">
80
81=== modified file 'src/sextant/query.py' (properties changed: -x to +x)
82--- src/sextant/query.py 2014-08-19 09:20:45 +0000
83+++ src/sextant/query.py 2014-08-22 14:50:12 +0000
84@@ -31,6 +31,10 @@
85
86 prog = None
87 names_list = None
88+ #If a function calls itself we don't want to output these calls in the
89+ # shortest path query if remove_self_calls is True don't output a nodes
90+ #calls to itself
91+ remove_self_calls = False
92
93 if input_query == 'functions-calling':
94 if argument_1 == None:
95
96=== modified file 'src/sextant/web/server.py' (properties changed: -x to +x)
97--- src/sextant/web/server.py 2014-08-20 09:04:45 +0000
98+++ src/sextant/web/server.py 2014-08-22 14:50:12 +0000
99@@ -61,14 +61,16 @@
100 return connection.get_all_functions_calling(progname, funcname)
101
102 @staticmethod
103- def get_plot(program, suppress_common_functions=False):
104- graph_dot = export.ProgramConverter.to_dot(program, suppress_common_functions)
105+ def get_plot(program, suppress_common_functions=False, remove_self_calls=False):
106+ graph_dot = export.ProgramConverter.to_dot(program, suppress_common_functions,
107+ remove_self_calls=remove_self_calls)
108
109 file_written_to = tempfile.NamedTemporaryFile(delete=False)
110 file_out = tempfile.NamedTemporaryFile(delete=False)
111 file_written_to.write(graph_dot)
112 file_written_to.close()
113- subprocess.call(['dot', '-Tsvg', '-Kdot', '-o', file_out.name, file_written_to.name])
114+ subprocess.call(['dot', '-Tsvg', '-Kdot', '-o', file_out.name,
115+ file_written_to.name])
116
117 output = file_out.read().encode()
118 file_out.close()
119@@ -202,8 +204,8 @@
120 request.setResponseCode(204)
121 request.finish()
122 defer.returnValue(None)
123-
124- output = yield deferToThread(self.get_plot, program, suppress_common)
125+ output = yield deferToThread(self.get_plot, program, suppress_common,
126+ remove_self_calls=False)
127 request.setHeader("content-type", "image/svg+xml")
128
129 logging.info('SVG: return')

Subscribers

People subscribed via source and target branches