mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-31 07:04:12 +00:00 
			
		
		
		
	#298 Always clean-up after building container
This commit is contained in:
		| @@ -1,5 +1,4 @@ | ||||
| import os | ||||
| from contextlib import contextmanager | ||||
| import subprocess | ||||
| import shutil | ||||
| from tempfile import mkdtemp | ||||
| @@ -15,12 +14,14 @@ enabled = os.environ.get('FUNCTIONAL') | ||||
|  | ||||
| def build_container(tag, dockerfile): | ||||
|     tmpdir = mkdtemp() | ||||
|     with Path(tmpdir).joinpath('Dockerfile').open('w') as file: | ||||
|         file.write(dockerfile) | ||||
|     if subprocess.call(['docker', 'build', '--tag={}'.format(tag), tmpdir], | ||||
|                        cwd=root) != 0: | ||||
|         raise Exception("Can't build a container") | ||||
|     shutil.rmtree(tmpdir) | ||||
|     try: | ||||
|         with Path(tmpdir).joinpath('Dockerfile').open('w') as file: | ||||
|             file.write(dockerfile) | ||||
|         if subprocess.call(['docker', 'build', '--tag={}'.format(tag), tmpdir], | ||||
|                            cwd=root) != 0: | ||||
|             raise Exception("Can't build a container") | ||||
|     finally: | ||||
|         shutil.rmtree(tmpdir) | ||||
|  | ||||
|  | ||||
| def spawn(request, tag, dockerfile, cmd): | ||||
| @@ -32,6 +33,7 @@ def spawn(request, tag, dockerfile, cmd): | ||||
|         proc = pexpect.spawnu('docker run --volume {}:/src --tty=true ' | ||||
|                               '--interactive=true {} {}'.format(root, tag, cmd)) | ||||
|         proc.sendline('pip install /src') | ||||
|         proc.sendline('cd /') | ||||
|  | ||||
|     proc.logfile = sys.stdout | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user