mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
Improve Python code: address unused variables (#11049)
* Address F841 (unused variable). * Reformat. * Add changelog fragment. * More cleanup. * Remove trailing whitespace. * Readd removed code as a comment with TODO.
This commit is contained in:
parent
0d8521c718
commit
396f467bbb
90 changed files with 232 additions and 235 deletions
|
|
@ -86,19 +86,19 @@ class BtrfsCommands:
|
|||
|
||||
def subvolume_set_default(self, filesystem_path, subvolume_id):
|
||||
command = [self.__btrfs, "subvolume", "set-default", str(subvolume_id), to_bytes(filesystem_path)]
|
||||
result = self.__module.run_command(command, check_rc=True)
|
||||
self.__module.run_command(command, check_rc=True)
|
||||
|
||||
def subvolume_create(self, subvolume_path):
|
||||
command = [self.__btrfs, "subvolume", "create", to_bytes(subvolume_path)]
|
||||
result = self.__module.run_command(command, check_rc=True)
|
||||
self.__module.run_command(command, check_rc=True)
|
||||
|
||||
def subvolume_snapshot(self, snapshot_source, snapshot_destination):
|
||||
command = [self.__btrfs, "subvolume", "snapshot", to_bytes(snapshot_source), to_bytes(snapshot_destination)]
|
||||
result = self.__module.run_command(command, check_rc=True)
|
||||
self.__module.run_command(command, check_rc=True)
|
||||
|
||||
def subvolume_delete(self, subvolume_path):
|
||||
command = [self.__btrfs, "subvolume", "delete", to_bytes(subvolume_path)]
|
||||
result = self.__module.run_command(command, check_rc=True)
|
||||
self.__module.run_command(command, check_rc=True)
|
||||
|
||||
|
||||
class BtrfsInfoProvider:
|
||||
|
|
|
|||
|
|
@ -57,11 +57,11 @@ def auth_argument_spec(spec=None):
|
|||
def find_project(gitlab_instance, identifier):
|
||||
try:
|
||||
project = gitlab_instance.projects.get(identifier)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
current_user = gitlab_instance.user
|
||||
try:
|
||||
project = gitlab_instance.projects.get(f"{current_user.username}/{identifier}")
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
return project
|
||||
|
|
@ -70,7 +70,7 @@ def find_project(gitlab_instance, identifier):
|
|||
def find_group(gitlab_instance, identifier):
|
||||
try:
|
||||
group = gitlab_instance.groups.get(identifier)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
return group
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ class RedfishUtils:
|
|||
)
|
||||
try:
|
||||
data = json.loads(to_native(resp.read()))
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
# No response data; this is okay in certain cases
|
||||
data = None
|
||||
if not allow_no_resp:
|
||||
|
|
@ -233,7 +233,7 @@ class RedfishUtils:
|
|||
)
|
||||
try:
|
||||
data = json.loads(to_native(resp.read()))
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
# No response data; this is okay in many cases
|
||||
data = None
|
||||
except HTTPError as e:
|
||||
|
|
@ -1991,7 +1991,7 @@ class RedfishUtils:
|
|||
try:
|
||||
with open(image_file, "rb") as f:
|
||||
image_payload = f.read()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return {"ret": False, "msg": f"Could not read file {image_file}"}
|
||||
|
||||
# Check that multipart HTTP push updates are supported
|
||||
|
|
@ -2409,7 +2409,7 @@ class RedfishUtils:
|
|||
return {"ret": False, "msg": "Key BootOrder not found"}
|
||||
|
||||
boot = data["Boot"]
|
||||
boot_order = boot["BootOrder"]
|
||||
# boot_order = boot["BootOrder"] - TODO is this needed?
|
||||
boot_options_dict = self._get_boot_options_dict(boot)
|
||||
|
||||
# Verify the requested boot options are valid
|
||||
|
|
@ -3742,7 +3742,7 @@ class RedfishUtils:
|
|||
response = self.get_request(f"{self.root_uri}/redfish/v1/Managers/{manager}", override_headers=None)
|
||||
try:
|
||||
result["service_identification"] = response["data"]["ServiceIdentification"]
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
self.module.fail_json(msg=f"Service ID not found for manager {manager}")
|
||||
result["ret"] = True
|
||||
return result
|
||||
|
|
@ -3826,7 +3826,6 @@ class RedfishUtils:
|
|||
|
||||
def get_hpe_thermal_config(self):
|
||||
result = {}
|
||||
key = "Thermal"
|
||||
# Go through list
|
||||
for chassis_uri in self.chassis_uris:
|
||||
response = self.get_request(self.root_uri + chassis_uri)
|
||||
|
|
@ -3840,8 +3839,6 @@ class RedfishUtils:
|
|||
return {"ret": False}
|
||||
|
||||
def get_hpe_fan_percent_min(self):
|
||||
result = {}
|
||||
key = "Thermal"
|
||||
# Go through list
|
||||
for chassis_uri in self.chassis_uris:
|
||||
response = self.get_request(self.root_uri + chassis_uri)
|
||||
|
|
@ -3946,17 +3943,6 @@ class RedfishUtils:
|
|||
|
||||
# Validate input parameters
|
||||
required_parameters = ["RAIDType", "Drives"]
|
||||
allowed_parameters = [
|
||||
"CapacityBytes",
|
||||
"DisplayName",
|
||||
"InitializeMethod",
|
||||
"MediaSpanCount",
|
||||
"Name",
|
||||
"ReadCachePolicy",
|
||||
"StripSizeBytes",
|
||||
"VolumeUsage",
|
||||
"WriteCachePolicy",
|
||||
]
|
||||
|
||||
for parameter in required_parameters:
|
||||
if not volume_details.get(parameter):
|
||||
|
|
@ -4029,7 +4015,6 @@ class RedfishUtils:
|
|||
reg_data = reg_resp["data"]
|
||||
|
||||
# Get BIOS attribute registry URI
|
||||
lst = []
|
||||
|
||||
# Get the location URI
|
||||
response = self.check_location_uri(reg_data, reg_uri)
|
||||
|
|
|
|||
|
|
@ -268,7 +268,6 @@ class Scaleway:
|
|||
def fetch_paginated_resources(self, resource_key, **pagination_kwargs):
|
||||
response = self.get(path=self.api_path, params=pagination_kwargs)
|
||||
|
||||
status_code = response.status_code
|
||||
if not response.ok:
|
||||
self.module.fail_json(
|
||||
msg=f"Error getting {resource_key} [{response.status_code}: {response.json['message']}]"
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ def get_object_ref(module, name, uuid=None, obj_type="VM", fail=True, msg_prefix
|
|||
# Find object by UUID. If no object is found using given UUID,
|
||||
# an exception will be generated.
|
||||
obj_ref = xapi_session.xenapi_request(f"{real_obj_type}.get_by_uuid", (uuid,))
|
||||
except XenAPI.Failure as f:
|
||||
except XenAPI.Failure:
|
||||
if fail:
|
||||
module.fail_json(msg=f"{msg_prefix}{obj_type} with UUID '{uuid}' not found!")
|
||||
elif name:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue