Skip to content

Commit d1401df

Browse files
committed
add try/catch, remove comments
1 parent 0d6d549 commit d1401df

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

netpyne_ui/netpyne_geppetto.py

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

374374
def getPlot(self, plotName, LFPflavour):
375-
with redirect_stdout(sys.__stdout__):
376-
args = self.getPlotSettings(plotName)
377-
if LFPflavour:
378-
args['plots'] = [LFPflavour]
379-
figData = getattr(analysis, plotName)(showFig=False, **args)
380-
381-
if isinstance(figData, tuple):
382-
fig = figData[0]
383-
if fig==-1:
384-
return fig
385-
elif isinstance(fig, list):
386-
# return [ui.getSVG(fig[0])].__str__()
387-
return [ui.getSVG(fig[0])]
388-
elif isinstance(fig, dict):
389-
svgs = []
390-
for key, value in fig.items():
391-
logging.debug("Found plot for "+ key)
392-
svgs.append(ui.getSVG(value))
393-
#return svgs.__str__()
394-
return svgs
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)]
395395
else:
396-
#return [ui.getSVG(fig)].__str__()
397-
return [ui.getSVG(fig)]
398-
else:
399-
return figData
400-
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+
401402
def getAvailablePops(self):
402403
return list(self.netParams.popParams.keys())
403404

0 commit comments

Comments
 (0)