cp.get_file_str: do not fail if file not found (#36936)

This commit is contained in:
Denys Havrysh 2016-10-12 22:40:49 +03:00 committed by Nicole Thomas
parent 2ccc44f314
commit e2bc94b029

View file

@ -341,6 +341,8 @@ def get_file_str(path, saltenv='base', env=None):
'''
Return the contents of a file from a URL
Returns ``False`` if Salt was unable to cache a file from a URL.
CLI Example:
.. code-block:: bash
@ -357,9 +359,11 @@ def get_file_str(path, saltenv='base', env=None):
saltenv = env
fn_ = cache_file(path, saltenv)
with salt.utils.fopen(fn_, 'r') as fp_:
data = fp_.read()
return data
if isinstance(fn_, six.string_types):
with salt.utils.fopen(fn_, 'r') as fp_:
data = fp_.read()
return data
return fn_
def cache_file(path, saltenv='base', env=None):