FEM: python, get rid of bare excepts
This commit is contained in:
@@ -34,6 +34,13 @@ These coding rules apply to FEM module code only. Other modules or the base syst
|
||||
- maximal line length is 100
|
||||
- double quotes as string identifier
|
||||
|
||||
### Exceptione
|
||||
- Do not use bare 'except'.
|
||||
- Be more specific. If not possible use:
|
||||
- Either use 'except Exception' or if really everything should be catched 'except BaseException'
|
||||
- https://stackoverflow.com/a/18982772
|
||||
- https://github.com/PyCQA/pycodestyle/issues/703
|
||||
|
||||
### Imports
|
||||
- Only one import per line.
|
||||
- Even on import from some_module import something. There should only be one something per line.
|
||||
|
||||
@@ -101,7 +101,7 @@ def readResult(
|
||||
m["frequency"] = mode_frequency
|
||||
results.append(m)
|
||||
mode_reading = True
|
||||
except:
|
||||
except Exception:
|
||||
if mode_reading:
|
||||
# Conversion error after mode reading started, so it's the end of section
|
||||
eigenvalue_output_section_found = False
|
||||
|
||||
@@ -214,7 +214,7 @@ def read_inp(file_name):
|
||||
try:
|
||||
enode = int(line_list[en])
|
||||
elm_category[number].append(enode)
|
||||
except:
|
||||
except Exception:
|
||||
elm_2nd_line = True
|
||||
break
|
||||
|
||||
|
||||
@@ -831,7 +831,7 @@ class GmshTools():
|
||||
# but the warnings are in stderr and thus printed :-)
|
||||
# print(output)
|
||||
# print(error)
|
||||
except:
|
||||
except Exception:
|
||||
error = "Error executing: {}\n".format(" ".join(comandlist))
|
||||
Console.PrintError(error)
|
||||
self.error = True
|
||||
|
||||
@@ -116,7 +116,7 @@ class Task(object):
|
||||
def protector(self):
|
||||
try:
|
||||
self.run()
|
||||
except:
|
||||
except Exception:
|
||||
self.fail()
|
||||
raise
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class _TaskPanel:
|
||||
error = ""
|
||||
try:
|
||||
error = gmsh_mesh.create_mesh()
|
||||
except:
|
||||
except Exception:
|
||||
import sys
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Unexpected error when creating mesh: {}\n"
|
||||
|
||||
@@ -235,7 +235,7 @@ class _TaskPanel:
|
||||
# self.result_widget.hsb_displacement_factor.setValue(df)
|
||||
self.result_widget.sb_displacement_factor_max.setValue(dfm)
|
||||
self.result_widget.sb_displacement_factor.setValue(df)
|
||||
except:
|
||||
except Exception:
|
||||
self.restore_initial_result_dialog()
|
||||
|
||||
def restore_initial_result_dialog(self):
|
||||
|
||||
@@ -285,7 +285,7 @@ class _TaskPanel:
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
self.fea.load_results()
|
||||
except:
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintError("loading results failed\n")
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
@@ -377,7 +377,7 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
|
||||
self.working_dir
|
||||
)
|
||||
self.inp_file_name = inp_writer.write_calculix_input_file()
|
||||
except:
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Unexpected error when writing CalculiX input file: {}\n"
|
||||
.format(sys.exc_info()[0])
|
||||
|
||||
@@ -249,7 +249,7 @@ def getBoundBoxOfAllDocumentShapes(doc):
|
||||
if hasattr(o, "Shape") and hasattr(o.Shape, "BoundBox"):
|
||||
try:
|
||||
bb = o.Shape.BoundBox
|
||||
except:
|
||||
except Exception:
|
||||
bb = None
|
||||
if bb.isValid():
|
||||
if not overalboundbox:
|
||||
|
||||
Reference in New Issue
Block a user