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

SetupDataPkg: Remove bare excepts #220

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions SetupDataPkg/Tools/ConfigEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def validate(self, value):
if len(value) > 0:
try:
int(value, 16)
except:
except Exception:
return None

# Normalize the cell format
Expand Down Expand Up @@ -634,7 +634,7 @@ def edit_num_finished(self, event):
if value < min_val or value > max_val:
raise Exception("Invalid input!")
self.set_config_item_value(item, text, file_id)
except:
except Exception:
pass

text = item["value"].strip("{").strip("}").strip()
Expand Down Expand Up @@ -1030,7 +1030,7 @@ def set_config_item_value(self, item, value_str, file_id):
new_value = self.cfg_data_list[file_id].cfg_data_obj.reformat_value_str(
value_str, self.cfg_data_list[file_id].cfg_data_obj.get_cfg_item_length(item), item=item
)
except:
except Exception:
print("WARNING: Failed to format knob value string '%s' for '%s' !" % (value_str, item['path']))
new_value = item['value']
else:
Expand All @@ -1040,7 +1040,7 @@ def set_config_item_value(self, item, value_str, file_id):
self.cfg_data_list[file_id].cfg_data_obj.get_cfg_item_length(item),
item["value"],
)
except:
except Exception:
print(
"WARNING: Failed to format value string '%s' for '%s' !"
% (value_str, item["path"])
Expand Down Expand Up @@ -1104,7 +1104,7 @@ def update_config_data_from_widget(self, widget, args):
def evaluate_condition(self, item, file_id):
try:
result = self.cfg_data_list[file_id].cfg_data_obj.evaluate_condition(item)
except:
except Exception:
print(
"WARNING: Condition '%s' is invalid for '%s' !"
% (item["condition"], item["path"])
Expand Down Expand Up @@ -1134,7 +1134,7 @@ def add_config_item(self, item, row, file_id):
option_value = self.cfg_data_list[file_id].cfg_data_obj.get_value(
option_str, len(option_str), False
)
except:
except Exception:
option_value = 0
print(
'WARNING: Option "%s" has invalid format for "%s" !'
Expand Down Expand Up @@ -1208,7 +1208,7 @@ def add_config_item(self, item, row, file_id):
option_value = self.cfg_data_list[file_id].cfg_data_obj.get_value(
item, len(option_str), False, option_str
)
except:
except Exception:
option_value = 0
print('WARNING: Option "%s" has invalid format for "%s" !' % (option_str, item['path']))
if option_value == current_value:
Expand Down
2 changes: 1 addition & 1 deletion SetupDataPkg/Tools/SettingSupport/CertSupportLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_thumbprint_from_pfx(self, pfxfilename=None):
if (len(thumbprint) != 40) or (found is False):
return "No thumbprint"

except:
except Exception:
traceback.print_exc()
return "Unable to read certificate"

Expand Down
20 changes: 10 additions & 10 deletions SetupDataPkg/Tools/SettingSupport/DFCI_SupportLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ def get_current_permission_defaults(self, resultfile):
# Collect the root attributes
try:
r1 = root.attrib["Default"]
except:
except Exception:
r1 = None

try:
r2 = root.attrib["Delegated"]
except:
except Exception:
r2 = None

print("Result Default Values for : Default=%s, Delegated=%s" % (r1, r2))
Expand Down Expand Up @@ -412,7 +412,7 @@ def extract_payload_from_current(self, resultfile, payloadfile):
try:
tree = ET.parse(resultfile)
elem = tree.find("./SyncBody/Results/Item/Data")
except:
except Exception:
elem = None

if elem is None:
Expand All @@ -429,7 +429,7 @@ def extract_results_packet(self, resultfile, resultpktfile):
try:
tree = ET.parse(resultfile)
elem = tree.find("./SyncBody/Results/Item/Data")
except:
except Exception:
elem = None

if elem is None:
Expand Down Expand Up @@ -495,7 +495,7 @@ def get_status_and_sessionid_from_settings_results(self, resultfile, checktype):
"Setting %s - Code %s"
% (elem.find("Id").text, elem.find("Result").text)
)
except:
except Exception:
traceback.print_exc()
return RsltRc, rslt.SessionId

Expand Down Expand Up @@ -541,7 +541,7 @@ def get_status_from_dmtools_results(self, resultsfile):
result = 0x8000000000000007 # EFI_DEVICE_ERROR
break
result = 0
except:
except Exception:
traceback.print_exc()

return result
Expand All @@ -566,7 +566,7 @@ def print_xml_payload(self, XmlFileName):
try:
tree = xml.dom.minidom.parse(XmlFileName)
print("%s" % tree.toprettyxml())
except:
except Exception:
traceback.print_exc()
print("Unable to print settings XML")

Expand Down Expand Up @@ -614,7 +614,7 @@ def get_device_ids(self, XmlFileName):
for key in d:
print(" Key {0} has the value of {1}".format(key, d[key]))

except:
except Exception:
traceback.print_exc()
print("Unable to extract DeviceIdElements.")
d = {}
Expand Down Expand Up @@ -653,7 +653,7 @@ def get_dfci_version(self, XmlFileName):
d = elem.text
print("Dfci Version detected as %s" % d)

except:
except Exception:
traceback.print_exc()
print("Unable to extract DfciVersion from %s" % XmlFileName)
d = None
Expand Down Expand Up @@ -686,7 +686,7 @@ def get_thumbprints(self, XmlFileName):
for key in d:
print(" Key {0} has the value of {1}".format(key, d[key]))

except:
except Exception:
traceback.print_exc()
print("Unable to extract DeviceIdElements.")
d = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self):
c_int,
c_int,
]
except:
except Exception:
logging.warn(
"G[S]etFirmwareEnvironmentVariableW function doesn't seem to exist"
)
Expand Down