This commit is contained in:
Olivier 'reivilibre' 2020-12-31 20:52:16 +00:00
parent dd848d0bf9
commit 5c716db2b6
3 changed files with 11 additions and 7 deletions

View File

@ -1,8 +1,10 @@
from scone.default.utensils.docker_utensils import (
ContainerState,
DockerContainerRun,
DockerContainerState,
DockerImagePull,
DockerNetworkCreate,
DockerVolumeCreate, DockerContainerState, ContainerState,
DockerVolumeCreate,
)
from scone.head.kitchen import Kitchen
from scone.head.recipe import Recipe, RecipeContext
@ -26,7 +28,8 @@ class DockerContainer(Recipe):
if current_state == ContainerState.NOTFOUND:
await kitchen.ut1areq(
DockerContainerRun(self.image, self.command, self.name), DockerContainerRun.Result
DockerContainerRun(self.image, self.command, self.name),
DockerContainerRun.Result,
)

View File

@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with Scone. If not, see <https://www.gnu.org/licenses/>.
from scone.default.utensils.basic_utensils import HashFile
from scone.head.kitchen import Kitchen

View File

@ -21,7 +21,9 @@ def _docker_client():
if not docker:
# check docker is actually installed and give a message with the resolution
# when it isn't.
raise RuntimeError("You need to install docker from PyPI to use these utensils!")
raise RuntimeError(
"You need to install docker from PyPI to use these utensils!"
)
global _docker_client_instance
if not _docker_client_instance:
@ -48,11 +50,11 @@ class DockerContainerState(Utensil):
for container in client.containers.list(all=True):
container: Container
if self.name == container.name:
if container.status == 'running':
if container.status == "running":
await channel.send(ContainerState.RUNNING)
elif container.status == 'exited':
elif container.status == "exited":
await channel.send(ContainerState.EXITED)
elif container.status == 'restarting':
elif container.status == "restarting":
await channel.send(ContainerState.RESTARTING)
else:
raise ValueError(f"Unknown container status: {container.status}")