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
=== modified file 'src/sextant/export.py' (properties changed: -x to +x)
--- src/sextant/export.py 2014-08-19 09:20:45 +0000
+++ src/sextant/export.py 2014-08-22 14:50:12 +0000
@@ -10,7 +10,7 @@
1010
11class ProgramConverter:11class ProgramConverter:
12 # Given our internal program representation, converts it to output formats.12 # Given our internal program representation, converts it to output formats.
13 # Currently supported: GraphML13 # Currently supported: GraphML, dot
1414
15 @staticmethod15 @staticmethod
16 def get_supported_outputs():16 def get_supported_outputs():
@@ -36,11 +36,14 @@
36 def to_dot(program, suppress_common_nodes=False):36 def to_dot(program, suppress_common_nodes=False):
37 """37 """
38 Convert the program to DOT output format.38 Convert the program to DOT output format.
39 program: Nodes and edges to be outputted
40 suppress_common_nodes: If true doesn't output connections to common nodes
41 remove_self_calls: If is True doesn't output edges back to original func.
39 """42 """
40 output_str = 'digraph "{}" {{\n '.format(program.program_name)43 output_str = 'digraph "{}" {{\n '.format(program.program_name)
41 output_str += 'overlap=false; \n'44 output_str += 'overlap=false; \n'
4245
43 font_name = "helvetica"46 font_name = "Helvetica"
4447
45 for func in program.get_functions():48 for func in program.get_functions():
46 if func.type == "plt_stub":49 if func.type == "plt_stub":
@@ -58,6 +61,13 @@
58 if func.is_common:61 if func.is_common:
59 output_str += ' "{}" [fillcolor=lightgreen, style=filled]\n'.format(func.name)62 output_str += ' "{}" [fillcolor=lightgreen, style=filled]\n'.format(func.name)
6063
64 functions_called = func.functions_i_call
65 if remove_self_calls is True:
66 #remove calls where a function calls to itself
67 for func_called in functions_called:
68 if func_called == func:
69 functions_called.remove(func_called)
70
61 for func_called in func.functions_i_call:71 for func_called in func.functions_i_call:
62 if not (suppress_common_nodes and func_called.is_common):72 if not (suppress_common_nodes and func_called.is_common):
63 output_str += ' "{}" -> "{}"\n'.format(func.name, func_called.name)73 output_str += ' "{}" -> "{}"\n'.format(func.name, func_called.name)
@@ -65,11 +75,16 @@
65 output_str += '}'75 output_str += '}'
66 return output_str76 return output_str
6777
68
69
70 @staticmethod78 @staticmethod
71 def to_yed_graphml(program, suppress_common_nodes=False):79 def to_yed_graphml(program, suppress_common_nodes=False, remove_self_calls=False):
80 """
81 Convert the program to GraphML output format.
82 program: Nodes and edges to be outputted
83 suppress_common_nodes: If true doesn't output connections to common nodes
84 remove_self_calls: If is True doesn't output edges back to original func.
85 """
72 commonly_called = []86 commonly_called = []
87
73 output_str = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>88 output_str = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
74<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \89<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
75xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" \90xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" \
@@ -120,7 +135,15 @@
120 </y:ShapeNode>135 </y:ShapeNode>
121 </data> 136 </data>
122 </node>\n""".format(func.name, 20, len(display_func)*8, colour, display_func)137 </node>\n""".format(func.name, 20, len(display_func)*8, colour, display_func)
123 for callee in func.functions_i_call:138
139 functions_called = func.functions_i_call
140 if remove_self_calls is True:
141 #remove calls where a function calls itself
142 for func_called in functions_called:
143 if func_called == func:
144 functions_called.remove(func_called)
145
146 for callee in functions_called:
124 if callee not in commonly_called:147 if callee not in commonly_called:
125 if not(suppress_common_nodes and callee.is_common):148 if not(suppress_common_nodes and callee.is_common):
126 output_str += """<edge source="{}" target="{}"> <data key="d9">149 output_str += """<edge source="{}" target="{}"> <data key="d9">
127150
=== modified file 'src/sextant/query.py' (properties changed: -x to +x)
--- src/sextant/query.py 2014-08-19 09:20:45 +0000
+++ src/sextant/query.py 2014-08-22 14:50:12 +0000
@@ -31,6 +31,10 @@
3131
32 prog = None32 prog = None
33 names_list = None33 names_list = None
34 #If a function calls itself we don't want to output these calls in the
35 # shortest path query if remove_self_calls is True don't output a nodes
36 #calls to itself
37 remove_self_calls = False
3438
35 if input_query == 'functions-calling':39 if input_query == 'functions-calling':
36 if argument_1 == None:40 if argument_1 == None:
3741
=== modified file 'src/sextant/web/server.py' (properties changed: -x to +x)
--- src/sextant/web/server.py 2014-08-20 09:04:45 +0000
+++ src/sextant/web/server.py 2014-08-22 14:50:12 +0000
@@ -61,14 +61,16 @@
61 return connection.get_all_functions_calling(progname, funcname)61 return connection.get_all_functions_calling(progname, funcname)
6262
63 @staticmethod63 @staticmethod
64 def get_plot(program, suppress_common_functions=False):64 def get_plot(program, suppress_common_functions=False, remove_self_calls=False):
65 graph_dot = export.ProgramConverter.to_dot(program, suppress_common_functions)65 graph_dot = export.ProgramConverter.to_dot(program, suppress_common_functions,
66 remove_self_calls=remove_self_calls)
6667
67 file_written_to = tempfile.NamedTemporaryFile(delete=False)68 file_written_to = tempfile.NamedTemporaryFile(delete=False)
68 file_out = tempfile.NamedTemporaryFile(delete=False)69 file_out = tempfile.NamedTemporaryFile(delete=False)
69 file_written_to.write(graph_dot)70 file_written_to.write(graph_dot)
70 file_written_to.close()71 file_written_to.close()
71 subprocess.call(['dot', '-Tsvg', '-Kdot', '-o', file_out.name, file_written_to.name])72 subprocess.call(['dot', '-Tsvg', '-Kdot', '-o', file_out.name,
73 file_written_to.name])
7274
73 output = file_out.read().encode()75 output = file_out.read().encode()
74 file_out.close()76 file_out.close()
@@ -202,8 +204,8 @@
202 request.setResponseCode(204)204 request.setResponseCode(204)
203 request.finish()205 request.finish()
204 defer.returnValue(None)206 defer.returnValue(None)
205207 output = yield deferToThread(self.get_plot, program, suppress_common,
206 output = yield deferToThread(self.get_plot, program, suppress_common)208 remove_self_calls=False)
207 request.setHeader("content-type", "image/svg+xml")209 request.setHeader("content-type", "image/svg+xml")
208210
209 logging.info('SVG: return')211 logging.info('SVG: return')

Subscribers

People subscribed via source and target branches