mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -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
|
@ -143,7 +143,7 @@ class Inventory(object):
|
|||
return re.search(pattern_str[1:], str)
|
||||
else:
|
||||
return fnmatch.fnmatch(str, pattern_str)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise AnsibleError('invalid host pattern: %s' % pattern_str)
|
||||
|
||||
def _match_list(self, items, item_attr, pattern_str):
|
||||
|
@ -153,7 +153,7 @@ class Inventory(object):
|
|||
pattern = re.compile(fnmatch.translate(pattern_str))
|
||||
else:
|
||||
pattern = re.compile(pattern_str[1:])
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise AnsibleError('invalid host pattern: %s' % pattern_str)
|
||||
|
||||
for item in items:
|
||||
|
|
|
@ -46,7 +46,7 @@ class InventoryScript:
|
|||
cmd = [ self.filename, "--list" ]
|
||||
try:
|
||||
sp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
raise AnsibleError("problem running %s (%s)" % (' '.join(cmd), e))
|
||||
(stdout, stderr) = sp.communicate()
|
||||
|
||||
|
@ -153,7 +153,7 @@ class InventoryScript:
|
|||
cmd = [self.filename, "--host", host.name]
|
||||
try:
|
||||
sp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
raise AnsibleError("problem running %s (%s)" % (' '.join(cmd), e))
|
||||
(out, err) = sp.communicate()
|
||||
if out.strip() == '':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue