Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI: Fixed bare 'except' in nviz/ #4613

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ per-file-ignores =
doc/python/m.distance.py: E501
gui/scripts/d.wms.py: E501
gui/wxpython/image2target/g.gui.image2target.py: E501
gui/wxpython/nviz/*: E722
gui/wxpython/photo2image/g.gui.photo2image.py: E501
gui/wxpython/psmap/*: E501, E722
gui/wxpython/vdigit/*: F841, E722, F405, F403
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/nviz/mapwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def LoadDataLayers(self):
GError(parent=self, message=e.value)
# when nviz.tools is not yet ready
# during opening 3D view 2nd time
except:
except Exception:
pass

stop = gs.clock()
Expand Down
64 changes: 20 additions & 44 deletions gui/wxpython/nviz/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def SetInitialMaps(self):
else:
try:
selection = layers[0].GetName()
except:
except (AttributeError, IndexError):
continue
if ltype == "raster":
self.FindWindowById(self.win["surface"]["map"]).SetValue(selection)
Expand Down Expand Up @@ -734,24 +734,12 @@ def _createDataPage(self):
self.mainPanelData = SP.ScrolledPanel(parent=self)
self.mainPanelData.SetupScrolling(scroll_x=False)
self.mainPanelData.AlwaysShowScrollbars(hflag=False)
try: # wxpython <= 2.8.10
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
style=fpb.FPB_DEFAULT_STYLE,
extraStyle=fpb.FPB_SINGLE_FOLD,
)
except:
try: # wxpython >= 2.8.11
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)
except: # to be sure
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData, id=wx.ID_ANY, style=fpb.FPB_SINGLE_FOLD
)
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
style=fpb.FPB_SINGLE_FOLD,
arohanajit marked this conversation as resolved.
Show resolved Hide resolved
agwStyle=fpb.FPB_SINGLE_FOLD,
)

self.foldpanelData.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)

Expand Down Expand Up @@ -814,24 +802,12 @@ def _createAppearancePage(self):
self.mainPanelAppear = SP.ScrolledPanel(parent=self)
self.mainPanelAppear.SetupScrolling(scroll_x=False)
self.mainPanelAppear.AlwaysShowScrollbars(hflag=False)
try: # wxpython <= 2.8.10
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
style=fpb.FPB_DEFAULT_STYLE,
extraStyle=fpb.FPB_SINGLE_FOLD,
)
except:
try: # wxpython >= 2.8.11
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)
except: # to be sure
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear, id=wx.ID_ANY, style=fpb.FPB_SINGLE_FOLD
)
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
style=fpb.FPB_SINGLE_FOLD,
extraStyle=fpb.FPB_SINGLE_FOLD,
)

self.foldpanelAppear.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)
# light page
Expand Down Expand Up @@ -3360,7 +3336,7 @@ def OnSetSurface(self, event):
name = event.GetString()
try:
self._getLayerPropertiesByName(name, mapType="raster")["surface"]
except:
except (AttributeError, TypeError):
arohanajit marked this conversation as resolved.
Show resolved Hide resolved
self.EnablePage("fringe", False)
return

Expand All @@ -3384,7 +3360,7 @@ def OnSetVector(self, event):
name = event.GetString()
try:
data = self._getLayerPropertiesByName(name, mapType="vector")["vector"]
except:
except (AttributeError, TypeError, KeyError):
self.EnablePage("vector", False)
return
layer = self._getMapLayerByName(name, mapType="vector")
Expand All @@ -3396,7 +3372,7 @@ def OnSetRaster3D(self, event):
name = event.GetString()
try:
data = self._getLayerPropertiesByName(name, mapType="raster_3d")["volume"]
except:
except (AttributeError, TypeError):
self.EnablePage("volume", False)
return

Expand Down Expand Up @@ -4925,7 +4901,7 @@ def OnCPlaneSelection(self, event):
try:
planeIndex = int(plane.split()[-1]) - 1
self.EnablePage("cplane", enabled=True)
except:
except (ValueError, IndexError):
planeIndex = -1
self.EnablePage("cplane", enabled=False)
self.mapWindow.SelectCPlane(planeIndex)
Expand All @@ -4942,7 +4918,7 @@ def OnCPlaneChanging(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

if event.GetId() in (
Expand Down Expand Up @@ -4984,7 +4960,7 @@ def OnCPlaneShading(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

self.mapWindow.cplanes[planeIndex]["shading"] = shading
Expand All @@ -4999,7 +4975,7 @@ def OnCPlaneReset(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

self.mapWindow.cplanes[planeIndex] = copy.deepcopy(
Expand Down
Loading