· 6 years ago · Oct 27, 2019, 09:42 PM
1PS C:\Users\Slid3rek\Documents\MWO\iwsoj\iwsoj> pytest -v tests
2================================================= test session starts =================================================
3platform win32 -- Python 3.7.5, pytest-5.2.1, py-1.8.0, pluggy-0.13.0 -- c:\program files\python37\python.exe
4cachedir: .pytest_cache
5Django settings: iwsoj.settings (from ini file)
6rootdir: C:\Users\Slid3rek\Documents\MWO\iwsoj\iwsoj, inifile: pytest.ini
7plugins: cov-2.8.1, django-3.5.1, mock-1.11.1
8collected 27 items
9
10tests/users/test_views.py::test_register_ok PASSED [ 3%]
11tests/users/serializers/test_user_serializer.py::test_serializer_is_valid_for_valid_data PASSED [ 7%]
12tests/users/serializers/test_user_serializer.py::test_serializer_only_unique_users PASSED [ 11%]
13tests/iwsoj/test_views.py::test_home_404 PASSED [ 14%]
14tests/runner/test_runner.py::test_lang_fromfile_ok PASSED [ 18%]
15tests/runner/test_runner.py::test_lang_fromfile_unsupported PASSED [ 22%]
16tests/runner/test_runner.py::test_lang_tostring PASSED [ 25%]
17tests/runner/test_runner.py::test_get_dockerfile_dir FAILED [ 29%]
18tests/runner/test_runner.py::test_runner_c_ok FAILED [ 33%]
19tests/runner/test_runner.py::test_runner_cpp_ok FAILED [ 37%]
20tests/runner/test_runner.py::test_runner_py3_ok FAILED [ 40%]
21tests/runner/test_runner.py::test_runner_java_ok FAILED [ 44%]
22tests/runner/test_runner.py::test_runner_go_ok FAILED [ 48%]
23tests/tasks/test_complexity.py::test_choices PASSED [ 51%]
24tests/tasks/test_complexity.py::test_tostring PASSED [ 55%]
25tests/tasks/test_complexity.py::test_enum_eq PASSED [ 59%]
26tests/tasks/test_models.py::test_create_date PASSED [ 62%]
27tests/tasks/test_models.py::test_emptytask_wont_validate PASSED [ 66%]
28tests/tasks/test_models.py::test_invalid_complexity_wont_validates PASSED [ 70%]
29tests/tasks/judge/test_errors.py::test_incorrect_solution_error PASSED [ 74%]
30tests/tasks/judge/test_judge.py::test_judge_ok_solution PASSED [ 77%]
31tests/tasks/judge/test_judge.py::test_judge_wrong_solution PASSED [ 81%]
32tests/tasks/serializers/test_task_serializer.py::test_serializer_valid_task_definition PASSED [ 85%]
33tests/tasks/serializers/test_task_serializer.py::test_json_has_valid_fields PASSED [ 88%]
34tests/users/test_views.py::test_register_invalid_request PASSED [ 92%]
35tests/users/serializers/test_user_serializer.py::test_create_valid_data PASSED [ 96%]
36tests/users/serializers/test_user_serializer.py::test_create_valid_data_save_called PASSED [100%]
37
38====================================================== FAILURES =======================================================
39_______________________________________________ test_get_dockerfile_dir _______________________________________________
40
41 def test_get_dockerfile_dir():
42> assert get_dockerfile_dir(Lang.C).endswith("iwsoj/runner/imgs/c")
43E AssertionError: assert False
44E + where False = <built-in method endswith of str object at 0x0000020D75272A40>('iwsoj/runner/imgs/c')
45E + where <built-in method endswith of str object at 0x0000020D75272A40> = 'C:\\Users\\Slid3rek\\Documents\\MWO\\iwsoj\\iwsoj\\runner\\imgs\\c'.endswith
46E + where 'C:\\Users\\Slid3rek\\Documents\\MWO\\iwsoj\\iwsoj\\runner\\imgs\\c' = get_dockerfile_dir(<Lang.C: 1>)
47E + where <Lang.C: 1> = Lang.C
48
49tests\runner\test_runner.py:25: AssertionError
50__________________________________________________ test_runner_c_ok ___________________________________________________
51
52codefpath = 'C:\\Users\\Slid3rek\\Documents\\MWO\\iwsoj\\iwsoj\\runner\\dummy\\dummy.c'
53
54 def soSorryYouLose(codefpath: str) -> str:
55 """
56 Executes the
57 :param codefpath: The path to the code to be run
58 :return: stdout of both the compile and the run step of the file in question
59 """
60
61 imagetag = "runner"
62 lang = Lang.from_file(codefpath)
63
64 dockerfile_path = get_dockerfile_dir(lang)
65 dockerc = docker.from_env()
66
67 try:
68 ctx2cwd(dockerfile_path, codefpath)
69 short_codefname = os.path.basename(codefpath)
70> dockerc.images.build(path="os.getcwd()", buildargs={"fpath": short_codefname}, tag=imagetag, rm=True)
71
72runner\runner.py:96:
73_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
74
75self = <docker.models.images.ImageCollection object at 0x0000020D750959C8>
76kwargs = {'buildargs': {'fpath': 'dummy.c'}, 'path': 'os.getcwd()', 'rm': True, 'tag': 'runner'}
77
78 def build(self, **kwargs):
79 """
80 Build an image and return it. Similar to the ``docker build``
81 command. Either ``path`` or ``fileobj`` must be set.
82
83 If you have a tar file for the Docker build context (including a
84 Dockerfile) already, pass a readable file-like object to ``fileobj``
85 and also pass ``custom_context=True``. If the stream is compressed
86 also, set ``encoding`` to the correct value (e.g ``gzip``).
87
88 If you want to get the raw output of the build, use the
89 :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
90 low-level API.
91
92 Args:
93 path (str): Path to the directory containing the Dockerfile
94 fileobj: A file object to use as the Dockerfile. (Or a file-like
95 object)
96 tag (str): A tag to add to the final image
97 quiet (bool): Whether to return the status
98 nocache (bool): Don't use the cache when set to ``True``
99 rm (bool): Remove intermediate containers. The ``docker build``
100 command now defaults to ``--rm=true``, but we have kept the old
101 default of `False` to preserve backward compatibility
102 timeout (int): HTTP timeout
103 custom_context (bool): Optional if using ``fileobj``
104 encoding (str): The encoding for a stream. Set to ``gzip`` for
105 compressing
106 pull (bool): Downloads any updates to the FROM image in Dockerfiles
107 forcerm (bool): Always remove intermediate containers, even after
108 unsuccessful builds
109 dockerfile (str): path within the build context to the Dockerfile
110 buildargs (dict): A dictionary of build arguments
111 container_limits (dict): A dictionary of limits applied to each
112 container created by the build process. Valid keys:
113
114 - memory (int): set memory limit for build
115 - memswap (int): Total memory (memory + swap), -1 to disable
116 swap
117 - cpushares (int): CPU shares (relative weight)
118 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
119 ``"0-3"``, ``"0,1"``
120 shmsize (int): Size of `/dev/shm` in bytes. The size must be
121 greater than 0. If omitted the system uses 64MB
122 labels (dict): A dictionary of labels to set on the image
123 cache_from (list): A list of images used for build cache
124 resolution
125 target (str): Name of the build-stage to build in a multi-stage
126 Dockerfile
127 network_mode (str): networking mode for the run commands during
128 build
129 squash (bool): Squash the resulting images layers into a
130 single layer.
131 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
132 containers, as a mapping of hostname to IP address.
133 platform (str): Platform in the format ``os[/arch[/variant]]``.
134 isolation (str): Isolation technology used during build.
135 Default: `None`.
136 use_config_proxy (bool): If ``True``, and if the docker client
137 configuration file (``~/.docker/config.json`` by default)
138 contains a proxy configuration, the corresponding environment
139 variables will be set in the container being built.
140
141 Returns:
142 (tuple): The first item is the :py:class:`Image` object for the
143 image that was build. The second item is a generator of the
144 build logs as JSON-decoded objects.
145
146 Raises:
147 :py:class:`docker.errors.BuildError`
148 If there is an error during the build.
149 :py:class:`docker.errors.APIError`
150 If the server returns any other error.
151 ``TypeError``
152 If neither ``path`` nor ``fileobj`` is specified.
153 """
154> resp = self.client.api.build(**kwargs)
155
156c:\program files\python37\lib\site-packages\docker\models\images.py:279:
157_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
158
159self = <docker.api.client.APIClient object at 0x0000020D751F0288>, path = 'os.getcwd()', tag = 'runner', quiet = False
160fileobj = None, nocache = False, rm = True, timeout = None, custom_context = False, encoding = None, pull = False
161forcerm = False, dockerfile = None, container_limits = {}, decode = False, buildargs = {'fpath': 'dummy.c'}
162gzip = False, shmsize = None, labels = None, cache_from = None, target = None, network_mode = None, squash = None
163extra_hosts = None, platform = None, isolation = None, use_config_proxy = True
164
165 def build(self, path=None, tag=None, quiet=False, fileobj=None,
166 nocache=False, rm=False, timeout=None,
167 custom_context=False, encoding=None, pull=False,
168 forcerm=False, dockerfile=None, container_limits=None,
169 decode=False, buildargs=None, gzip=False, shmsize=None,
170 labels=None, cache_from=None, target=None, network_mode=None,
171 squash=None, extra_hosts=None, platform=None, isolation=None,
172 use_config_proxy=True):
173 """
174 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
175 needs to be set. ``path`` can be a local path (to a directory
176 containing a Dockerfile) or a remote URL. ``fileobj`` must be a
177 readable file-like object to a Dockerfile.
178
179 If you have a tar file for the Docker build context (including a
180 Dockerfile) already, pass a readable file-like object to ``fileobj``
181 and also pass ``custom_context=True``. If the stream is compressed
182 also, set ``encoding`` to the correct value (e.g ``gzip``).
183
184 Example:
185 >>> from io import BytesIO
186 >>> from docker import APIClient
187 >>> dockerfile = '''
188 ... # Shared Volume
189 ... FROM busybox:buildroot-2014.02
190 ... VOLUME /data
191 ... CMD ["/bin/sh"]
192 ... '''
193 >>> f = BytesIO(dockerfile.encode('utf-8'))
194 >>> cli = APIClient(base_url='tcp://127.0.0.1:2375')
195 >>> response = [line for line in cli.build(
196 ... fileobj=f, rm=True, tag='yourname/volume'
197 ... )]
198 >>> response
199 ['{"stream":" ---\\u003e a9eb17255234\\n"}',
200 '{"stream":"Step 1 : VOLUME /data\\n"}',
201 '{"stream":" ---\\u003e Running in abdc1e6896c6\\n"}',
202 '{"stream":" ---\\u003e 713bca62012e\\n"}',
203 '{"stream":"Removing intermediate container abdc1e6896c6\\n"}',
204 '{"stream":"Step 2 : CMD [\\"/bin/sh\\"]\\n"}',
205 '{"stream":" ---\\u003e Running in dba30f2a1a7e\\n"}',
206 '{"stream":" ---\\u003e 032b8b2855fc\\n"}',
207 '{"stream":"Removing intermediate container dba30f2a1a7e\\n"}',
208 '{"stream":"Successfully built 032b8b2855fc\\n"}']
209
210 Args:
211 path (str): Path to the directory containing the Dockerfile
212 fileobj: A file object to use as the Dockerfile. (Or a file-like
213 object)
214 tag (str): A tag to add to the final image
215 quiet (bool): Whether to return the status
216 nocache (bool): Don't use the cache when set to ``True``
217 rm (bool): Remove intermediate containers. The ``docker build``
218 command now defaults to ``--rm=true``, but we have kept the old
219 default of `False` to preserve backward compatibility
220 timeout (int): HTTP timeout
221 custom_context (bool): Optional if using ``fileobj``
222 encoding (str): The encoding for a stream. Set to ``gzip`` for
223 compressing
224 pull (bool): Downloads any updates to the FROM image in Dockerfiles
225 forcerm (bool): Always remove intermediate containers, even after
226 unsuccessful builds
227 dockerfile (str): path within the build context to the Dockerfile
228 buildargs (dict): A dictionary of build arguments
229 container_limits (dict): A dictionary of limits applied to each
230 container created by the build process. Valid keys:
231
232 - memory (int): set memory limit for build
233 - memswap (int): Total memory (memory + swap), -1 to disable
234 swap
235 - cpushares (int): CPU shares (relative weight)
236 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
237 ``"0-3"``, ``"0,1"``
238 decode (bool): If set to ``True``, the returned stream will be
239 decoded into dicts on the fly. Default ``False``
240 shmsize (int): Size of `/dev/shm` in bytes. The size must be
241 greater than 0. If omitted the system uses 64MB
242 labels (dict): A dictionary of labels to set on the image
243 cache_from (:py:class:`list`): A list of images used for build
244 cache resolution
245 target (str): Name of the build-stage to build in a multi-stage
246 Dockerfile
247 network_mode (str): networking mode for the run commands during
248 build
249 squash (bool): Squash the resulting images layers into a
250 single layer.
251 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
252 containers, as a mapping of hostname to IP address.
253 platform (str): Platform in the format ``os[/arch[/variant]]``
254 isolation (str): Isolation technology used during build.
255 Default: `None`.
256 use_config_proxy (bool): If ``True``, and if the docker client
257 configuration file (``~/.docker/config.json`` by default)
258 contains a proxy configuration, the corresponding environment
259 variables will be set in the container being built.
260
261 Returns:
262 A generator for the build output.
263
264 Raises:
265 :py:class:`docker.errors.APIError`
266 If the server returns an error.
267 ``TypeError``
268 If neither ``path`` nor ``fileobj`` is specified.
269 """
270 remote = context = None
271 headers = {}
272 container_limits = container_limits or {}
273 buildargs = buildargs or {}
274 if path is None and fileobj is None:
275 raise TypeError("Either path or fileobj needs to be provided.")
276 if gzip and encoding is not None:
277 raise errors.DockerException(
278 'Can not use custom encoding if gzip is enabled'
279 )
280
281 for key in container_limits.keys():
282 if key not in constants.CONTAINER_LIMITS_KEYS:
283 raise errors.DockerException(
284 'Invalid container_limits key {0}'.format(key)
285 )
286
287 if custom_context:
288 if not fileobj:
289 raise TypeError("You must specify fileobj with custom_context")
290 context = fileobj
291 elif fileobj is not None:
292 context = utils.mkbuildcontext(fileobj)
293 elif path.startswith(('http://', 'https://',
294 'git://', 'github.com/', 'git@')):
295 remote = path
296 elif not os.path.isdir(path):
297> raise TypeError("You must specify a directory to build in path")
298E TypeError: You must specify a directory to build in path
299
300c:\program files\python37\lib\site-packages\docker\api\build.py:148: TypeError
301
302During handling of the above exception, another exception occurred:
303
304self = <docker.api.client.APIClient object at 0x0000020D751F0288>, response = <Response [404]>
305
306 def _raise_for_status(self, response):
307 """Raises stored :class:`APIError`, if one occurred."""
308 try:
309> response.raise_for_status()
310
311c:\program files\python37\lib\site-packages\docker\api\client.py:261:
312_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
313
314self = <Response [404]>
315
316 def raise_for_status(self):
317 """Raises stored :class:`HTTPError`, if one occurred."""
318
319 http_error_msg = ''
320 if isinstance(self.reason, bytes):
321 # We attempt to decode utf-8 first because some servers
322 # choose to localize their reason strings. If the string
323 # isn't utf-8, we fall back to iso-8859-1 for all other
324 # encodings. (See PR #3538)
325 try:
326 reason = self.reason.decode('utf-8')
327 except UnicodeDecodeError:
328 reason = self.reason.decode('iso-8859-1')
329 else:
330 reason = self.reason
331
332 if 400 <= self.status_code < 500:
333 http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
334
335 elif 500 <= self.status_code < 600:
336 http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
337
338 if http_error_msg:
339> raise HTTPError(http_error_msg, response=self)
340E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False
341
342c:\program files\python37\lib\site-packages\requests\models.py:940: HTTPError
343
344During handling of the above exception, another exception occurred:
345
346 @pytest.mark.integration
347 def test_runner_c_ok():
348> assert soSorryYouLose(str(dummypath / 'dummy.c')) == "It takes 8 bits to represent 222\n"
349
350tests\runner\test_runner.py:33:
351_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
352runner\runner.py:102: in soSorryYouLose
353 dockerc.images.remove(imagetag)
354c:\program files\python37\lib\site-packages\docker\models\images.py:463: in remove
355 self.client.api.remove_image(*args, **kwargs)
356c:\program files\python37\lib\site-packages\docker\utils\decorators.py:19: in wrapped
357 return f(self, resource_id, *args, **kwargs)
358c:\program files\python37\lib\site-packages\docker\api\image.py:495: in remove_image
359 return self._result(res, True)
360c:\program files\python37\lib\site-packages\docker\api\client.py:267: in _result
361 self._raise_for_status(response)
362c:\program files\python37\lib\site-packages\docker\api\client.py:263: in _raise_for_status
363 raise create_api_error_from_http_exception(e)
364_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
365
366e = HTTPError('404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False')
367
368 def create_api_error_from_http_exception(e):
369 """
370 Create a suitable APIError from requests.exceptions.HTTPError.
371 """
372 response = e.response
373 try:
374 explanation = response.json()['message']
375 except ValueError:
376 explanation = (response.content or '').strip()
377 cls = APIError
378 if response.status_code == 404:
379 if explanation and ('No such image' in str(explanation) or
380 'not found: does not exist or no pull access'
381 in str(explanation) or
382 'repository does not exist' in str(explanation)):
383 cls = ImageNotFound
384 else:
385 cls = NotFound
386> raise cls(e, response=response, explanation=explanation)
387E docker.errors.ImageNotFound: 404 Client Error: Not Found ("No such image: runner:latest")
388
389c:\program files\python37\lib\site-packages\docker\errors.py:31: ImageNotFound
390_________________________________________________ test_runner_cpp_ok __________________________________________________
391
392codefpath = 'C:\\Users\\Slid3rek\\Documents\\MWO\\iwsoj\\iwsoj\\runner\\dummy\\dummy.cpp'
393
394 def soSorryYouLose(codefpath: str) -> str:
395 """
396 Executes the
397 :param codefpath: The path to the code to be run
398 :return: stdout of both the compile and the run step of the file in question
399 """
400
401 imagetag = "runner"
402 lang = Lang.from_file(codefpath)
403
404 dockerfile_path = get_dockerfile_dir(lang)
405 dockerc = docker.from_env()
406
407 try:
408 ctx2cwd(dockerfile_path, codefpath)
409 short_codefname = os.path.basename(codefpath)
410> dockerc.images.build(path="os.getcwd()", buildargs={"fpath": short_codefname}, tag=imagetag, rm=True)
411
412runner\runner.py:96:
413_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
414
415self = <docker.models.images.ImageCollection object at 0x0000020D75747648>
416kwargs = {'buildargs': {'fpath': 'dummy.cpp'}, 'path': 'os.getcwd()', 'rm': True, 'tag': 'runner'}
417
418 def build(self, **kwargs):
419 """
420 Build an image and return it. Similar to the ``docker build``
421 command. Either ``path`` or ``fileobj`` must be set.
422
423 If you have a tar file for the Docker build context (including a
424 Dockerfile) already, pass a readable file-like object to ``fileobj``
425 and also pass ``custom_context=True``. If the stream is compressed
426 also, set ``encoding`` to the correct value (e.g ``gzip``).
427
428 If you want to get the raw output of the build, use the
429 :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
430 low-level API.
431
432 Args:
433 path (str): Path to the directory containing the Dockerfile
434 fileobj: A file object to use as the Dockerfile. (Or a file-like
435 object)
436 tag (str): A tag to add to the final image
437 quiet (bool): Whether to return the status
438 nocache (bool): Don't use the cache when set to ``True``
439 rm (bool): Remove intermediate containers. The ``docker build``
440 command now defaults to ``--rm=true``, but we have kept the old
441 default of `False` to preserve backward compatibility
442 timeout (int): HTTP timeout
443 custom_context (bool): Optional if using ``fileobj``
444 encoding (str): The encoding for a stream. Set to ``gzip`` for
445 compressing
446 pull (bool): Downloads any updates to the FROM image in Dockerfiles
447 forcerm (bool): Always remove intermediate containers, even after
448 unsuccessful builds
449 dockerfile (str): path within the build context to the Dockerfile
450 buildargs (dict): A dictionary of build arguments
451 container_limits (dict): A dictionary of limits applied to each
452 container created by the build process. Valid keys:
453
454 - memory (int): set memory limit for build
455 - memswap (int): Total memory (memory + swap), -1 to disable
456 swap
457 - cpushares (int): CPU shares (relative weight)
458 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
459 ``"0-3"``, ``"0,1"``
460 shmsize (int): Size of `/dev/shm` in bytes. The size must be
461 greater than 0. If omitted the system uses 64MB
462 labels (dict): A dictionary of labels to set on the image
463 cache_from (list): A list of images used for build cache
464 resolution
465 target (str): Name of the build-stage to build in a multi-stage
466 Dockerfile
467 network_mode (str): networking mode for the run commands during
468 build
469 squash (bool): Squash the resulting images layers into a
470 single layer.
471 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
472 containers, as a mapping of hostname to IP address.
473 platform (str): Platform in the format ``os[/arch[/variant]]``.
474 isolation (str): Isolation technology used during build.
475 Default: `None`.
476 use_config_proxy (bool): If ``True``, and if the docker client
477 configuration file (``~/.docker/config.json`` by default)
478 contains a proxy configuration, the corresponding environment
479 variables will be set in the container being built.
480
481 Returns:
482 (tuple): The first item is the :py:class:`Image` object for the
483 image that was build. The second item is a generator of the
484 build logs as JSON-decoded objects.
485
486 Raises:
487 :py:class:`docker.errors.BuildError`
488 If there is an error during the build.
489 :py:class:`docker.errors.APIError`
490 If the server returns any other error.
491 ``TypeError``
492 If neither ``path`` nor ``fileobj`` is specified.
493 """
494> resp = self.client.api.build(**kwargs)
495
496c:\program files\python37\lib\site-packages\docker\models\images.py:279:
497_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
498
499self = <docker.api.client.APIClient object at 0x0000020D757477C8>, path = 'os.getcwd()', tag = 'runner', quiet = False
500fileobj = None, nocache = False, rm = True, timeout = None, custom_context = False, encoding = None, pull = False
501forcerm = False, dockerfile = None, container_limits = {}, decode = False, buildargs = {'fpath': 'dummy.cpp'}
502gzip = False, shmsize = None, labels = None, cache_from = None, target = None, network_mode = None, squash = None
503extra_hosts = None, platform = None, isolation = None, use_config_proxy = True
504
505 def build(self, path=None, tag=None, quiet=False, fileobj=None,
506 nocache=False, rm=False, timeout=None,
507 custom_context=False, encoding=None, pull=False,
508 forcerm=False, dockerfile=None, container_limits=None,
509 decode=False, buildargs=None, gzip=False, shmsize=None,
510 labels=None, cache_from=None, target=None, network_mode=None,
511 squash=None, extra_hosts=None, platform=None, isolation=None,
512 use_config_proxy=True):
513 """
514 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
515 needs to be set. ``path`` can be a local path (to a directory
516 containing a Dockerfile) or a remote URL. ``fileobj`` must be a
517 readable file-like object to a Dockerfile.
518
519 If you have a tar file for the Docker build context (including a
520 Dockerfile) already, pass a readable file-like object to ``fileobj``
521 and also pass ``custom_context=True``. If the stream is compressed
522 also, set ``encoding`` to the correct value (e.g ``gzip``).
523
524 Example:
525 >>> from io import BytesIO
526 >>> from docker import APIClient
527 >>> dockerfile = '''
528 ... # Shared Volume
529 ... FROM busybox:buildroot-2014.02
530 ... VOLUME /data
531 ... CMD ["/bin/sh"]
532 ... '''
533 >>> f = BytesIO(dockerfile.encode('utf-8'))
534 >>> cli = APIClient(base_url='tcp://127.0.0.1:2375')
535 >>> response = [line for line in cli.build(
536 ... fileobj=f, rm=True, tag='yourname/volume'
537 ... )]
538 >>> response
539 ['{"stream":" ---\\u003e a9eb17255234\\n"}',
540 '{"stream":"Step 1 : VOLUME /data\\n"}',
541 '{"stream":" ---\\u003e Running in abdc1e6896c6\\n"}',
542 '{"stream":" ---\\u003e 713bca62012e\\n"}',
543 '{"stream":"Removing intermediate container abdc1e6896c6\\n"}',
544 '{"stream":"Step 2 : CMD [\\"/bin/sh\\"]\\n"}',
545 '{"stream":" ---\\u003e Running in dba30f2a1a7e\\n"}',
546 '{"stream":" ---\\u003e 032b8b2855fc\\n"}',
547 '{"stream":"Removing intermediate container dba30f2a1a7e\\n"}',
548 '{"stream":"Successfully built 032b8b2855fc\\n"}']
549
550 Args:
551 path (str): Path to the directory containing the Dockerfile
552 fileobj: A file object to use as the Dockerfile. (Or a file-like
553 object)
554 tag (str): A tag to add to the final image
555 quiet (bool): Whether to return the status
556 nocache (bool): Don't use the cache when set to ``True``
557 rm (bool): Remove intermediate containers. The ``docker build``
558 command now defaults to ``--rm=true``, but we have kept the old
559 default of `False` to preserve backward compatibility
560 timeout (int): HTTP timeout
561 custom_context (bool): Optional if using ``fileobj``
562 encoding (str): The encoding for a stream. Set to ``gzip`` for
563 compressing
564 pull (bool): Downloads any updates to the FROM image in Dockerfiles
565 forcerm (bool): Always remove intermediate containers, even after
566 unsuccessful builds
567 dockerfile (str): path within the build context to the Dockerfile
568 buildargs (dict): A dictionary of build arguments
569 container_limits (dict): A dictionary of limits applied to each
570 container created by the build process. Valid keys:
571
572 - memory (int): set memory limit for build
573 - memswap (int): Total memory (memory + swap), -1 to disable
574 swap
575 - cpushares (int): CPU shares (relative weight)
576 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
577 ``"0-3"``, ``"0,1"``
578 decode (bool): If set to ``True``, the returned stream will be
579 decoded into dicts on the fly. Default ``False``
580 shmsize (int): Size of `/dev/shm` in bytes. The size must be
581 greater than 0. If omitted the system uses 64MB
582 labels (dict): A dictionary of labels to set on the image
583 cache_from (:py:class:`list`): A list of images used for build
584 cache resolution
585 target (str): Name of the build-stage to build in a multi-stage
586 Dockerfile
587 network_mode (str): networking mode for the run commands during
588 build
589 squash (bool): Squash the resulting images layers into a
590 single layer.
591 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
592 containers, as a mapping of hostname to IP address.
593 platform (str): Platform in the format ``os[/arch[/variant]]``
594 isolation (str): Isolation technology used during build.
595 Default: `None`.
596 use_config_proxy (bool): If ``True``, and if the docker client
597 configuration file (``~/.docker/config.json`` by default)
598 contains a proxy configuration, the corresponding environment
599 variables will be set in the container being built.
600
601 Returns:
602 A generator for the build output.
603
604 Raises:
605 :py:class:`docker.errors.APIError`
606 If the server returns an error.
607 ``TypeError``
608 If neither ``path`` nor ``fileobj`` is specified.
609 """
610 remote = context = None
611 headers = {}
612 container_limits = container_limits or {}
613 buildargs = buildargs or {}
614 if path is None and fileobj is None:
615 raise TypeError("Either path or fileobj needs to be provided.")
616 if gzip and encoding is not None:
617 raise errors.DockerException(
618 'Can not use custom encoding if gzip is enabled'
619 )
620
621 for key in container_limits.keys():
622 if key not in constants.CONTAINER_LIMITS_KEYS:
623 raise errors.DockerException(
624 'Invalid container_limits key {0}'.format(key)
625 )
626
627 if custom_context:
628 if not fileobj:
629 raise TypeError("You must specify fileobj with custom_context")
630 context = fileobj
631 elif fileobj is not None:
632 context = utils.mkbuildcontext(fileobj)
633 elif path.startswith(('http://', 'https://',
634 'git://', 'github.com/', 'git@')):
635 remote = path
636 elif not os.path.isdir(path):
637> raise TypeError("You must specify a directory to build in path")
638E TypeError: You must specify a directory to build in path
639
640c:\program files\python37\lib\site-packages\docker\api\build.py:148: TypeError
641
642During handling of the above exception, another exception occurred:
643
644self = <docker.api.client.APIClient object at 0x0000020D757477C8>, response = <Response [404]>
645
646 def _raise_for_status(self, response):
647 """Raises stored :class:`APIError`, if one occurred."""
648 try:
649> response.raise_for_status()
650
651c:\program files\python37\lib\site-packages\docker\api\client.py:261:
652_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
653
654self = <Response [404]>
655
656 def raise_for_status(self):
657 """Raises stored :class:`HTTPError`, if one occurred."""
658
659 http_error_msg = ''
660 if isinstance(self.reason, bytes):
661 # We attempt to decode utf-8 first because some servers
662 # choose to localize their reason strings. If the string
663 # isn't utf-8, we fall back to iso-8859-1 for all other
664 # encodings. (See PR #3538)
665 try:
666 reason = self.reason.decode('utf-8')
667 except UnicodeDecodeError:
668 reason = self.reason.decode('iso-8859-1')
669 else:
670 reason = self.reason
671
672 if 400 <= self.status_code < 500:
673 http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
674
675 elif 500 <= self.status_code < 600:
676 http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
677
678 if http_error_msg:
679> raise HTTPError(http_error_msg, response=self)
680E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False
681
682c:\program files\python37\lib\site-packages\requests\models.py:940: HTTPError
683
684During handling of the above exception, another exception occurred:
685
686 @pytest.mark.integration
687 def test_runner_cpp_ok():
688> assert soSorryYouLose(str(dummypath / 'dummy.cpp')) == "Distance from p1 and p2 is 0\n"
689
690tests\runner\test_runner.py:38:
691_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
692runner\runner.py:102: in soSorryYouLose
693 dockerc.images.remove(imagetag)
694c:\program files\python37\lib\site-packages\docker\models\images.py:463: in remove
695 self.client.api.remove_image(*args, **kwargs)
696c:\program files\python37\lib\site-packages\docker\utils\decorators.py:19: in wrapped
697 return f(self, resource_id, *args, **kwargs)
698c:\program files\python37\lib\site-packages\docker\api\image.py:495: in remove_image
699 return self._result(res, True)
700c:\program files\python37\lib\site-packages\docker\api\client.py:267: in _result
701 self._raise_for_status(response)
702c:\program files\python37\lib\site-packages\docker\api\client.py:263: in _raise_for_status
703 raise create_api_error_from_http_exception(e)
704_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
705
706e = HTTPError('404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False')
707
708 def create_api_error_from_http_exception(e):
709 """
710 Create a suitable APIError from requests.exceptions.HTTPError.
711 """
712 response = e.response
713 try:
714 explanation = response.json()['message']
715 except ValueError:
716 explanation = (response.content or '').strip()
717 cls = APIError
718 if response.status_code == 404:
719 if explanation and ('No such image' in str(explanation) or
720 'not found: does not exist or no pull access'
721 in str(explanation) or
722 'repository does not exist' in str(explanation)):
723 cls = ImageNotFound
724 else:
725 cls = NotFound
726> raise cls(e, response=response, explanation=explanation)
727E docker.errors.ImageNotFound: 404 Client Error: Not Found ("No such image: runner:latest")
728
729c:\program files\python37\lib\site-packages\docker\errors.py:31: ImageNotFound
730_________________________________________________ test_runner_py3_ok __________________________________________________
731
732codefpath = 'C:\\Users\\Slid3rek\\Documents\\MWO\\iwsoj\\iwsoj\\runner\\dummy\\dummy.py'
733
734 def soSorryYouLose(codefpath: str) -> str:
735 """
736 Executes the
737 :param codefpath: The path to the code to be run
738 :return: stdout of both the compile and the run step of the file in question
739 """
740
741 imagetag = "runner"
742 lang = Lang.from_file(codefpath)
743
744 dockerfile_path = get_dockerfile_dir(lang)
745 dockerc = docker.from_env()
746
747 try:
748 ctx2cwd(dockerfile_path, codefpath)
749 short_codefname = os.path.basename(codefpath)
750> dockerc.images.build(path="os.getcwd()", buildargs={"fpath": short_codefname}, tag=imagetag, rm=True)
751
752runner\runner.py:96:
753_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
754
755self = <docker.models.images.ImageCollection object at 0x0000020D75928908>
756kwargs = {'buildargs': {'fpath': 'dummy.py'}, 'path': 'os.getcwd()', 'rm': True, 'tag': 'runner'}
757
758 def build(self, **kwargs):
759 """
760 Build an image and return it. Similar to the ``docker build``
761 command. Either ``path`` or ``fileobj`` must be set.
762
763 If you have a tar file for the Docker build context (including a
764 Dockerfile) already, pass a readable file-like object to ``fileobj``
765 and also pass ``custom_context=True``. If the stream is compressed
766 also, set ``encoding`` to the correct value (e.g ``gzip``).
767
768 If you want to get the raw output of the build, use the
769 :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
770 low-level API.
771
772 Args:
773 path (str): Path to the directory containing the Dockerfile
774 fileobj: A file object to use as the Dockerfile. (Or a file-like
775 object)
776 tag (str): A tag to add to the final image
777 quiet (bool): Whether to return the status
778 nocache (bool): Don't use the cache when set to ``True``
779 rm (bool): Remove intermediate containers. The ``docker build``
780 command now defaults to ``--rm=true``, but we have kept the old
781 default of `False` to preserve backward compatibility
782 timeout (int): HTTP timeout
783 custom_context (bool): Optional if using ``fileobj``
784 encoding (str): The encoding for a stream. Set to ``gzip`` for
785 compressing
786 pull (bool): Downloads any updates to the FROM image in Dockerfiles
787 forcerm (bool): Always remove intermediate containers, even after
788 unsuccessful builds
789 dockerfile (str): path within the build context to the Dockerfile
790 buildargs (dict): A dictionary of build arguments
791 container_limits (dict): A dictionary of limits applied to each
792 container created by the build process. Valid keys:
793
794 - memory (int): set memory limit for build
795 - memswap (int): Total memory (memory + swap), -1 to disable
796 swap
797 - cpushares (int): CPU shares (relative weight)
798 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
799 ``"0-3"``, ``"0,1"``
800 shmsize (int): Size of `/dev/shm` in bytes. The size must be
801 greater than 0. If omitted the system uses 64MB
802 labels (dict): A dictionary of labels to set on the image
803 cache_from (list): A list of images used for build cache
804 resolution
805 target (str): Name of the build-stage to build in a multi-stage
806 Dockerfile
807 network_mode (str): networking mode for the run commands during
808 build
809 squash (bool): Squash the resulting images layers into a
810 single layer.
811 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
812 containers, as a mapping of hostname to IP address.
813 platform (str): Platform in the format ``os[/arch[/variant]]``.
814 isolation (str): Isolation technology used during build.
815 Default: `None`.
816 use_config_proxy (bool): If ``True``, and if the docker client
817 configuration file (``~/.docker/config.json`` by default)
818 contains a proxy configuration, the corresponding environment
819 variables will be set in the container being built.
820
821 Returns:
822 (tuple): The first item is the :py:class:`Image` object for the
823 image that was build. The second item is a generator of the
824 build logs as JSON-decoded objects.
825
826 Raises:
827 :py:class:`docker.errors.BuildError`
828 If there is an error during the build.
829 :py:class:`docker.errors.APIError`
830 If the server returns any other error.
831 ``TypeError``
832 If neither ``path`` nor ``fileobj`` is specified.
833 """
834> resp = self.client.api.build(**kwargs)
835
836c:\program files\python37\lib\site-packages\docker\models\images.py:279:
837_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
838
839self = <docker.api.client.APIClient object at 0x0000020D75928708>, path = 'os.getcwd()', tag = 'runner', quiet = False
840fileobj = None, nocache = False, rm = True, timeout = None, custom_context = False, encoding = None, pull = False
841forcerm = False, dockerfile = None, container_limits = {}, decode = False, buildargs = {'fpath': 'dummy.py'}
842gzip = False, shmsize = None, labels = None, cache_from = None, target = None, network_mode = None, squash = None
843extra_hosts = None, platform = None, isolation = None, use_config_proxy = True
844
845 def build(self, path=None, tag=None, quiet=False, fileobj=None,
846 nocache=False, rm=False, timeout=None,
847 custom_context=False, encoding=None, pull=False,
848 forcerm=False, dockerfile=None, container_limits=None,
849 decode=False, buildargs=None, gzip=False, shmsize=None,
850 labels=None, cache_from=None, target=None, network_mode=None,
851 squash=None, extra_hosts=None, platform=None, isolation=None,
852 use_config_proxy=True):
853 """
854 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
855 needs to be set. ``path`` can be a local path (to a directory
856 containing a Dockerfile) or a remote URL. ``fileobj`` must be a
857 readable file-like object to a Dockerfile.
858
859 If you have a tar file for the Docker build context (including a
860 Dockerfile) already, pass a readable file-like object to ``fileobj``
861 and also pass ``custom_context=True``. If the stream is compressed
862 also, set ``encoding`` to the correct value (e.g ``gzip``).
863
864 Example:
865 >>> from io import BytesIO
866 >>> from docker import APIClient
867 >>> dockerfile = '''
868 ... # Shared Volume
869 ... FROM busybox:buildroot-2014.02
870 ... VOLUME /data
871 ... CMD ["/bin/sh"]
872 ... '''
873 >>> f = BytesIO(dockerfile.encode('utf-8'))
874 >>> cli = APIClient(base_url='tcp://127.0.0.1:2375')
875 >>> response = [line for line in cli.build(
876 ... fileobj=f, rm=True, tag='yourname/volume'
877 ... )]
878 >>> response
879 ['{"stream":" ---\\u003e a9eb17255234\\n"}',
880 '{"stream":"Step 1 : VOLUME /data\\n"}',
881 '{"stream":" ---\\u003e Running in abdc1e6896c6\\n"}',
882 '{"stream":" ---\\u003e 713bca62012e\\n"}',
883 '{"stream":"Removing intermediate container abdc1e6896c6\\n"}',
884 '{"stream":"Step 2 : CMD [\\"/bin/sh\\"]\\n"}',
885 '{"stream":" ---\\u003e Running in dba30f2a1a7e\\n"}',
886 '{"stream":" ---\\u003e 032b8b2855fc\\n"}',
887 '{"stream":"Removing intermediate container dba30f2a1a7e\\n"}',
888 '{"stream":"Successfully built 032b8b2855fc\\n"}']
889
890 Args:
891 path (str): Path to the directory containing the Dockerfile
892 fileobj: A file object to use as the Dockerfile. (Or a file-like
893 object)
894 tag (str): A tag to add to the final image
895 quiet (bool): Whether to return the status
896 nocache (bool): Don't use the cache when set to ``True``
897 rm (bool): Remove intermediate containers. The ``docker build``
898 command now defaults to ``--rm=true``, but we have kept the old
899 default of `False` to preserve backward compatibility
900 timeout (int): HTTP timeout
901 custom_context (bool): Optional if using ``fileobj``
902 encoding (str): The encoding for a stream. Set to ``gzip`` for
903 compressing
904 pull (bool): Downloads any updates to the FROM image in Dockerfiles
905 forcerm (bool): Always remove intermediate containers, even after
906 unsuccessful builds
907 dockerfile (str): path within the build context to the Dockerfile
908 buildargs (dict): A dictionary of build arguments
909 container_limits (dict): A dictionary of limits applied to each
910 container created by the build process. Valid keys:
911
912 - memory (int): set memory limit for build
913 - memswap (int): Total memory (memory + swap), -1 to disable
914 swap
915 - cpushares (int): CPU shares (relative weight)
916 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
917 ``"0-3"``, ``"0,1"``
918 decode (bool): If set to ``True``, the returned stream will be
919 decoded into dicts on the fly. Default ``False``
920 shmsize (int): Size of `/dev/shm` in bytes. The size must be
921 greater than 0. If omitted the system uses 64MB
922 labels (dict): A dictionary of labels to set on the image
923 cache_from (:py:class:`list`): A list of images used for build
924 cache resolution
925 target (str): Name of the build-stage to build in a multi-stage
926 Dockerfile
927 network_mode (str): networking mode for the run commands during
928 build
929 squash (bool): Squash the resulting images layers into a
930 single layer.
931 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
932 containers, as a mapping of hostname to IP address.
933 platform (str): Platform in the format ``os[/arch[/variant]]``
934 isolation (str): Isolation technology used during build.
935 Default: `None`.
936 use_config_proxy (bool): If ``True``, and if the docker client
937 configuration file (``~/.docker/config.json`` by default)
938 contains a proxy configuration, the corresponding environment
939 variables will be set in the container being built.
940
941 Returns:
942 A generator for the build output.
943
944 Raises:
945 :py:class:`docker.errors.APIError`
946 If the server returns an error.
947 ``TypeError``
948 If neither ``path`` nor ``fileobj`` is specified.
949 """
950 remote = context = None
951 headers = {}
952 container_limits = container_limits or {}
953 buildargs = buildargs or {}
954 if path is None and fileobj is None:
955 raise TypeError("Either path or fileobj needs to be provided.")
956 if gzip and encoding is not None:
957 raise errors.DockerException(
958 'Can not use custom encoding if gzip is enabled'
959 )
960
961 for key in container_limits.keys():
962 if key not in constants.CONTAINER_LIMITS_KEYS:
963 raise errors.DockerException(
964 'Invalid container_limits key {0}'.format(key)
965 )
966
967 if custom_context:
968 if not fileobj:
969 raise TypeError("You must specify fileobj with custom_context")
970 context = fileobj
971 elif fileobj is not None:
972 context = utils.mkbuildcontext(fileobj)
973 elif path.startswith(('http://', 'https://',
974 'git://', 'github.com/', 'git@')):
975 remote = path
976 elif not os.path.isdir(path):
977> raise TypeError("You must specify a directory to build in path")
978E TypeError: You must specify a directory to build in path
979
980c:\program files\python37\lib\site-packages\docker\api\build.py:148: TypeError
981
982During handling of the above exception, another exception occurred:
983
984self = <docker.api.client.APIClient object at 0x0000020D75928708>, response = <Response [404]>
985
986 def _raise_for_status(self, response):
987 """Raises stored :class:`APIError`, if one occurred."""
988 try:
989> response.raise_for_status()
990
991c:\program files\python37\lib\site-packages\docker\api\client.py:261:
992_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
993
994self = <Response [404]>
995
996 def raise_for_status(self):
997 """Raises stored :class:`HTTPError`, if one occurred."""
998
999 http_error_msg = ''
1000 if isinstance(self.reason, bytes):
1001 # We attempt to decode utf-8 first because some servers
1002 # choose to localize their reason strings. If the string
1003 # isn't utf-8, we fall back to iso-8859-1 for all other
1004 # encodings. (See PR #3538)
1005 try:
1006 reason = self.reason.decode('utf-8')
1007 except UnicodeDecodeError:
1008 reason = self.reason.decode('iso-8859-1')
1009 else:
1010 reason = self.reason
1011
1012 if 400 <= self.status_code < 500:
1013 http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
1014
1015 elif 500 <= self.status_code < 600:
1016 http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
1017
1018 if http_error_msg:
1019> raise HTTPError(http_error_msg, response=self)
1020E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False
1021
1022c:\program files\python37\lib\site-packages\requests\models.py:940: HTTPError
1023
1024During handling of the above exception, another exception occurred:
1025
1026 @pytest.mark.integration
1027 def test_runner_py3_ok():
1028> assert soSorryYouLose(str(dummypath / 'dummy.py')) == "The 10th Fib number is 55\n"
1029
1030tests\runner\test_runner.py:43:
1031_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1032runner\runner.py:102: in soSorryYouLose
1033 dockerc.images.remove(imagetag)
1034c:\program files\python37\lib\site-packages\docker\models\images.py:463: in remove
1035 self.client.api.remove_image(*args, **kwargs)
1036c:\program files\python37\lib\site-packages\docker\utils\decorators.py:19: in wrapped
1037 return f(self, resource_id, *args, **kwargs)
1038c:\program files\python37\lib\site-packages\docker\api\image.py:495: in remove_image
1039 return self._result(res, True)
1040c:\program files\python37\lib\site-packages\docker\api\client.py:267: in _result
1041 self._raise_for_status(response)
1042c:\program files\python37\lib\site-packages\docker\api\client.py:263: in _raise_for_status
1043 raise create_api_error_from_http_exception(e)
1044_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1045
1046e = HTTPError('404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False')
1047
1048 def create_api_error_from_http_exception(e):
1049 """
1050 Create a suitable APIError from requests.exceptions.HTTPError.
1051 """
1052 response = e.response
1053 try:
1054 explanation = response.json()['message']
1055 except ValueError:
1056 explanation = (response.content or '').strip()
1057 cls = APIError
1058 if response.status_code == 404:
1059 if explanation and ('No such image' in str(explanation) or
1060 'not found: does not exist or no pull access'
1061 in str(explanation) or
1062 'repository does not exist' in str(explanation)):
1063 cls = ImageNotFound
1064 else:
1065 cls = NotFound
1066> raise cls(e, response=response, explanation=explanation)
1067E docker.errors.ImageNotFound: 404 Client Error: Not Found ("No such image: runner:latest")
1068
1069c:\program files\python37\lib\site-packages\docker\errors.py:31: ImageNotFound
1070_________________________________________________ test_runner_java_ok _________________________________________________
1071
1072codefpath = 'C:\\Users\\Slid3rek\\Documents\\MWO\\iwsoj\\iwsoj\\runner\\dummy\\dummy.java'
1073
1074 def soSorryYouLose(codefpath: str) -> str:
1075 """
1076 Executes the
1077 :param codefpath: The path to the code to be run
1078 :return: stdout of both the compile and the run step of the file in question
1079 """
1080
1081 imagetag = "runner"
1082 lang = Lang.from_file(codefpath)
1083
1084 dockerfile_path = get_dockerfile_dir(lang)
1085 dockerc = docker.from_env()
1086
1087 try:
1088 ctx2cwd(dockerfile_path, codefpath)
1089 short_codefname = os.path.basename(codefpath)
1090> dockerc.images.build(path="os.getcwd()", buildargs={"fpath": short_codefname}, tag=imagetag, rm=True)
1091
1092runner\runner.py:96:
1093_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1094
1095self = <docker.models.images.ImageCollection object at 0x0000020D757C1108>
1096kwargs = {'buildargs': {'fpath': 'dummy.java'}, 'path': 'os.getcwd()', 'rm': True, 'tag': 'runner'}
1097
1098 def build(self, **kwargs):
1099 """
1100 Build an image and return it. Similar to the ``docker build``
1101 command. Either ``path`` or ``fileobj`` must be set.
1102
1103 If you have a tar file for the Docker build context (including a
1104 Dockerfile) already, pass a readable file-like object to ``fileobj``
1105 and also pass ``custom_context=True``. If the stream is compressed
1106 also, set ``encoding`` to the correct value (e.g ``gzip``).
1107
1108 If you want to get the raw output of the build, use the
1109 :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
1110 low-level API.
1111
1112 Args:
1113 path (str): Path to the directory containing the Dockerfile
1114 fileobj: A file object to use as the Dockerfile. (Or a file-like
1115 object)
1116 tag (str): A tag to add to the final image
1117 quiet (bool): Whether to return the status
1118 nocache (bool): Don't use the cache when set to ``True``
1119 rm (bool): Remove intermediate containers. The ``docker build``
1120 command now defaults to ``--rm=true``, but we have kept the old
1121 default of `False` to preserve backward compatibility
1122 timeout (int): HTTP timeout
1123 custom_context (bool): Optional if using ``fileobj``
1124 encoding (str): The encoding for a stream. Set to ``gzip`` for
1125 compressing
1126 pull (bool): Downloads any updates to the FROM image in Dockerfiles
1127 forcerm (bool): Always remove intermediate containers, even after
1128 unsuccessful builds
1129 dockerfile (str): path within the build context to the Dockerfile
1130 buildargs (dict): A dictionary of build arguments
1131 container_limits (dict): A dictionary of limits applied to each
1132 container created by the build process. Valid keys:
1133
1134 - memory (int): set memory limit for build
1135 - memswap (int): Total memory (memory + swap), -1 to disable
1136 swap
1137 - cpushares (int): CPU shares (relative weight)
1138 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
1139 ``"0-3"``, ``"0,1"``
1140 shmsize (int): Size of `/dev/shm` in bytes. The size must be
1141 greater than 0. If omitted the system uses 64MB
1142 labels (dict): A dictionary of labels to set on the image
1143 cache_from (list): A list of images used for build cache
1144 resolution
1145 target (str): Name of the build-stage to build in a multi-stage
1146 Dockerfile
1147 network_mode (str): networking mode for the run commands during
1148 build
1149 squash (bool): Squash the resulting images layers into a
1150 single layer.
1151 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
1152 containers, as a mapping of hostname to IP address.
1153 platform (str): Platform in the format ``os[/arch[/variant]]``.
1154 isolation (str): Isolation technology used during build.
1155 Default: `None`.
1156 use_config_proxy (bool): If ``True``, and if the docker client
1157 configuration file (``~/.docker/config.json`` by default)
1158 contains a proxy configuration, the corresponding environment
1159 variables will be set in the container being built.
1160
1161 Returns:
1162 (tuple): The first item is the :py:class:`Image` object for the
1163 image that was build. The second item is a generator of the
1164 build logs as JSON-decoded objects.
1165
1166 Raises:
1167 :py:class:`docker.errors.BuildError`
1168 If there is an error during the build.
1169 :py:class:`docker.errors.APIError`
1170 If the server returns any other error.
1171 ``TypeError``
1172 If neither ``path`` nor ``fileobj`` is specified.
1173 """
1174> resp = self.client.api.build(**kwargs)
1175
1176c:\program files\python37\lib\site-packages\docker\models\images.py:279:
1177_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1178
1179self = <docker.api.client.APIClient object at 0x0000020D757C1908>, path = 'os.getcwd()', tag = 'runner', quiet = False
1180fileobj = None, nocache = False, rm = True, timeout = None, custom_context = False, encoding = None, pull = False
1181forcerm = False, dockerfile = None, container_limits = {}, decode = False, buildargs = {'fpath': 'dummy.java'}
1182gzip = False, shmsize = None, labels = None, cache_from = None, target = None, network_mode = None, squash = None
1183extra_hosts = None, platform = None, isolation = None, use_config_proxy = True
1184
1185 def build(self, path=None, tag=None, quiet=False, fileobj=None,
1186 nocache=False, rm=False, timeout=None,
1187 custom_context=False, encoding=None, pull=False,
1188 forcerm=False, dockerfile=None, container_limits=None,
1189 decode=False, buildargs=None, gzip=False, shmsize=None,
1190 labels=None, cache_from=None, target=None, network_mode=None,
1191 squash=None, extra_hosts=None, platform=None, isolation=None,
1192 use_config_proxy=True):
1193 """
1194 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
1195 needs to be set. ``path`` can be a local path (to a directory
1196 containing a Dockerfile) or a remote URL. ``fileobj`` must be a
1197 readable file-like object to a Dockerfile.
1198
1199 If you have a tar file for the Docker build context (including a
1200 Dockerfile) already, pass a readable file-like object to ``fileobj``
1201 and also pass ``custom_context=True``. If the stream is compressed
1202 also, set ``encoding`` to the correct value (e.g ``gzip``).
1203
1204 Example:
1205 >>> from io import BytesIO
1206 >>> from docker import APIClient
1207 >>> dockerfile = '''
1208 ... # Shared Volume
1209 ... FROM busybox:buildroot-2014.02
1210 ... VOLUME /data
1211 ... CMD ["/bin/sh"]
1212 ... '''
1213 >>> f = BytesIO(dockerfile.encode('utf-8'))
1214 >>> cli = APIClient(base_url='tcp://127.0.0.1:2375')
1215 >>> response = [line for line in cli.build(
1216 ... fileobj=f, rm=True, tag='yourname/volume'
1217 ... )]
1218 >>> response
1219 ['{"stream":" ---\\u003e a9eb17255234\\n"}',
1220 '{"stream":"Step 1 : VOLUME /data\\n"}',
1221 '{"stream":" ---\\u003e Running in abdc1e6896c6\\n"}',
1222 '{"stream":" ---\\u003e 713bca62012e\\n"}',
1223 '{"stream":"Removing intermediate container abdc1e6896c6\\n"}',
1224 '{"stream":"Step 2 : CMD [\\"/bin/sh\\"]\\n"}',
1225 '{"stream":" ---\\u003e Running in dba30f2a1a7e\\n"}',
1226 '{"stream":" ---\\u003e 032b8b2855fc\\n"}',
1227 '{"stream":"Removing intermediate container dba30f2a1a7e\\n"}',
1228 '{"stream":"Successfully built 032b8b2855fc\\n"}']
1229
1230 Args:
1231 path (str): Path to the directory containing the Dockerfile
1232 fileobj: A file object to use as the Dockerfile. (Or a file-like
1233 object)
1234 tag (str): A tag to add to the final image
1235 quiet (bool): Whether to return the status
1236 nocache (bool): Don't use the cache when set to ``True``
1237 rm (bool): Remove intermediate containers. The ``docker build``
1238 command now defaults to ``--rm=true``, but we have kept the old
1239 default of `False` to preserve backward compatibility
1240 timeout (int): HTTP timeout
1241 custom_context (bool): Optional if using ``fileobj``
1242 encoding (str): The encoding for a stream. Set to ``gzip`` for
1243 compressing
1244 pull (bool): Downloads any updates to the FROM image in Dockerfiles
1245 forcerm (bool): Always remove intermediate containers, even after
1246 unsuccessful builds
1247 dockerfile (str): path within the build context to the Dockerfile
1248 buildargs (dict): A dictionary of build arguments
1249 container_limits (dict): A dictionary of limits applied to each
1250 container created by the build process. Valid keys:
1251
1252 - memory (int): set memory limit for build
1253 - memswap (int): Total memory (memory + swap), -1 to disable
1254 swap
1255 - cpushares (int): CPU shares (relative weight)
1256 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
1257 ``"0-3"``, ``"0,1"``
1258 decode (bool): If set to ``True``, the returned stream will be
1259 decoded into dicts on the fly. Default ``False``
1260 shmsize (int): Size of `/dev/shm` in bytes. The size must be
1261 greater than 0. If omitted the system uses 64MB
1262 labels (dict): A dictionary of labels to set on the image
1263 cache_from (:py:class:`list`): A list of images used for build
1264 cache resolution
1265 target (str): Name of the build-stage to build in a multi-stage
1266 Dockerfile
1267 network_mode (str): networking mode for the run commands during
1268 build
1269 squash (bool): Squash the resulting images layers into a
1270 single layer.
1271 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
1272 containers, as a mapping of hostname to IP address.
1273 platform (str): Platform in the format ``os[/arch[/variant]]``
1274 isolation (str): Isolation technology used during build.
1275 Default: `None`.
1276 use_config_proxy (bool): If ``True``, and if the docker client
1277 configuration file (``~/.docker/config.json`` by default)
1278 contains a proxy configuration, the corresponding environment
1279 variables will be set in the container being built.
1280
1281 Returns:
1282 A generator for the build output.
1283
1284 Raises:
1285 :py:class:`docker.errors.APIError`
1286 If the server returns an error.
1287 ``TypeError``
1288 If neither ``path`` nor ``fileobj`` is specified.
1289 """
1290 remote = context = None
1291 headers = {}
1292 container_limits = container_limits or {}
1293 buildargs = buildargs or {}
1294 if path is None and fileobj is None:
1295 raise TypeError("Either path or fileobj needs to be provided.")
1296 if gzip and encoding is not None:
1297 raise errors.DockerException(
1298 'Can not use custom encoding if gzip is enabled'
1299 )
1300
1301 for key in container_limits.keys():
1302 if key not in constants.CONTAINER_LIMITS_KEYS:
1303 raise errors.DockerException(
1304 'Invalid container_limits key {0}'.format(key)
1305 )
1306
1307 if custom_context:
1308 if not fileobj:
1309 raise TypeError("You must specify fileobj with custom_context")
1310 context = fileobj
1311 elif fileobj is not None:
1312 context = utils.mkbuildcontext(fileobj)
1313 elif path.startswith(('http://', 'https://',
1314 'git://', 'github.com/', 'git@')):
1315 remote = path
1316 elif not os.path.isdir(path):
1317> raise TypeError("You must specify a directory to build in path")
1318E TypeError: You must specify a directory to build in path
1319
1320c:\program files\python37\lib\site-packages\docker\api\build.py:148: TypeError
1321
1322During handling of the above exception, another exception occurred:
1323
1324self = <docker.api.client.APIClient object at 0x0000020D757C1908>, response = <Response [404]>
1325
1326 def _raise_for_status(self, response):
1327 """Raises stored :class:`APIError`, if one occurred."""
1328 try:
1329> response.raise_for_status()
1330
1331c:\program files\python37\lib\site-packages\docker\api\client.py:261:
1332_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1333
1334self = <Response [404]>
1335
1336 def raise_for_status(self):
1337 """Raises stored :class:`HTTPError`, if one occurred."""
1338
1339 http_error_msg = ''
1340 if isinstance(self.reason, bytes):
1341 # We attempt to decode utf-8 first because some servers
1342 # choose to localize their reason strings. If the string
1343 # isn't utf-8, we fall back to iso-8859-1 for all other
1344 # encodings. (See PR #3538)
1345 try:
1346 reason = self.reason.decode('utf-8')
1347 except UnicodeDecodeError:
1348 reason = self.reason.decode('iso-8859-1')
1349 else:
1350 reason = self.reason
1351
1352 if 400 <= self.status_code < 500:
1353 http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
1354
1355 elif 500 <= self.status_code < 600:
1356 http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
1357
1358 if http_error_msg:
1359> raise HTTPError(http_error_msg, response=self)
1360E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False
1361
1362c:\program files\python37\lib\site-packages\requests\models.py:940: HTTPError
1363
1364During handling of the above exception, another exception occurred:
1365
1366 @pytest.mark.integration
1367 def test_runner_java_ok():
1368> assert soSorryYouLose(str(dummypath / 'dummy.java')) == "Factorial of 4 is 24\n"
1369
1370tests\runner\test_runner.py:48:
1371_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1372runner\runner.py:102: in soSorryYouLose
1373 dockerc.images.remove(imagetag)
1374c:\program files\python37\lib\site-packages\docker\models\images.py:463: in remove
1375 self.client.api.remove_image(*args, **kwargs)
1376c:\program files\python37\lib\site-packages\docker\utils\decorators.py:19: in wrapped
1377 return f(self, resource_id, *args, **kwargs)
1378c:\program files\python37\lib\site-packages\docker\api\image.py:495: in remove_image
1379 return self._result(res, True)
1380c:\program files\python37\lib\site-packages\docker\api\client.py:267: in _result
1381 self._raise_for_status(response)
1382c:\program files\python37\lib\site-packages\docker\api\client.py:263: in _raise_for_status
1383 raise create_api_error_from_http_exception(e)
1384_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1385
1386e = HTTPError('404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False')
1387
1388 def create_api_error_from_http_exception(e):
1389 """
1390 Create a suitable APIError from requests.exceptions.HTTPError.
1391 """
1392 response = e.response
1393 try:
1394 explanation = response.json()['message']
1395 except ValueError:
1396 explanation = (response.content or '').strip()
1397 cls = APIError
1398 if response.status_code == 404:
1399 if explanation and ('No such image' in str(explanation) or
1400 'not found: does not exist or no pull access'
1401 in str(explanation) or
1402 'repository does not exist' in str(explanation)):
1403 cls = ImageNotFound
1404 else:
1405 cls = NotFound
1406> raise cls(e, response=response, explanation=explanation)
1407E docker.errors.ImageNotFound: 404 Client Error: Not Found ("No such image: runner:latest")
1408
1409c:\program files\python37\lib\site-packages\docker\errors.py:31: ImageNotFound
1410__________________________________________________ test_runner_go_ok __________________________________________________
1411
1412codefpath = 'C:\\Users\\Slid3rek\\Documents\\MWO\\iwsoj\\iwsoj\\runner\\dummy\\dummy.go'
1413
1414 def soSorryYouLose(codefpath: str) -> str:
1415 """
1416 Executes the
1417 :param codefpath: The path to the code to be run
1418 :return: stdout of both the compile and the run step of the file in question
1419 """
1420
1421 imagetag = "runner"
1422 lang = Lang.from_file(codefpath)
1423
1424 dockerfile_path = get_dockerfile_dir(lang)
1425 dockerc = docker.from_env()
1426
1427 try:
1428 ctx2cwd(dockerfile_path, codefpath)
1429 short_codefname = os.path.basename(codefpath)
1430> dockerc.images.build(path="os.getcwd()", buildargs={"fpath": short_codefname}, tag=imagetag, rm=True)
1431
1432runner\runner.py:96:
1433_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1434
1435self = <docker.models.images.ImageCollection object at 0x0000020D74F90D88>
1436kwargs = {'buildargs': {'fpath': 'dummy.go'}, 'path': 'os.getcwd()', 'rm': True, 'tag': 'runner'}
1437
1438 def build(self, **kwargs):
1439 """
1440 Build an image and return it. Similar to the ``docker build``
1441 command. Either ``path`` or ``fileobj`` must be set.
1442
1443 If you have a tar file for the Docker build context (including a
1444 Dockerfile) already, pass a readable file-like object to ``fileobj``
1445 and also pass ``custom_context=True``. If the stream is compressed
1446 also, set ``encoding`` to the correct value (e.g ``gzip``).
1447
1448 If you want to get the raw output of the build, use the
1449 :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
1450 low-level API.
1451
1452 Args:
1453 path (str): Path to the directory containing the Dockerfile
1454 fileobj: A file object to use as the Dockerfile. (Or a file-like
1455 object)
1456 tag (str): A tag to add to the final image
1457 quiet (bool): Whether to return the status
1458 nocache (bool): Don't use the cache when set to ``True``
1459 rm (bool): Remove intermediate containers. The ``docker build``
1460 command now defaults to ``--rm=true``, but we have kept the old
1461 default of `False` to preserve backward compatibility
1462 timeout (int): HTTP timeout
1463 custom_context (bool): Optional if using ``fileobj``
1464 encoding (str): The encoding for a stream. Set to ``gzip`` for
1465 compressing
1466 pull (bool): Downloads any updates to the FROM image in Dockerfiles
1467 forcerm (bool): Always remove intermediate containers, even after
1468 unsuccessful builds
1469 dockerfile (str): path within the build context to the Dockerfile
1470 buildargs (dict): A dictionary of build arguments
1471 container_limits (dict): A dictionary of limits applied to each
1472 container created by the build process. Valid keys:
1473
1474 - memory (int): set memory limit for build
1475 - memswap (int): Total memory (memory + swap), -1 to disable
1476 swap
1477 - cpushares (int): CPU shares (relative weight)
1478 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
1479 ``"0-3"``, ``"0,1"``
1480 shmsize (int): Size of `/dev/shm` in bytes. The size must be
1481 greater than 0. If omitted the system uses 64MB
1482 labels (dict): A dictionary of labels to set on the image
1483 cache_from (list): A list of images used for build cache
1484 resolution
1485 target (str): Name of the build-stage to build in a multi-stage
1486 Dockerfile
1487 network_mode (str): networking mode for the run commands during
1488 build
1489 squash (bool): Squash the resulting images layers into a
1490 single layer.
1491 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
1492 containers, as a mapping of hostname to IP address.
1493 platform (str): Platform in the format ``os[/arch[/variant]]``.
1494 isolation (str): Isolation technology used during build.
1495 Default: `None`.
1496 use_config_proxy (bool): If ``True``, and if the docker client
1497 configuration file (``~/.docker/config.json`` by default)
1498 contains a proxy configuration, the corresponding environment
1499 variables will be set in the container being built.
1500
1501 Returns:
1502 (tuple): The first item is the :py:class:`Image` object for the
1503 image that was build. The second item is a generator of the
1504 build logs as JSON-decoded objects.
1505
1506 Raises:
1507 :py:class:`docker.errors.BuildError`
1508 If there is an error during the build.
1509 :py:class:`docker.errors.APIError`
1510 If the server returns any other error.
1511 ``TypeError``
1512 If neither ``path`` nor ``fileobj`` is specified.
1513 """
1514> resp = self.client.api.build(**kwargs)
1515
1516c:\program files\python37\lib\site-packages\docker\models\images.py:279:
1517_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1518
1519self = <docker.api.client.APIClient object at 0x0000020D751F0288>, path = 'os.getcwd()', tag = 'runner', quiet = False
1520fileobj = None, nocache = False, rm = True, timeout = None, custom_context = False, encoding = None, pull = False
1521forcerm = False, dockerfile = None, container_limits = {}, decode = False, buildargs = {'fpath': 'dummy.go'}
1522gzip = False, shmsize = None, labels = None, cache_from = None, target = None, network_mode = None, squash = None
1523extra_hosts = None, platform = None, isolation = None, use_config_proxy = True
1524
1525 def build(self, path=None, tag=None, quiet=False, fileobj=None,
1526 nocache=False, rm=False, timeout=None,
1527 custom_context=False, encoding=None, pull=False,
1528 forcerm=False, dockerfile=None, container_limits=None,
1529 decode=False, buildargs=None, gzip=False, shmsize=None,
1530 labels=None, cache_from=None, target=None, network_mode=None,
1531 squash=None, extra_hosts=None, platform=None, isolation=None,
1532 use_config_proxy=True):
1533 """
1534 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
1535 needs to be set. ``path`` can be a local path (to a directory
1536 containing a Dockerfile) or a remote URL. ``fileobj`` must be a
1537 readable file-like object to a Dockerfile.
1538
1539 If you have a tar file for the Docker build context (including a
1540 Dockerfile) already, pass a readable file-like object to ``fileobj``
1541 and also pass ``custom_context=True``. If the stream is compressed
1542 also, set ``encoding`` to the correct value (e.g ``gzip``).
1543
1544 Example:
1545 >>> from io import BytesIO
1546 >>> from docker import APIClient
1547 >>> dockerfile = '''
1548 ... # Shared Volume
1549 ... FROM busybox:buildroot-2014.02
1550 ... VOLUME /data
1551 ... CMD ["/bin/sh"]
1552 ... '''
1553 >>> f = BytesIO(dockerfile.encode('utf-8'))
1554 >>> cli = APIClient(base_url='tcp://127.0.0.1:2375')
1555 >>> response = [line for line in cli.build(
1556 ... fileobj=f, rm=True, tag='yourname/volume'
1557 ... )]
1558 >>> response
1559 ['{"stream":" ---\\u003e a9eb17255234\\n"}',
1560 '{"stream":"Step 1 : VOLUME /data\\n"}',
1561 '{"stream":" ---\\u003e Running in abdc1e6896c6\\n"}',
1562 '{"stream":" ---\\u003e 713bca62012e\\n"}',
1563 '{"stream":"Removing intermediate container abdc1e6896c6\\n"}',
1564 '{"stream":"Step 2 : CMD [\\"/bin/sh\\"]\\n"}',
1565 '{"stream":" ---\\u003e Running in dba30f2a1a7e\\n"}',
1566 '{"stream":" ---\\u003e 032b8b2855fc\\n"}',
1567 '{"stream":"Removing intermediate container dba30f2a1a7e\\n"}',
1568 '{"stream":"Successfully built 032b8b2855fc\\n"}']
1569
1570 Args:
1571 path (str): Path to the directory containing the Dockerfile
1572 fileobj: A file object to use as the Dockerfile. (Or a file-like
1573 object)
1574 tag (str): A tag to add to the final image
1575 quiet (bool): Whether to return the status
1576 nocache (bool): Don't use the cache when set to ``True``
1577 rm (bool): Remove intermediate containers. The ``docker build``
1578 command now defaults to ``--rm=true``, but we have kept the old
1579 default of `False` to preserve backward compatibility
1580 timeout (int): HTTP timeout
1581 custom_context (bool): Optional if using ``fileobj``
1582 encoding (str): The encoding for a stream. Set to ``gzip`` for
1583 compressing
1584 pull (bool): Downloads any updates to the FROM image in Dockerfiles
1585 forcerm (bool): Always remove intermediate containers, even after
1586 unsuccessful builds
1587 dockerfile (str): path within the build context to the Dockerfile
1588 buildargs (dict): A dictionary of build arguments
1589 container_limits (dict): A dictionary of limits applied to each
1590 container created by the build process. Valid keys:
1591
1592 - memory (int): set memory limit for build
1593 - memswap (int): Total memory (memory + swap), -1 to disable
1594 swap
1595 - cpushares (int): CPU shares (relative weight)
1596 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
1597 ``"0-3"``, ``"0,1"``
1598 decode (bool): If set to ``True``, the returned stream will be
1599 decoded into dicts on the fly. Default ``False``
1600 shmsize (int): Size of `/dev/shm` in bytes. The size must be
1601 greater than 0. If omitted the system uses 64MB
1602 labels (dict): A dictionary of labels to set on the image
1603 cache_from (:py:class:`list`): A list of images used for build
1604 cache resolution
1605 target (str): Name of the build-stage to build in a multi-stage
1606 Dockerfile
1607 network_mode (str): networking mode for the run commands during
1608 build
1609 squash (bool): Squash the resulting images layers into a
1610 single layer.
1611 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
1612 containers, as a mapping of hostname to IP address.
1613 platform (str): Platform in the format ``os[/arch[/variant]]``
1614 isolation (str): Isolation technology used during build.
1615 Default: `None`.
1616 use_config_proxy (bool): If ``True``, and if the docker client
1617 configuration file (``~/.docker/config.json`` by default)
1618 contains a proxy configuration, the corresponding environment
1619 variables will be set in the container being built.
1620
1621 Returns:
1622 A generator for the build output.
1623
1624 Raises:
1625 :py:class:`docker.errors.APIError`
1626 If the server returns an error.
1627 ``TypeError``
1628 If neither ``path`` nor ``fileobj`` is specified.
1629 """
1630 remote = context = None
1631 headers = {}
1632 container_limits = container_limits or {}
1633 buildargs = buildargs or {}
1634 if path is None and fileobj is None:
1635 raise TypeError("Either path or fileobj needs to be provided.")
1636 if gzip and encoding is not None:
1637 raise errors.DockerException(
1638 'Can not use custom encoding if gzip is enabled'
1639 )
1640
1641 for key in container_limits.keys():
1642 if key not in constants.CONTAINER_LIMITS_KEYS:
1643 raise errors.DockerException(
1644 'Invalid container_limits key {0}'.format(key)
1645 )
1646
1647 if custom_context:
1648 if not fileobj:
1649 raise TypeError("You must specify fileobj with custom_context")
1650 context = fileobj
1651 elif fileobj is not None:
1652 context = utils.mkbuildcontext(fileobj)
1653 elif path.startswith(('http://', 'https://',
1654 'git://', 'github.com/', 'git@')):
1655 remote = path
1656 elif not os.path.isdir(path):
1657> raise TypeError("You must specify a directory to build in path")
1658E TypeError: You must specify a directory to build in path
1659
1660c:\program files\python37\lib\site-packages\docker\api\build.py:148: TypeError
1661
1662During handling of the above exception, another exception occurred:
1663
1664self = <docker.api.client.APIClient object at 0x0000020D751F0288>, response = <Response [404]>
1665
1666 def _raise_for_status(self, response):
1667 """Raises stored :class:`APIError`, if one occurred."""
1668 try:
1669> response.raise_for_status()
1670
1671c:\program files\python37\lib\site-packages\docker\api\client.py:261:
1672_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1673
1674self = <Response [404]>
1675
1676 def raise_for_status(self):
1677 """Raises stored :class:`HTTPError`, if one occurred."""
1678
1679 http_error_msg = ''
1680 if isinstance(self.reason, bytes):
1681 # We attempt to decode utf-8 first because some servers
1682 # choose to localize their reason strings. If the string
1683 # isn't utf-8, we fall back to iso-8859-1 for all other
1684 # encodings. (See PR #3538)
1685 try:
1686 reason = self.reason.decode('utf-8')
1687 except UnicodeDecodeError:
1688 reason = self.reason.decode('iso-8859-1')
1689 else:
1690 reason = self.reason
1691
1692 if 400 <= self.status_code < 500:
1693 http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
1694
1695 elif 500 <= self.status_code < 600:
1696 http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
1697
1698 if http_error_msg:
1699> raise HTTPError(http_error_msg, response=self)
1700E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False
1701
1702c:\program files\python37\lib\site-packages\requests\models.py:940: HTTPError
1703
1704During handling of the above exception, another exception occurred:
1705
1706 @pytest.mark.integration
1707 def test_runner_go_ok():
1708> assert soSorryYouLose(str(dummypath / 'dummy.go')) == "GO somewhere else!\n"
1709
1710tests\runner\test_runner.py:53:
1711_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1712runner\runner.py:102: in soSorryYouLose
1713 dockerc.images.remove(imagetag)
1714c:\program files\python37\lib\site-packages\docker\models\images.py:463: in remove
1715 self.client.api.remove_image(*args, **kwargs)
1716c:\program files\python37\lib\site-packages\docker\utils\decorators.py:19: in wrapped
1717 return f(self, resource_id, *args, **kwargs)
1718c:\program files\python37\lib\site-packages\docker\api\image.py:495: in remove_image
1719 return self._result(res, True)
1720c:\program files\python37\lib\site-packages\docker\api\client.py:267: in _result
1721 self._raise_for_status(response)
1722c:\program files\python37\lib\site-packages\docker\api\client.py:263: in _raise_for_status
1723 raise create_api_error_from_http_exception(e)
1724_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1725
1726e = HTTPError('404 Client Error: Not Found for url: http+docker://localnpipe/v1.35/images/runner?force=False&noprune=False')
1727
1728 def create_api_error_from_http_exception(e):
1729 """
1730 Create a suitable APIError from requests.exceptions.HTTPError.
1731 """
1732 response = e.response
1733 try:
1734 explanation = response.json()['message']
1735 except ValueError:
1736 explanation = (response.content or '').strip()
1737 cls = APIError
1738 if response.status_code == 404:
1739 if explanation and ('No such image' in str(explanation) or
1740 'not found: does not exist or no pull access'
1741 in str(explanation) or
1742 'repository does not exist' in str(explanation)):
1743 cls = ImageNotFound
1744 else:
1745 cls = NotFound
1746> raise cls(e, response=response, explanation=explanation)
1747E docker.errors.ImageNotFound: 404 Client Error: Not Found ("No such image: runner:latest")
1748
1749c:\program files\python37\lib\site-packages\docker\errors.py:31: ImageNotFound
1750================================================== warnings summary ===================================================
1751runner\runner.py:7
1752 C:\Users\Slid3rek\Documents\MWO\iwsoj\iwsoj\runner\runner.py:7: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
1753 from collections import Mapping
1754
1755c:\program files\python37\lib\site-packages\_pytest\mark\structures.py:325
1756 c:\program files\python37\lib\site-packages\_pytest\mark\structures.py:325: PytestUnknownMarkWarning: Unknown pytest.mark.integration - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
1757 PytestUnknownMarkWarning,
1758
1759-- Docs: https://docs.pytest.org/en/latest/warnings.html
1760====================================== 6 failed, 21 passed, 2 warnings in 3.01s =======================================
1761PS C:\Users\Slid3rek\Documents\MWO\iwsoj\iwsoj>