mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
Update bare exceptions to specify Exception.
This will keep us from accidentally catching program-exiting exceptions like KeyboardInterupt and SystemExit.
This commit is contained in:
parent
5147e792d3
commit
3fba006207
320 changed files with 659 additions and 656 deletions
|
@ -153,7 +153,7 @@ from ansible.module_utils.aws.direct_connect import (DirectConnectError, delete_
|
|||
|
||||
try:
|
||||
from botocore.exceptions import BotoCoreError, ClientError
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
# handled by imported AnsibleAWSModule
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ import time
|
|||
|
||||
try:
|
||||
import botocore
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
# handled by imported HAS_BOTO3
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ def do_grant(kms, keyarn, role_arn, granttypes, mode='grant', dry_run=True, clea
|
|||
kms.put_key_policy(KeyId=keyarn, PolicyName='default', Policy=policy_json_string)
|
||||
# returns nothing, so we have to just assume it didn't throw
|
||||
ret['changed'] = True
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
ret['changes_needed'] = changes_needed
|
||||
|
|
|
@ -91,7 +91,7 @@ rules:
|
|||
|
||||
try:
|
||||
from botocore.exceptions import ClientError, BotoCoreError
|
||||
except:
|
||||
except Exception:
|
||||
# handled by HAS_BOTO3 check in main
|
||||
pass
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ def create_update_parameter(client, module):
|
|||
|
||||
try:
|
||||
existing_parameter = client.get_parameter(Name=args['Name'], WithDecryption=True)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if existing_parameter:
|
||||
|
|
|
@ -477,7 +477,7 @@ def stack_operation(cfn, stack_name, operation, events_limit, op_token=None):
|
|||
try:
|
||||
stack = get_stack_facts(cfn, stack_name)
|
||||
existed.append('yes')
|
||||
except:
|
||||
except Exception:
|
||||
# If the stack previously existed, and now can't be found then it's
|
||||
# been deleted successfully.
|
||||
if 'yes' in existed or operation == 'DELETE': # stacks may delete fast, look in a few ways.
|
||||
|
|
|
@ -608,7 +608,7 @@ def get_reservations(module, ec2, vpc, tags=None, state=None, zone=None):
|
|||
if isinstance(tags, str):
|
||||
try:
|
||||
tags = literal_eval(tags)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# if not a string type, convert and make sure it's a text string
|
||||
|
|
|
@ -1156,7 +1156,7 @@ def create_autoscaling_group(connection):
|
|||
else:
|
||||
try:
|
||||
ag['LaunchConfigurationName'] = as_group['LaunchConfigurationName']
|
||||
except:
|
||||
except Exception:
|
||||
launch_template = as_group['LaunchTemplate']
|
||||
# Prefer LaunchTemplateId over Name as it's more specific. Only one can be used for update_asg.
|
||||
ag['LaunchTemplate'] = {"LaunchTemplateId": launch_template['LaunchTemplateId'], "Version": launch_template['Version']}
|
||||
|
|
|
@ -516,7 +516,7 @@ class ElbManager(object):
|
|||
def get_info(self):
|
||||
try:
|
||||
check_elb = self.elb_conn.get_all_load_balancers(self.name)[0]
|
||||
except:
|
||||
except Exception:
|
||||
check_elb = None
|
||||
|
||||
if not check_elb:
|
||||
|
@ -528,11 +528,11 @@ class ElbManager(object):
|
|||
else:
|
||||
try:
|
||||
lb_cookie_policy = check_elb.policies.lb_cookie_stickiness_policies[0].__dict__['policy_name']
|
||||
except:
|
||||
except Exception:
|
||||
lb_cookie_policy = None
|
||||
try:
|
||||
app_cookie_policy = check_elb.policies.app_cookie_stickiness_policies[0].__dict__['policy_name']
|
||||
except:
|
||||
except Exception:
|
||||
app_cookie_policy = None
|
||||
|
||||
info = {
|
||||
|
|
|
@ -506,7 +506,7 @@ class Ec2Metadata(object):
|
|||
self._data['%s' % (new_uri)] = content
|
||||
for (key, value) in dict.items():
|
||||
self._data['%s:%s' % (new_uri, key.lower())] = value
|
||||
except:
|
||||
except Exception:
|
||||
self._data['%s' % (new_uri)] = content # not a stringifed JSON string
|
||||
|
||||
def fix_invalid_varnames(self, data):
|
||||
|
|
|
@ -124,7 +124,7 @@ from ansible.module_utils.ec2 import boto3_tag_list_to_ansible_dict, ansible_dic
|
|||
|
||||
try:
|
||||
from botocore.exceptions import BotoCoreError, ClientError
|
||||
except:
|
||||
except Exception:
|
||||
pass # Handled by AnsibleAWSModule
|
||||
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ def run(ecr, params, verbosity):
|
|||
ecr.set_repository_policy(
|
||||
registry_id, name, policy_text, force_set_policy)
|
||||
result['changed'] = True
|
||||
except:
|
||||
except Exception:
|
||||
# Some failure w/ the policy. It's helpful to know what the
|
||||
# policy is.
|
||||
result['policy'] = policy_text
|
||||
|
|
|
@ -512,7 +512,7 @@ class ElbManager(object):
|
|||
def get_info(self):
|
||||
try:
|
||||
check_elb = self.elb_conn.get_all_load_balancers(self.name)[0]
|
||||
except:
|
||||
except Exception:
|
||||
check_elb = None
|
||||
|
||||
if not check_elb:
|
||||
|
@ -524,11 +524,11 @@ class ElbManager(object):
|
|||
else:
|
||||
try:
|
||||
lb_cookie_policy = check_elb.policies.lb_cookie_stickiness_policies[0].__dict__['policy_name']
|
||||
except:
|
||||
except Exception:
|
||||
lb_cookie_policy = None
|
||||
try:
|
||||
app_cookie_policy = check_elb.policies.app_cookie_stickiness_policies[0].__dict__['policy_name']
|
||||
except:
|
||||
except Exception:
|
||||
app_cookie_policy = None
|
||||
|
||||
info = {
|
||||
|
|
|
@ -134,7 +134,7 @@ from ansible.module_utils.ec2 import get_aws_connection_info, boto3_conn
|
|||
|
||||
try:
|
||||
from botocore.exceptions import ClientError
|
||||
except:
|
||||
except Exception:
|
||||
pass # will be protected by AnsibleAWSModule
|
||||
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ def set_queue_attribute(queue, attribute, value, check_mode=False):
|
|||
|
||||
try:
|
||||
existing_value = queue.get_attributes(attributes=attribute)[attribute]
|
||||
except:
|
||||
except Exception:
|
||||
existing_value = ''
|
||||
|
||||
# convert dict attributes to JSON strings (sort keys for comparing)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue