Pyinfra: Regression on file facts (v1.0.2)

Created on 15 Jul 2020  路  3Comments  路  Source: Fizzadar/pyinfra

Describe the bug

File facts (file existence check) seems broken.

host.fact.file(FILE)

for a valid FILE path returns None, with no warning/info message. On v1.0.0 it is working well.

Seems this is a related commit: acae97d863e66874fb7d57f08643f9194f98e4e2 (#365).

The output of pyinfra -vv (LONG_FILE_NAME is a placeholder to hide sensitive input)

find LONG_FILE_NAME &> /dev/null && (ls -ld --time-style=long-iso LONG_FILE_NAME 2> /dev/null || ls -ld --full-time LONG_FILE_NAME 2> /dev/null || ls -lde LONG_FILE_NAME 2> /dev/null || ls -ldT LONG_FILE_NAME)
-rw-r--r-- 1 MYUSERID MYUSERGRP 142648373 2020-07-07 05:41 LONG_FILE_NAME

Meta

  • Include output of pyinfra --support.

    • 1.0.2

  • How was pyinfra installed (source/pip)?

    • pip

  • Include pyinfra-debug.log (if one was created)
  • Consider including output with -vv and --debug.
Bug

Most helpful comment

This should be fixed by the move to using stat for these facts, which I'll release in 1.0.3 today/tomorrow.

All 3 comments

This is strange - does the filename contain any strange characters? Testing this locally works:

In [1]: from pyinfra.facts.files import File

In [2]: f=File()

In [3]: f.process(['-rw-r--r-- 1 MYUSERID MYUSERGRP 142648373 2020-07-07 05:41 LONG_FILE_NAME'])
Out[3]:
{'mode': 644,
 'user': 'MYUSERID',
 'group': 'MYUSERGRP',
 'size': '142648373',
 'mtime': datetime.datetime(2020, 7, 7, 5, 41)}

I think this is the addition of the find statement which is my mistake - should be stat not find (https://github.com/Fizzadar/pyinfra/commit/c793dc0f1deb81c1860de6b5589742cd759c4842). Working on a fix!

This should be fixed by the move to using stat for these facts, which I'll release in 1.0.3 today/tomorrow.

Was this page helpful?
0 / 5 - 0 ratings