Skip to content

Commit c782aed

Browse files
authored
Merge pull request #4554 from Flamefire/fix-dep-graph-msg
Correctly evaluate result for `--dep-graph`
2 parents 33a5030 + 02a3719 commit c782aed

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

easybuild/framework/easyconfig/tools.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from easybuild.framework.easyconfig.format.yeb import quote_yaml_special_chars
5555
from easybuild.framework.easyconfig.style import cmdline_easyconfigs_style_check
5656
from easybuild.tools import LooseVersion
57-
from easybuild.tools.build_log import EasyBuildError, print_msg, print_warning
57+
from easybuild.tools.build_log import EasyBuildError, print_error, print_msg, print_warning
5858
from easybuild.tools.config import build_option
5959
from easybuild.tools.environment import restore_env
6060
from easybuild.tools.filetools import find_easyconfigs, is_patch_file, locate_files
@@ -219,10 +219,12 @@ def mk_node_name(spec):
219219
if dep in spec['ec'].build_dependencies:
220220
dgr.add_edge_attributes((spec['module'], dep), attrs=edge_attrs)
221221

222-
_dep_graph_dump(dgr, filename)
223-
224-
if not build_option('silent'):
225-
print("Wrote dependency graph for %d easyconfigs to %s" % (len(specs), filename))
222+
what = "dependency graph for %d easyconfigs to %s" % (len(specs), filename)
223+
silent = build_option('silent')
224+
if _dep_graph_dump(dgr, filename):
225+
print_msg("Wrote " + what, silent=silent)
226+
else:
227+
print_error("Failed writing " + what, silent=silent)
226228

227229

228230
@only_if_module_is_available('pygraph.readwrite.dot', pkgname='python-graph-dot')
@@ -232,18 +234,24 @@ def _dep_graph_dump(dgr, filename):
232234
dottxt = dot.write(dgr)
233235
if os.path.splitext(filename)[-1] == '.dot':
234236
# create .dot file
235-
write_file(filename, dottxt)
237+
try:
238+
write_file(filename, dottxt)
239+
except EasyBuildError as e:
240+
print(str(e))
241+
return False
242+
else:
243+
return True
236244
else:
237-
_dep_graph_gv(dottxt, filename)
245+
return _dep_graph_gv(dottxt, filename)
238246

239247

240248
@only_if_module_is_available('gv', pkgname='graphviz-python')
241249
def _dep_graph_gv(dottxt, filename):
242250
"""Render dependency graph to file using graphviz."""
243251
# try and render graph in specified file format
244252
gvv = gv.readstring(dottxt)
245-
gv.layout(gvv, 'dot')
246-
gv.render(gvv, os.path.splitext(filename)[-1], filename)
253+
if gv.layout(gvv, 'dot') is not False:
254+
return gv.render(gvv, os.path.splitext(filename)[-1], filename)
247255

248256

249257
def get_paths_for(subdir=EASYCONFIGS_PKG_SUBDIR, robot_path=None):

0 commit comments

Comments
 (0)