diff --git a/pyinfra/facts/files.py b/pyinfra/facts/files.py index 257cd7b22..bce9486b2 100644 --- a/pyinfra/facts/files.py +++ b/pyinfra/facts/files.py @@ -28,7 +28,7 @@ def command(self, name): name = escape_unix_path(name) commands = [ls_command.format(name) for ls_command in self._ls_commands] ls_command = ' || '.join(commands) - return 'find {0} 2> /dev/null && ({1})'.format(name, ls_command) + return 'find {0} &> /dev/null && ({1})'.format(name, ls_command) def process(self, output): return parse_ls_output(output[0], self.type) diff --git a/tests/facts/directory/file.json b/tests/facts/directory/file.json index 997fab10d..dc8672616 100644 --- a/tests/facts/directory/file.json +++ b/tests/facts/directory/file.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/mylink", - "command": "find /home/pyinfra/mylink 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", + "command": "find /home/pyinfra/mylink &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", "output": [ "-rwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/file.txt" ], diff --git a/tests/facts/directory/link.json b/tests/facts/directory/link.json index cd059464a..8fffb8822 100644 --- a/tests/facts/directory/link.json +++ b/tests/facts/directory/link.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/mylink", - "command": "find /home/pyinfra/mylink 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", + "command": "find /home/pyinfra/mylink &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", "output": [ "lrwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/file.txt -> file.txt" ], diff --git a/tests/facts/directory/valid.json b/tests/facts/directory/valid.json index 9d3a7573a..fcc344a93 100644 --- a/tests/facts/directory/valid.json +++ b/tests/facts/directory/valid.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/myd@-_ir", - "command": "find /home/pyinfra/myd@-_ir 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/myd@-_ir 2> /dev/null || ls -ld --full-time /home/pyinfra/myd@-_ir 2> /dev/null || ls -lde /home/pyinfra/myd@-_ir 2> /dev/null || ls -ldT /home/pyinfra/myd@-_ir)", + "command": "find /home/pyinfra/myd@-_ir &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/myd@-_ir 2> /dev/null || ls -ld --full-time /home/pyinfra/myd@-_ir 2> /dev/null || ls -lde /home/pyinfra/myd@-_ir 2> /dev/null || ls -ldT /home/pyinfra/myd@-_ir)", "output": [ "drwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/myd@-_ir" ], diff --git a/tests/facts/file/directory.json b/tests/facts/file/directory.json index 125cb06cc..c303406f0 100644 --- a/tests/facts/file/directory.json +++ b/tests/facts/file/directory.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/mylink", - "command": "find /home/pyinfra/mylink 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", + "command": "find /home/pyinfra/mylink &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", "output": [ "drwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/mylink" ], diff --git a/tests/facts/file/link.json b/tests/facts/file/link.json index cd059464a..8fffb8822 100644 --- a/tests/facts/file/link.json +++ b/tests/facts/file/link.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/mylink", - "command": "find /home/pyinfra/mylink 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", + "command": "find /home/pyinfra/mylink &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", "output": [ "lrwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/file.txt -> file.txt" ], diff --git a/tests/facts/file/valid.json b/tests/facts/file/valid.json index 654d0ef13..f704a2181 100644 --- a/tests/facts/file/valid.json +++ b/tests/facts/file/valid.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/fil-@_e.txt", - "command": "find /home/pyinfra/fil-@_e.txt 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", + "command": "find /home/pyinfra/fil-@_e.txt &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", "output": [ "-rwxrwxrwx 1 pyinfra pyinfra 8 Feb 13 12:56:00 2016 /home/pyinfra/fil-@_e.txt" ], diff --git a/tests/facts/file/valid_full_time.json b/tests/facts/file/valid_full_time.json index 67095c069..a9e588b3e 100644 --- a/tests/facts/file/valid_full_time.json +++ b/tests/facts/file/valid_full_time.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/fil-@_e.txt", - "command": "find /home/pyinfra/fil-@_e.txt 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", + "command": "find /home/pyinfra/fil-@_e.txt &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", "output": [ "-rwxrwxrwx 1 pyinfra pyinfra 8 2020-07-09 15:34:36 +0000 /home/pyinfra/fil-@_e.txt" ], diff --git a/tests/facts/file/valid_incomplete.json b/tests/facts/file/valid_incomplete.json index 5739f38ee..702414b88 100644 --- a/tests/facts/file/valid_incomplete.json +++ b/tests/facts/file/valid_incomplete.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/fil-@_e.txt", - "command": "find /home/pyinfra/fil-@_e.txt 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", + "command": "find /home/pyinfra/fil-@_e.txt &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", "output": [ "-rwxrwxrxw 1 pyinfra pyinfra 8 Feb 46 12:56:00 2016 /home/pyinfra/fil-@_e.txt" ], diff --git a/tests/facts/file/valid_legacy_busybox.json b/tests/facts/file/valid_legacy_busybox.json index 51077138b..46a78d75e 100644 --- a/tests/facts/file/valid_legacy_busybox.json +++ b/tests/facts/file/valid_legacy_busybox.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/fil-@_e.txt", - "command": "find /home/pyinfra/fil-@_e.txt 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", + "command": "find /home/pyinfra/fil-@_e.txt &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra/fil-@_e.txt)", "output": [ "-rwxrwxrwx 1 pyinfra pyinfra 8 Thu Jul 9 15:34:36 2020 /home/pyinfra/fil-@_e.txt" ], diff --git a/tests/facts/file/valid_other_time.json b/tests/facts/file/valid_other_time.json index 7337d1dcd..35dfcf49a 100644 --- a/tests/facts/file/valid_other_time.json +++ b/tests/facts/file/valid_other_time.json @@ -1,6 +1,6 @@ { "arg": "/Users/pyinfra/file.dmg", - "command": "find /Users/pyinfra/file.dmg 2> /dev/null && (ls -ld --time-style=long-iso /Users/pyinfra/file.dmg 2> /dev/null || ls -ld --full-time /Users/pyinfra/file.dmg 2> /dev/null || ls -lde /Users/pyinfra/file.dmg 2> /dev/null || ls -ldT /Users/pyinfra/file.dmg)", + "command": "find /Users/pyinfra/file.dmg &> /dev/null && (ls -ld --time-style=long-iso /Users/pyinfra/file.dmg 2> /dev/null || ls -ld --full-time /Users/pyinfra/file.dmg 2> /dev/null || ls -lde /Users/pyinfra/file.dmg 2> /dev/null || ls -ldT /Users/pyinfra/file.dmg)", "output": [ "-rw-r--r-- 1 staff pyinfra 210653788 Jul 13 12:57 /Users/pyinfra/file.dmg" ], diff --git a/tests/facts/file/valid_with_space.json b/tests/facts/file/valid_with_space.json index 2d8d5b25a..922198fe0 100644 --- a/tests/facts/file/valid_with_space.json +++ b/tests/facts/file/valid_with_space.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra dir/fil-@_e.txt", - "command": "find /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra\\ dir/fil-@_e.txt)", + "command": "find /home/pyinfra\\ dir/fil-@_e.txt &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra\\ dir/fil-@_e.txt)", "output": [ "-rwxrwxrwx 1 pyinfra pyinfra 8 Feb 13 12:56:00 2016 /home/pyinfra\\ dir/fil-@_e.txt" ], diff --git a/tests/facts/file/valid_with_space_already_escaped.json b/tests/facts/file/valid_with_space_already_escaped.json index 5492f0038..fbcad20cc 100644 --- a/tests/facts/file/valid_with_space_already_escaped.json +++ b/tests/facts/file/valid_with_space_already_escaped.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra\\ dir/fil-@_e.txt", - "command": "find /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra\\ dir/fil-@_e.txt)", + "command": "find /home/pyinfra\\ dir/fil-@_e.txt &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ld --full-time /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -lde /home/pyinfra\\ dir/fil-@_e.txt 2> /dev/null || ls -ldT /home/pyinfra\\ dir/fil-@_e.txt)", "output": [ "-rwxrwxrwx 1 pyinfra pyinfra 8 Feb 13 12:56:00 2016 /home/pyinfra\\ dir/fil-@_e.txt" ], diff --git a/tests/facts/link/directory.json b/tests/facts/link/directory.json index 125cb06cc..c303406f0 100644 --- a/tests/facts/link/directory.json +++ b/tests/facts/link/directory.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/mylink", - "command": "find /home/pyinfra/mylink 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", + "command": "find /home/pyinfra/mylink &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", "output": [ "drwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/mylink" ], diff --git a/tests/facts/link/file.json b/tests/facts/link/file.json index 997fab10d..dc8672616 100644 --- a/tests/facts/link/file.json +++ b/tests/facts/link/file.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/mylink", - "command": "find /home/pyinfra/mylink 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", + "command": "find /home/pyinfra/mylink &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/mylink 2> /dev/null || ls -ld --full-time /home/pyinfra/mylink 2> /dev/null || ls -lde /home/pyinfra/mylink 2> /dev/null || ls -ldT /home/pyinfra/mylink)", "output": [ "-rwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/file.txt" ], diff --git a/tests/facts/link/valid.json b/tests/facts/link/valid.json index d024e5f61..97c571e2e 100644 --- a/tests/facts/link/valid.json +++ b/tests/facts/link/valid.json @@ -1,6 +1,6 @@ { "arg": "/home/pyinfra/my@-_link", - "command": "find /home/pyinfra/my@-_link 2> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/my@-_link 2> /dev/null || ls -ld --full-time /home/pyinfra/my@-_link 2> /dev/null || ls -lde /home/pyinfra/my@-_link 2> /dev/null || ls -ldT /home/pyinfra/my@-_link)", + "command": "find /home/pyinfra/my@-_link &> /dev/null && (ls -ld --time-style=long-iso /home/pyinfra/my@-_link 2> /dev/null || ls -ld --full-time /home/pyinfra/my@-_link 2> /dev/null || ls -lde /home/pyinfra/my@-_link 2> /dev/null || ls -ldT /home/pyinfra/my@-_link)", "output": [ "lrwxrwxrwx 1 pyinfra pyinfra 8 2016-02-13 12:56 /home/pyinfra/my@-_link -> my_f@-ile.txt" ],