Skip to content

Commit

Permalink
Don't show the find output in files facts!
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Jul 14, 2020
1 parent 18a61dd commit f065fa5
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pyinfra/facts/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/directory/file.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/directory/link.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/directory/valid.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/directory.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/link.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/valid.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/valid_full_time.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/valid_incomplete.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/valid_legacy_busybox.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/valid_other_time.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/valid_with_space.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/file/valid_with_space_already_escaped.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/link/directory.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/link/file.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/facts/link/valid.json
Original file line number Diff line number Diff line change
@@ -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 -> [email protected]"
],
Expand Down

0 comments on commit f065fa5

Please sign in to comment.