mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-25 00:50:30 +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:
|
class Print:
|
||||||
|
|
||||||
def __init__(self):
|
'''display all any information you want'''
|
||||||
pass
|
|
||||||
|
def __init__(self, status: Optional[str] = 'all'):
|
||||||
|
self.status = status
|
||||||
|
|
||||||
def printRepo():
|
def printRepo():
|
||||||
model.FileOp.printJson(path_repo)
|
model.FileOp.printJson(path_repo)
|
||||||
|
|
||||||
|
def lsProject(self):
|
||||||
|
ls = model.DockerOp(self.status)
|
||||||
|
ls.lsProject()
|
||||||
|
|
||||||
|
|
||||||
class Create:
|
class Create:
|
||||||
|
|
16
cli/model.py
16
cli/model.py
|
@ -156,18 +156,26 @@ class DockerComposeOp:
|
||||||
|
|
||||||
class DockerOp:
|
class DockerOp:
|
||||||
''' Docker operation '''
|
''' Docker operation '''
|
||||||
def __init__(self):
|
def __init__(self, status: Optional[str] = 'all'):
|
||||||
self.client = docker.from_env()
|
self.client = docker.from_env()
|
||||||
|
self.status = status
|
||||||
|
|
||||||
def lsContainer(self):
|
def lsContainer(self):
|
||||||
container_list = []
|
container_list = []
|
||||||
|
|
||||||
for container in self.client.containers.list(all):
|
for container in self.client.containers.list(self.status):
|
||||||
container_list.append(container.name)
|
container_list.append(container.name)
|
||||||
return container_list
|
return container_list
|
||||||
|
|
||||||
def lsProject(self):
|
def getProject(self):
|
||||||
project_dict = {}
|
project_dict = {}
|
||||||
|
|
||||||
for name in self.lsContainer():
|
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 = typer.Typer()
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def list():
|
def ls(status: Optional[str] = 'all'):
|
||||||
'''print the lists file'''
|
'''list all the project have installed'''
|
||||||
controller.Print.printRepo()
|
print = controller.Print(status)
|
||||||
|
print.lsProject()
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def create(app_name: str, project_name: Optional[str] = None):
|
def create(app_name: str, project_name: Optional[str] = None):
|
||||||
|
|
Loading…
Reference in a new issue