diff options
author | baude <bbaude@redhat.com> | 2018-06-22 08:15:37 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-27 04:52:22 +0000 |
commit | 60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5 (patch) | |
tree | 64f11dab9bcdc426956160b6b56ee536bb3aa6e8 /contrib/python/cmd/utils.py | |
parent | 56133f7263337e9b2c9cfb1cfce35adc2366f52b (diff) | |
download | podman-60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5.tar.gz podman-60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5.tar.bz2 podman-60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5.zip |
add podman remote client
podman client that is capable of:
* images
* ps
* rm
* rmi
this is only a mockup to frame out and prove python library and ssh
tunnelling usage.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #986
Approved by: rhatdan
Diffstat (limited to 'contrib/python/cmd/utils.py')
-rw-r--r-- | contrib/python/cmd/utils.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/python/cmd/utils.py b/contrib/python/cmd/utils.py new file mode 100644 index 000000000..d4a14164d --- /dev/null +++ b/contrib/python/cmd/utils.py @@ -0,0 +1,32 @@ +import sys +import math +import datetime + +def write_out(output, lf="\n"): + _output(sys.stdout, output, lf) + + +def write_err(output, lf="\n"): + _output(sys.stderr, output, lf) + + +def _output(fd, output, lf): + fd.flush() + fd.write(output + str(lf)) + + +def convert_size(size): + if size > 0: + size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") + i = int(math.floor(math.log(size, 1000))) + p = math.pow(1000, i) + s = round(size/p, 2) # pylint: disable=round-builtin,old-division + if s > 0: + return '%s %s' % (s, size_name[i]) + return '0B' + +def stringTimeToHuman(t): + #datetime.date(datetime.strptime("05/Feb/2016", '%d/%b/%Y')) + #2018-04-30 13:55:45.019400581 +0000 UTC + #d = datetime.date(datetime.strptime(t, "%Y-%m-%d")) + return "sometime ago" |