Skip to content

Commit 5250f00

Browse files
committed
Merge branch 'development' into plotinclude
2 parents 2ffed94 + 0f2ba90 commit 5250f00

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -372,26 +372,33 @@ def getDirList(self, dir=None, onlyDirs = False, filterFiles=False):
372372
return dir_list
373373

374374
def getPlot(self, plotName, LFPflavour):
375-
args = self.getPlotSettings(plotName)
376-
if LFPflavour:
377-
args['plots'] = [LFPflavour]
378-
fig = getattr(analysis, plotName)(showFig=False, **args)[0]
379-
if fig==-1:
380-
return fig
381-
elif isinstance(fig, list):
382-
# return [ui.getSVG(fig[0])].__str__()
383-
return [ui.getSVG(fig[0])]
384-
elif isinstance(fig, dict):
385-
svgs = []
386-
for key, value in fig.items():
387-
logging.debug("Found plot for "+ key)
388-
svgs.append(ui.getSVG(value))
389-
#return svgs.__str__()
390-
return svgs
391-
else:
392-
#return [ui.getSVG(fig)].__str__()
393-
return [ui.getSVG(fig)]
394-
375+
try:
376+
with redirect_stdout(sys.__stdout__):
377+
args = self.getPlotSettings(plotName)
378+
if LFPflavour:
379+
args['plots'] = [LFPflavour]
380+
figData = getattr(analysis, plotName)(showFig=False, **args)
381+
382+
if isinstance(figData, tuple):
383+
fig = figData[0]
384+
if fig==-1:
385+
return fig
386+
elif isinstance(fig, list):
387+
return [ui.getSVG(fig[0])]
388+
elif isinstance(fig, dict):
389+
svgs = []
390+
for key, value in fig.items():
391+
svgs.append(ui.getSVG(value))
392+
return svgs
393+
else:
394+
return [ui.getSVG(fig)]
395+
else:
396+
return figData
397+
except Exception as e:
398+
# TODO: Extract these two lines as a function and call it in every catch clause
399+
err = "There was an exception in %s():"%(function.__name__)
400+
logging.exception(("%s \n %s \n%s"%(err,e,sys.exc_info())))
401+
395402
def getAvailablePops(self):
396403
return list(self.netParams.popParams.keys())
397404

0 commit comments

Comments
 (0)