This commit is contained in:
chendelin1982 2021-10-18 19:07:41 +08:00
parent 34e0cce673
commit c9d737f57f
3 changed files with 24 additions and 9 deletions

View file

@ -9,11 +9,17 @@ github_url = ("https://github.com", "https://hub.fastgit.org", "https://github.c
class Print:
def __init__(self):
pass
'''display all any information you want'''
def __init__(self, status: Optional[str] = 'all'):
self.status = status
def printRepo():
model.FileOp.printJson(path_repo)
def lsProject(self):
ls = model.DockerOp(self.status)
ls.lsProject()
class Create:

View file

@ -156,18 +156,26 @@ class DockerComposeOp:
class DockerOp:
''' Docker operation '''
def __init__(self):
def __init__(self, status: Optional[str] = 'all'):
self.client = docker.from_env()
self.status = status
def lsContainer(self):
container_list = []
for container in self.client.containers.list(all):
for container in self.client.containers.list(self.status):
container_list.append(container.name)
return container_list
def lsProject(self):
def getProject(self):
project_dict = {}
for name in self.lsContainer():
print(self.client.containers.get(name).labels)
project_dict[self.client.containers.get(name).labels['com.docker.compose.project']] = self.client.containers.get(name).labels['com.docker.compose.project.working_dir']
return project_dict
def lsProject(self):
'''list all project and path'''
for key, value in self.getProject().items():
print(key,value)

View file

@ -9,9 +9,10 @@ import typer
app = typer.Typer()
@app.command()
def list():
'''print the lists file'''
controller.Print.printRepo()
def ls(status: Optional[str] = 'all'):
'''list all the project have installed'''
print = controller.Print(status)
print.lsProject()
@app.command()
def create(app_name: str, project_name: Optional[str] = None):