Add support for modified_since parameter to find command

Change-Id: Ieb4b5c7171cda33221b32639e46da90a4147dd08
This commit is contained in:
Federico Ressi 2021-02-15 13:54:07 +01:00
parent 0b2d3ed95e
commit 13aa4ddc6e
1 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,7 @@
# under the License.
from __future__ import absolute_import
import math
import typing # noqa
import tobiko
@ -35,12 +36,17 @@ def find_files(path: sh.ShellCommandType,
name: NameType = None,
command: sh.ShellCommandType = 'find',
ssh_client: ssh.SSHClientFixture = None,
modified_since: tobiko.Seconds = None,
**execute_params) -> typing.List[str]:
if not path:
raise ValueError("Path can't be empty")
command_line = sh.shell_command(command) + path
if name is not None:
command_line += ['-name', name]
command_line += f"-name '{name}'"
if modified_since is not None:
# round seconds to the next minute
minutes = math.ceil(modified_since / 60.)
command_line += f"-mmin {minutes}"
result = sh.execute(command_line,
ssh_client=ssh_client,
expect_exit_status=None,