mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add ignore ability to process_read_exception
This commit is contained in:
parent
015834ded9
commit
9f547205a0
1 changed files with 13 additions and 1 deletions
|
@ -205,10 +205,22 @@ def rename(src, dst):
|
|||
os.rename(src, dst)
|
||||
|
||||
|
||||
def process_read_exception(exc, path):
|
||||
def process_read_exception(exc, path, ignore=None):
|
||||
'''
|
||||
Common code for raising exceptions when reading a file fails
|
||||
|
||||
The ignore argument can be an iterable of integer error codes (or a single
|
||||
integer error code) that should be ignored.
|
||||
'''
|
||||
if ignore is not None:
|
||||
if isinstance(ignore, six.integer_types):
|
||||
ignore = (ignore,)
|
||||
else:
|
||||
ignore = ()
|
||||
|
||||
if exc.errno in ignore:
|
||||
return
|
||||
|
||||
if exc.errno == errno.ENOENT:
|
||||
raise CommandExecutionError('{0} does not exist'.format(path))
|
||||
elif exc.errno == errno.EACCES:
|
||||
|
|
Loading…
Add table
Reference in a new issue