From b1063250c7d15db547eccf7f061e6e789c5f772c Mon Sep 17 00:00:00 2001 From: chendelin1982 Date: Mon, 1 Nov 2021 19:23:17 +0800 Subject: [PATCH] up error --- cli/__pycache__/controller.cpython-36.pyc | Bin 0 -> 4594 bytes cli/__pycache__/model.cpython-36.pyc | Bin 0 -> 7280 bytes cli/controller.py | 38 +++++++++++++++++++-- cli/model.py | 12 +++---- cli/stackhub.py | 39 ++++++++++++++++++---- 5 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 cli/__pycache__/controller.cpython-36.pyc create mode 100644 cli/__pycache__/model.cpython-36.pyc diff --git a/cli/__pycache__/controller.cpython-36.pyc b/cli/__pycache__/controller.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d29f462f95f3d808913066138258cf428720cda2 GIT binary patch literal 4594 zcmbtY-EJGl72erDE|=7g6-P?i)Yue(8@3UNHWzJ!xQHV;sS}h^CADsd1jKr0B#~O} zu4k9FMNkM(xkG_ndXrbsRlhU4q$t_RMNMJO%$zej=ggV&H+pwz z$^X@Vz6{5!hVhND@Ut-f04+}dxWQR$^va&~n4X(GQ}hv6DaI5EX zyI14OJ?~?Kd%XV4;Pt85t7GQ#24)S+e9W4B39}{48l3GLt(9-V)9ALCay}juJK1=n z-Qi&ocET)+2T@oI(xe>^@A!ai^Zz7FzBD zOxVQeL;cvCK`+t+u4O7a7xAH<{L7HE?xNK>O^S}_?8=mnqN0P1qZ6p16UBp0lqQ8t z<5ifP>J_aBYIxT4hheV#@@TX`X66T3-Lqvo){l`c_| zMq~|uW;xxpXWHhn{M97;_Pdao7{qx+T7+2tP{4%YuZ}1H^N%A zAND-ngkdcycT0+}5HKtco~F;FnpvqNJ&TAN{ivUt!!I!51{tU}Q#LU%MjIkNoLKTU zjfk3f7+o=BOSy+>%!QOcz#j6404+;j#wB7wIa)8II$D_1z%X5gKhtNvIbJEnzck*N zwb12}#9L^20YKI=HO?7&6FvNzY^JcMYy%N&17{gJ7+HGcZW!lQQ5$;0I=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TJO32aCThuvo25Fekp42jxpLTdI~X z-&3aS09`B4)`GP&>iwd1;k=%~7W9{Kc## z<)MFEa;5ij^Lo_V0KLq^-cCmUO+YP8&k4ChfOe3-C$LB0fWT!C)FW-_pMY?JmeWIy zUTEv99^Po>pCl?$1_cf25THsHqR?AZryQMGl%J0t!kZ$I=kk|CB1Om*fL>ESnJZV5 m0paOUs3Wc3{zXzL@BQ)x`Wx~kU2eaP+=C2c;R(62y!StQ(*hL$ literal 0 HcmV?d00001 diff --git a/cli/__pycache__/model.cpython-36.pyc b/cli/__pycache__/model.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3642d67c50fd8c1d2327c9537c21647906cda1a6 GIT binary patch literal 7280 zcmcIp&vP6{6`tQayOvfzBgali#)(Oy#F2qODg?(Uk%>dfwRU0~CtC^2c%~(-G`q9z znYE>@RdEniKowLj6bC942TpM0%#}ZY>m1?a6L(+W`+8<)SMnxtNJXmYnf@`;@4f!| zd++tWGCN!Q{Xc&0|8q&x{;f^?nRs5umHZ1usD*l@HS@dP)K%SR8tQH~O?9`Lmb%+b zTiuu%r<8`^=7>@*PQFjH|IMG&4tclb5YOd zT52v|)4_fWanMSs9gjs8kQK8F^e(ReVN4x<^N`3tRS2|Kht z)s(rw}07D?(Qs>AEc$lHvice$NvOo>PNScA~DS1A?!`}K( zzodQq+JUiuHr00Y9b*WygvM`;9rF;Pr&eeVjg#7;u4_Z%I$HRD&-qZh<9vYY7Drg@ zP3;{gwE3iTbQ0mAw(!2To6|bGV?hRgTh(IKXFZVqulDIDep*jP< z>viK4jefArh zX5!t<;+w0coW-kh9z|xg@xih6Wu1*CMKPq}EtyUNZt(Kg_N2SZ+2^Qtj=TDqia&{3(pUTN)alYHCAnT5}(eDILVwGhVpSV$Wtg*jodD0*l^T1nG4xADB3gVOxURz z2EbGYm;j~1R--|{l6;b1`38%pSkSTxGJtR@Lg^?b_6mcpLJZx zM<^x;v>6T@EMBNNq}T@_>3jt3hNZu9An7jcC#8T=W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ikh=)|FS+4z;5~!nwASD845oqN6Jqn(4s=P8G9VMRSLr$_4trr|I_) zzZKKS_wd1K6LICg>O^51vG5m76pts83wUN4n0x1J)=z?VyA_Ev6%wnbzK6_jCvJB$ z8*8v7GSkPYf|>L?BS!f#zLB{lZn(oiwhi3!gs?VVyDc;(+y0}7EGRh-1k>D|?H&7zYK#5QrrMW+!B5XkzuF|@Rl+P&+6e>GzexOjKeB7ZB_oZA(SxIjB8E$O9DIZvNst?qco_w^=OH}(h!jU*hz0+pKH79Q zW!!0r?p=^l)W*q!q$3)gitu^DCd%_O3;GkTJWWTQHCPzQ`Y@rG7|2UWw1$T*?Lgl< z3qpZp$Ve4EBUhbAg03?kMWzW_Vg5Pfi9JFlN4D`^R%5=8lQlYDq=oRx6fSdo1Q5t8 zEgpszZns%4$Ex$`X0@yzQzknRB^#sf{u$p(m|SaEV+QquVoP1^txXIow-oiVaVg#2 z!UOVfeeX5ucBnz8bI?g?nP)sWVbo8lGbn0awi%~1JO|ISmaooQ;e^%- zPqM}w52q9@_=Umg&mM==har@YFyIJy$(_#-aG)u0Z2*>WqO4z{m8sT^Krv}5Jv5GO`{il2Kr zl2$`xiBlE%E*|9#7Taue()}I)Ai2vW0Vru@Nf_qQUWHEtv7{fDq^xE=|0QFs_#s0s yv4T1e~T(=3dBug}6uwRG{$=z~Gwo<@#Lxd0dP27yk!V`3F+~ literal 0 HcmV?d00001 diff --git a/cli/controller.py b/cli/controller.py index 184ca964..b0176355 100644 --- a/cli/controller.py +++ b/cli/controller.py @@ -104,6 +104,40 @@ class Create: pass -class Manage(model.DockerComposeOp): - pass +class Status: + + '''The status operation of project, e.g Start | Stop | Restart | Erase''' + + def __init__(self, project_name: str, project_path: Optional[str] = None): + + self.project_name = project_name + self.project_path = project_path + self.dockerop = model.DockerOp() + + projectdict = self.dockerop.getProject() + + if self.project_path == None: + try: + self.project_path = projectdict[self.project_name] + self.dockercomposeop = model.DockerComposeOp(self.project_path) + except: + print("No this application!") + sys.exit(0) + def stopApp(self): + pass + + def upApp(self): + pass + + def startApp(self): + pass + + def retartApp(self): + pass + + def eraseApp(self): + self.dockercomposeop.down() + + def upApp(self): + self.dockercomposeop.up(self.project_path) \ No newline at end of file diff --git a/cli/model.py b/cli/model.py index 0f0d3567..7df67cf4 100644 --- a/cli/model.py +++ b/cli/model.py @@ -115,7 +115,7 @@ class SecurityOp: class DockerComposeOp: '''Docker Compose operation''' - def __int__(self, path: Optional[str] = ""): + def __init__(self, path: Optional[str] = ''): self.cmd_up = "docker-compose up -d" self.cmd_stop = "docker-compose stop" @@ -125,22 +125,22 @@ class DockerComposeOp: try: os.chdir(self.path) except: - print("No found project directory") + print("Not found project directory") sys.exit(0) def up(self): '''docker-compose up''' try: - os.system(cmd_up) + os.system(self.cmd_up) except: print("Create failed") - os.system(cmd_up) + os.system(self.cmd_up) sys.exit(0) def stop(self): '''docker-compose stop''' try: - os.system(cmd_stop) + os.system(self.cmd_stop) except: print("Stop failed, suggest try it again") sys.exit(0) @@ -148,7 +148,7 @@ class DockerComposeOp: def down(self): '''docker-compose down''' try: - os.system(cmd_down) + os.system(self.cmd_down) except: print("Down failed, suggest try it again") sys.exit(0) diff --git a/cli/stackhub.py b/cli/stackhub.py index 67d5e5de..a028d887 100644 --- a/cli/stackhub.py +++ b/cli/stackhub.py @@ -22,16 +22,41 @@ def create(app_name: str, project_name: Optional[str] = None): create.setEnv() create.upRepo() create.printResult() - -@app.command() -def start(app_name: str, project_name: Optional[str] = None): - '''start one application''' - pass @app.command() -def update(name: str): +def up(path: str): + '''up one deleted application''' + status = controller.Status("application", path) + status.startApp() + +@app.command() +def start(project_name: str): + '''start one stopped application''' + status = controller.Status(project_name) + status.startApp() + +@app.command() +def stop(project_name: str): + '''start one running application''' + status = controller.Status(project_name) + status.stopApp() + +@app.command() +def restart(project_name: str): + '''Restart one application''' + status = controller.Status(project_name) + status.retartApp() + +@app.command() +def erase(project_name: str): + '''erase or delete an application''' + status = controller.Status(project_name) + status.eraseApp() + +@app.command() +def update(project_name: str): '''update the local lists cache''' - typer.echo(f"Hello {name}") + typer.echo(f"Hello {project_name}") @app.command()