Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions salt/modules/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down