diff options
author | Rhiza <6900588+ArchiMoebius@users.noreply.github.com> | 2022-08-19 15:10:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-19 15:10:53 -0400 |
commit | 923e067dddc3d4b86e4e620a99fcdcdafbd17a98 (patch) | |
tree | c26760d6bbc253101f73da7f8f69564fdcd06eb6 /docker/api/container.py | |
parent | 1c27ec1f0c34f6b9510f5caadada5fd8ecc430d9 (diff) | |
download | docker-py-923e067dddc3d4b86e4e620a99fcdcdafbd17a98.tar.gz |
api: add support for floats to docker logs params since / until (#3031)
Add support for floats to docker logs params `since` / `until` since the
Docker Engine APIs support it.
This allows using fractional seconds for greater precision.
Signed-off-by: Archi Moebius <poerhiz@gmail.com>
Diffstat (limited to 'docker/api/container.py')
-rw-r--r-- | docker/api/container.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/docker/api/container.py b/docker/api/container.py index f600be1..ce48371 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -826,11 +826,12 @@ class ContainerApiMixin: tail (str or int): Output specified number of lines at the end of logs. Either an integer of number of lines or the string ``all``. Default ``all`` - since (datetime or int): Show logs since a given datetime or - integer epoch (in seconds) + since (datetime, int, or float): Show logs since a given datetime, + integer epoch (in seconds) or float (in fractional seconds) follow (bool): Follow log output. Default ``False`` - until (datetime or int): Show logs that occurred before the given - datetime or integer epoch (in seconds) + until (datetime, int, or float): Show logs that occurred before + the given datetime, integer epoch (in seconds), or + float (in fractional seconds) Returns: (generator or str) @@ -855,9 +856,11 @@ class ContainerApiMixin: params['since'] = utils.datetime_to_timestamp(since) elif (isinstance(since, int) and since > 0): params['since'] = since + elif (isinstance(since, float) and since > 0.0): + params['since'] = since else: raise errors.InvalidArgument( - 'since value should be datetime or positive int, ' + 'since value should be datetime or positive int/float, ' 'not {}'.format(type(since)) ) @@ -870,9 +873,11 @@ class ContainerApiMixin: params['until'] = utils.datetime_to_timestamp(until) elif (isinstance(until, int) and until > 0): params['until'] = until + elif (isinstance(until, float) and until > 0.0): + params['until'] = until else: raise errors.InvalidArgument( - 'until value should be datetime or positive int, ' + 'until value should be datetime or positive int/float, ' 'not {}'.format(type(until)) ) |