-
-
Notifications
You must be signed in to change notification settings - Fork 434
Open
Description
Describe the bug
The docs of FileContents
say:
Returns
None
if the file doest not exist.
However, it actually errors and stops the script.
(Also, note the "doest" typo.)
To Reproduce
from pyinfra import host
from pyinfra.facts.files import FileContents
host.get_fact(FileContents, "doesnotexist")
pyinfra localhost test.py
--> Preparing operation files...
Loading: test.py
[localhost] cat: doesnotexist: No such file or directory
[localhost] Error: could not load fact: files.FileContents path=doesnotexist
Expected behavior
The current behavior could be correct in the sense that asking for the contents of a file that does not exist may be an error. OTOH, returning None
for non-existent files also makes sense. So:
- either the documentation should be corrected, or
- it should return
None
if the file does not exist.
The typo ("doest") should be fixed. Sha1File
has the same typo.
Meta
- Include output of
pyinfra --support
. - How was pyinfra installed (source/pip)?
- Include pyinfra-debug.log (if one was created)
- Consider including output with
-vv
and--debug
.
Metadata
Metadata
Assignees
Labels
No labels