mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Add ignore ability to process_read_exception
This commit is contained in:
parent
015834ded9
commit
9f547205a0
@ -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…
Reference in New Issue
Block a user