mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
Use 'except ... as' syntax
This syntax works on Python 2.6 through 3.x. lib/ansible/module_utils (and lib/ansible/modules) need to support Python 2.4, so I didn't touch those.
This commit is contained in:
parent
2ac931d6c9
commit
0c6ce31f76
24 changed files with 51 additions and 51 deletions
|
@ -67,7 +67,7 @@ except ImportError:
|
|||
try:
|
||||
import consul
|
||||
HAS_CONSUL = True
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
HAS_CONSUL = False
|
||||
|
||||
|
||||
|
@ -104,7 +104,7 @@ class LookupModule(LookupBase):
|
|||
values.append(r['Value'])
|
||||
else:
|
||||
values.append(results[1]['Value'])
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise AnsibleError(
|
||||
"Error locating '%s' in kv store. Error was %s" % (term, e))
|
||||
|
||||
|
@ -127,7 +127,7 @@ class LookupModule(LookupBase):
|
|||
name, value = param.split('=')
|
||||
assert name in paramvals, "% not a valid consul lookup parameter" % name
|
||||
paramvals[name] = value
|
||||
except (ValueError, AssertionError), e:
|
||||
except (ValueError, AssertionError) as e:
|
||||
raise AnsibleError(e)
|
||||
|
||||
return paramvals
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue