Add pull image docker function, and clear read/call token
This commit is contained in:
@@ -6,7 +6,6 @@ from pathlib import PurePosixPath
|
|||||||
from docker.errors import DockerException
|
from docker.errors import DockerException
|
||||||
from .issue import ContainerErrorTest
|
from .issue import ContainerErrorTest
|
||||||
from .properties import ContainerObject
|
from .properties import ContainerObject
|
||||||
from .misc import read_token
|
|
||||||
|
|
||||||
|
|
||||||
class VirtualMachine:
|
class VirtualMachine:
|
||||||
@@ -15,9 +14,7 @@ class VirtualMachine:
|
|||||||
|
|
||||||
self.container = container
|
self.container = container
|
||||||
self.base_command = self.container.commands
|
self.base_command = self.container.commands
|
||||||
|
|
||||||
self.clear_containers()
|
self.clear_containers()
|
||||||
self.pull_image()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def start_docker():
|
def start_docker():
|
||||||
@@ -30,17 +27,6 @@ class VirtualMachine:
|
|||||||
print('Docker isn\'t start or installed')
|
print('Docker isn\'t start or installed')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def pull_image(self):
|
|
||||||
"""Pull docker image"""
|
|
||||||
print(f'Pull this image : {self.container.image}')
|
|
||||||
if 'unreal' in self.container.label:
|
|
||||||
unreal_token = read_token('token_unreal.txt')
|
|
||||||
self.client.login(registry='https://ghcr.io', username='stilobique', password=unreal_token)
|
|
||||||
|
|
||||||
print('Start to PULL image')
|
|
||||||
self.client.images.pull(f'{self.container.image}:{self.container.tag}')
|
|
||||||
print('Image is pull')
|
|
||||||
|
|
||||||
def clear_containers(self):
|
def clear_containers(self):
|
||||||
"""Look all docker containers, and remove-it if the task are used with the unit test."""
|
"""Look all docker containers, and remove-it if the task are used with the unit test."""
|
||||||
containers = self.client.containers.list(all=True)
|
containers = self.client.containers.list(all=True)
|
||||||
|
|||||||
@@ -4,16 +4,6 @@ import sys
|
|||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from .issue import ArchiveFolderSourceNotFound
|
from .issue import ArchiveFolderSourceNotFound
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
def read_token(file: str = 'token.txt') -> str:
|
|
||||||
"""From tests folder, return a token string, in a dedicated file"""
|
|
||||||
token_file = Path(os.getcwd(), 'tests', file)
|
|
||||||
with open(token_file, 'r') as f:
|
|
||||||
token = f.read()
|
|
||||||
|
|
||||||
return token
|
|
||||||
|
|
||||||
|
|
||||||
def generate_archive(list_clean: list, name: str):
|
def generate_archive(list_clean: list, name: str):
|
||||||
|
|||||||
Reference in New Issue
Block a user