From 13aa4ddc6e0206a46b8a0c2c4b2d7c5d96948afb Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Mon, 15 Feb 2021 13:54:07 +0100 Subject: [PATCH] Add support for modified_since parameter to find command Change-Id: Ieb4b5c7171cda33221b32639e46da90a4147dd08 --- tobiko/shell/find.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tobiko/shell/find.py b/tobiko/shell/find.py index a9f6e24aa..855584f94 100644 --- a/tobiko/shell/find.py +++ b/tobiko/shell/find.py @@ -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,