Fix some stuff
This commit is contained in:
parent
0ecf09e35b
commit
b4dcdbc905
2 changed files with 6 additions and 9 deletions
|
@ -1,9 +1,6 @@
|
|||
from subprocess import getoutput
|
||||
import docker_parser
|
||||
import pprint
|
||||
|
||||
# Goals: Loop: Select container (or exit), then menu to do stuff to container (start, stop, rm, list info, go back to main menu)
|
||||
|
||||
|
||||
if '\n' not in getoutput('docker ps'):
|
||||
print('No containers running')
|
||||
exit()
|
||||
ps()
|
||||
pprint.pprint(docker_parser.DockerParser.ps())
|
||||
|
|
|
@ -5,7 +5,7 @@ class NoContainersError(Exception):
|
|||
pass
|
||||
|
||||
class DockerParser:
|
||||
def ps(raw_info='docker ps'):
|
||||
def ps(raw_info=getoutput('docker ps')):
|
||||
"""
|
||||
Gets info about all running Docker containers from docker ps
|
||||
:return: Nested dict of containers info
|
||||
|
@ -38,7 +38,7 @@ class DockerParser:
|
|||
end_i = header_indices[header_indices_keys[j+1]]
|
||||
else:
|
||||
end_i = len(header)
|
||||
info[containers[i]][header_indices[header_indices_keys[j]]] = \
|
||||
info[containers[i]][header_indices_keys[j]] = \
|
||||
raw_info.split('\n')[i][start_i:end_i].strip()
|
||||
|
||||
return info
|
||||
|
@ -50,7 +50,7 @@ class DockerParser:
|
|||
"""
|
||||
if '\n' not in raw_info:
|
||||
raise(NoContainersError('A Docker container is required to run this program. Please create a docker container and try again.'))
|
||||
raw_info = getoutput('docker ps')
|
||||
raw_info = getoutput('docker container list')
|
||||
# Header: "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES" (with way more spaces)
|
||||
header = raw_info[:raw_info.find('\n')+1]
|
||||
header_temp = header
|
||||
|
|
Loading…
Reference in a new issue