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

checks: Replace bare except (Flake8 E722) in wxGUI/core #4367

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 0 additions & 6 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ per-file-ignores =
doc/python/m.distance.py: E501
doc/gui/wxpython/example/dialogs.py: F401
gui/scripts/d.wms.py: E501
gui/wxpython/core/gconsole.py: E722
gui/wxpython/core/render.py: E722
gui/wxpython/core/settings.py: E722
gui/wxpython/core/toolboxes.py: E722
gui/wxpython/core/utils.py: E722
gui/wxpython/core/workspace.py: E722
gui/wxpython/datacatalog/tree.py: E731, E402
gui/wxpython/dbmgr/base.py: E722
gui/wxpython/dbmgr/dialogs.py: E722
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/gconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def load_source(modname, filename):
if len(command) == 1 and not skipInterface:
try:
task = gtask.parse_interface(command[0])
except:
except Exception:
task = None
else:
task = None
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ def SetRegion(self, windres=False, windres3=False):

return grass_region

except:
except Exception:
return None

def GetListOfLayers(
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _generateLocale(self):
self.locs.sort()
# Add a default choice to not override system locale
self.locs.insert(0, "system")
except:
except Exception:
# No NLS
self.locs = ["system"]

Expand Down Expand Up @@ -992,7 +992,7 @@ def SaveToFile(self, settings=None):
if not os.path.exists(dirPath):
try:
os.mkdir(dirPath)
except:
except OSError:
GError(_("Unable to create settings directory"))
return
try:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/toolboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def getMenudataFile(userRootFile, newFile, fallback):
fh.write(xml)
fh.close()
return menudataFile
except:
except Exception:
_debug(
2,
(
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def GetTempfile(pref=None):
return os.path.join(pref, file)
else:
return tempfile
except:
except Exception:
return None


Expand Down Expand Up @@ -255,7 +255,7 @@ def ListOfCatsToRange(cats):

try:
cats = list(map(int, cats))
except:
except ValueError:
return catstr

i = 0
Expand Down Expand Up @@ -579,7 +579,7 @@ def GetListOfLocations(dbase):
os.path.join(location, "*")
):
listOfLocations.append(os.path.basename(location))
except:
except OSError:
pass

ListSortLower(listOfLocations)
Expand Down Expand Up @@ -632,7 +632,7 @@ def _getGDALFormats():
"""Get dictionary of available GDAL drivers"""
try:
ret = grass.read_command("r.in.gdal", quiet=True, flags="f")
except:
except Exception:
arohanajit marked this conversation as resolved.
Show resolved Hide resolved
ret = None

return _parseFormats(ret), _parseFormats(ret, writableOnly=True)
Expand All @@ -642,7 +642,7 @@ def _getOGRFormats():
"""Get dictionary of available OGR drivers"""
try:
ret = grass.read_command("v.in.ogr", quiet=True, flags="f")
except:
except Exception:
arohanajit marked this conversation as resolved.
Show resolved Hide resolved
ret = None

return _parseFormats(ret), _parseFormats(ret, writableOnly=True)
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __processFile(self):
try:
self.layerManager["pos"] = (posVal[0], posVal[1])
self.layerManager["size"] = (posVal[2], posVal[3])
except:
except IndexError:
pass
# current working directory
cwdPath = self.__getNodeText(node_lm, "cwd")
Expand Down Expand Up @@ -155,7 +155,7 @@ def __processFile(self):
try:
pos = (posVal[0], posVal[1])
size = (posVal[2], posVal[3])
except:
except IndexError:
pos = None
size = None
# this happens on Windows when mapwindow is minimized when
Expand Down Expand Up @@ -2019,7 +2019,7 @@ def _get_value(self, line):
"""Get value of element"""
try:
return line.strip(" ").split(" ")[1].strip(" ")
except:
except IndexError:
return ""

def _get_element(self, line):
Expand Down
Loading