mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-21 15:10:22 +00:00
model
This commit is contained in:
parent
34e0cce673
commit
c9d737f57f
3 changed files with 24 additions and 9 deletions
|
@ -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:
|
||||
|
|
16
cli/model.py
16
cli/model.py
|
@ -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)
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue