diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-07-16 17:29:50 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-23 18:53:44 +0000 |
commit | 9a18681ba62d1a297809c243607a7b3763131c36 (patch) | |
tree | 8333f8727fd7d32f81cb1f54754ccd138a7e1063 /contrib/python/pypodman/lib/actions/ps_action.py | |
parent | 8569ed03056ce39e0dc163747089ed4b60b1b9b1 (diff) | |
download | podman-9a18681ba62d1a297809c243607a7b3763131c36.tar.gz podman-9a18681ba62d1a297809c243607a7b3763131c36.tar.bz2 podman-9a18681ba62d1a297809c243607a7b3763131c36.zip |
[WIP] Refactor and simplify python builds
* pypodman namespaced in site-packages
* version numbers pulled from requirements.txt
* add python-podman spec file to install eggs
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Closes: #1106
Approved by: rhatdan
Diffstat (limited to 'contrib/python/pypodman/lib/actions/ps_action.py')
-rw-r--r-- | contrib/python/pypodman/lib/actions/ps_action.py | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/contrib/python/pypodman/lib/actions/ps_action.py b/contrib/python/pypodman/lib/actions/ps_action.py deleted file mode 100644 index 4bbec5578..000000000 --- a/contrib/python/pypodman/lib/actions/ps_action.py +++ /dev/null @@ -1,76 +0,0 @@ -"""Remote client commands dealing with containers.""" -import operator -from collections import OrderedDict - -import humanize -import podman - -from .. import AbstractActionBase, Report, ReportColumn - - -class Ps(AbstractActionBase): - """Class for Container manipulation.""" - - @classmethod - def subparser(cls, parent): - """Add Images command to parent parser.""" - parser = parent.add_parser('ps', help='list containers') - super().subparser(parser) - parser.add_argument( - '--sort', - choices=[ - 'createdat', 'id', 'image', 'names', 'runningfor', 'size', - 'status' - ], - default='createdat', - type=str.lower, - help=('Change sort ordered of displayed containers.' - ' (default: %(default)s)')) - parser.set_defaults(class_=cls, method='list') - - def __init__(self, args): - """Construct Ps class.""" - super().__init__(args) - - self.columns = OrderedDict({ - 'id': - ReportColumn('id', 'CONTAINER ID', 14), - 'image': - ReportColumn('image', 'IMAGE', 30), - 'command': - ReportColumn('column', 'COMMAND', 20), - 'createdat': - ReportColumn('createdat', 'CREATED', 12), - 'status': - ReportColumn('status', 'STATUS', 10), - 'ports': - ReportColumn('ports', 'PORTS', 28), - 'names': - ReportColumn('names', 'NAMES', 18) - }) - - def list(self): - """List containers.""" - # TODO: Verify sorting on dates and size - ctnrs = sorted( - self.client.containers.list(), - key=operator.attrgetter(self._args.sort)) - if len(ctnrs) == 0: - return 0 - - rows = list() - for ctnr in ctnrs: - fields = dict(ctnr) - fields.update({ - 'command': - ' '.join(ctnr.command), - 'createdat': - humanize.naturaldate(podman.datetime_parse(ctnr.createdat)), - }) - rows.append(fields) - - with Report(self.columns, heading=self._args.heading) as report: - report.layout( - rows, self.columns.keys(), truncate=self._args.truncate) - for row in rows: - report.row(**row) |