· 6 years ago · Oct 29, 2019, 11:28 PM
1(env) slid3rek@MSI-Gaming3-Z97-i5-4690K-GTX970:~/Dokumenty/MWO/iwsoj/iwsoj/iwsoj$ pytest tests/submissions/test_api.py
2=============================================================================================================================== test session starts ===============================================================================================================================
3platform linux -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
4Django settings: iwsoj.settings (from ini file)
5rootdir: /home/slid3rek/Dokumenty/MWO/iwsoj/iwsoj/iwsoj, inifile: pytest.ini
6plugins: cov-2.8.1, django-3.5.1, mock-1.11.1
7collected 2 items
8
9tests/submissions/test_api.py F. [100%]
10
11==================================================================================================================================== FAILURES =====================================================================================================================================
12______________________________________________________________________________________________________________________________ test_api_submissions _______________________________________________________________________________________________________________________________
13
14self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1dda20>, method = 'POST'
15url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D', body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>
16headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}, retries = Retry(total=0, connect=None, read=False, redirect=None, status=None)
17redirect = False, assert_same_host = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa19a518>, pool_timeout = None, release_conn = False, chunked = False, body_pos = 0, response_kw = {'decode_content': False, 'preload_content': False}, conn = None
18release_this_conn = True, err = None, clean_exit = False, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff320>, is_new_proxy_conn = False
19
20 def urlopen(
21 self,
22 method,
23 url,
24 body=None,
25 headers=None,
26 retries=None,
27 redirect=True,
28 assert_same_host=True,
29 timeout=_Default,
30 pool_timeout=None,
31 release_conn=None,
32 chunked=False,
33 body_pos=None,
34 **response_kw
35 ):
36 """
37 Get a connection from the pool and perform an HTTP request. This is the
38 lowest level call for making a request, so you'll need to specify all
39 the raw details.
40
41 .. note::
42
43 More commonly, it's appropriate to use a convenience method provided
44 by :class:`.RequestMethods`, such as :meth:`request`.
45
46 .. note::
47
48 `release_conn` will only behave as expected if
49 `preload_content=False` because we want to make
50 `preload_content=False` the default behaviour someday soon without
51 breaking backwards compatibility.
52
53 :param method:
54 HTTP request method (such as GET, POST, PUT, etc.)
55
56 :param body:
57 Data to send in the request body (useful for creating
58 POST requests, see HTTPConnectionPool.post_url for
59 more convenience).
60
61 :param headers:
62 Dictionary of custom headers to send, such as User-Agent,
63 If-None-Match, etc. If None, pool headers are used. If provided,
64 these headers completely replace any pool-specific headers.
65
66 :param retries:
67 Configure the number of retries to allow before raising a
68 :class:`~urllib3.exceptions.MaxRetryError` exception.
69
70 Pass ``None`` to retry until you receive a response. Pass a
71 :class:`~urllib3.util.retry.Retry` object for fine-grained control
72 over different types of retries.
73 Pass an integer number to retry connection errors that many times,
74 but no other types of errors. Pass zero to never retry.
75
76 If ``False``, then retries are disabled and any exception is raised
77 immediately. Also, instead of raising a MaxRetryError on redirects,
78 the redirect response will be returned.
79
80 :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
81
82 :param redirect:
83 If True, automatically handle redirects (status codes 301, 302,
84 303, 307, 308). Each redirect counts as a retry. Disabling retries
85 will disable redirect, too.
86
87 :param assert_same_host:
88 If ``True``, will make sure that the host of the pool requests is
89 consistent else will raise HostChangedError. When False, you can
90 use the pool on an HTTP proxy and request foreign hosts.
91
92 :param timeout:
93 If specified, overrides the default timeout for this one
94 request. It may be a float (in seconds) or an instance of
95 :class:`urllib3.util.Timeout`.
96
97 :param pool_timeout:
98 If set and the pool is set to block=True, then this method will
99 block for ``pool_timeout`` seconds and raise EmptyPoolError if no
100 connection is available within the time period.
101
102 :param release_conn:
103 If False, then the urlopen call will not release the connection
104 back into the pool once a response is received (but will release if
105 you read the entire contents of the response such as when
106 `preload_content=True`). This is useful if you're not preloading
107 the response's content immediately. You will need to call
108 ``r.release_conn()`` on the response ``r`` to return the connection
109 back into the pool. If None, it takes the value of
110 ``response_kw.get('preload_content', True)``.
111
112 :param chunked:
113 If True, urllib3 will send the body using chunked transfer
114 encoding. Otherwise, urllib3 will send the body using the standard
115 content-length form. Defaults to False.
116
117 :param int body_pos:
118 Position to seek to in file-like body in the event of a retry or
119 redirect. Typically this won't need to be set because urllib3 will
120 auto-populate the value when needed.
121
122 :param \\**response_kw:
123 Additional parameters are passed to
124 :meth:`urllib3.response.HTTPResponse.from_httplib`
125 """
126 if headers is None:
127 headers = self.headers
128
129 if not isinstance(retries, Retry):
130 retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
131
132 if release_conn is None:
133 release_conn = response_kw.get("preload_content", True)
134
135 # Check host
136 if assert_same_host and not self.is_same_host(url):
137 raise HostChangedError(self, url, retries)
138
139 # Ensure that the URL we're connecting to is properly encoded
140 if url.startswith("/"):
141 url = six.ensure_str(_encode_target(url))
142 else:
143 url = six.ensure_str(parse_url(url).url)
144
145 conn = None
146
147 # Track whether `conn` needs to be released before
148 # returning/raising/recursing. Update this variable if necessary, and
149 # leave `release_conn` constant throughout the function. That way, if
150 # the function recurses, the original value of `release_conn` will be
151 # passed down into the recursive call, and its value will be respected.
152 #
153 # See issue #651 [1] for details.
154 #
155 # [1] <https://github.com/shazow/urllib3/issues/651>
156 release_this_conn = release_conn
157
158 # Merge the proxy headers. Only do this in HTTP. We have to copy the
159 # headers dict so we can safely change it without those changes being
160 # reflected in anyone else's copy.
161 if self.scheme == "http":
162 headers = headers.copy()
163 headers.update(self.proxy_headers)
164
165 # Must keep the exception bound to a separate variable or else Python 3
166 # complains about UnboundLocalError.
167 err = None
168
169 # Keep track of whether we cleanly exited the except block. This
170 # ensures we do proper cleanup in finally.
171 clean_exit = False
172
173 # Rewind body position, if needed. Record current position
174 # for future rewinds in the event of a redirect/retry.
175 body_pos = set_file_position(body, body_pos)
176
177 try:
178 # Request a connection from the queue.
179 timeout_obj = self._get_timeout(timeout)
180 conn = self._get_conn(timeout=pool_timeout)
181
182 conn.timeout = timeout_obj.connect_timeout
183
184 is_new_proxy_conn = self.proxy is not None and not getattr(
185 conn, "sock", None
186 )
187 if is_new_proxy_conn:
188 self._prepare_proxy(conn)
189
190 # Make the request on the httplib connection object.
191 httplib_response = self._make_request(
192 conn,
193 method,
194 url,
195 timeout=timeout_obj,
196 body=body,
197 headers=headers,
198> chunked=chunked,
199 )
200
201../env/lib/python3.7/site-packages/urllib3/connectionpool.py:672:
202_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
203
204self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1dda20>, conn = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, method = 'POST'
205url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D', timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff320>, chunked = False
206httplib_request_kw = {'body': <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, 'headers': {'User-Agent': 'docker-sdk-python/4.1.0... deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}}
207timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ffba8>
208
209 def _make_request(
210 self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw
211 ):
212 """
213 Perform a request on a given urllib connection object taken from our
214 pool.
215
216 :param conn:
217 a connection from one of our connection pools
218
219 :param timeout:
220 Socket timeout in seconds for the request. This can be a
221 float or integer, which will set the same timeout value for
222 the socket connect and the socket read, or an instance of
223 :class:`urllib3.util.Timeout`, which gives you more fine-grained
224 control over your timeouts.
225 """
226 self.num_requests += 1
227
228 timeout_obj = self._get_timeout(timeout)
229 timeout_obj.start_connect()
230 conn.timeout = timeout_obj.connect_timeout
231
232 # Trigger any extra validation we need to do.
233 try:
234 self._validate_conn(conn)
235 except (SocketTimeout, BaseSSLError) as e:
236 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
237 self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
238 raise
239
240 # conn.request() calls httplib.*.request, not the method in
241 # urllib3.request. It also calls makefile (recv) on the socket.
242 if chunked:
243 conn.request_chunked(method, url, **httplib_request_kw)
244 else:
245> conn.request(method, url, **httplib_request_kw)
246
247../env/lib/python3.7/site-packages/urllib3/connectionpool.py:387:
248_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
249
250self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, method = 'POST', url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D'
251body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}
252
253 def request(self, method, url, body=None, headers={}, *,
254 encode_chunked=False):
255 """Send a complete request to the server."""
256> self._send_request(method, url, body, headers, encode_chunked)
257
258/usr/lib/python3.7/http/client.py:1244:
259_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
260
261self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, method = 'POST', url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D'
262body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}
263encode_chunked = False
264
265 def _send_request(self, method, url, body, headers, encode_chunked):
266 # Honor explicitly requested Host: and Accept-Encoding: headers.
267 header_names = frozenset(k.lower() for k in headers)
268 skips = {}
269 if 'host' in header_names:
270 skips['skip_host'] = 1
271 if 'accept-encoding' in header_names:
272 skips['skip_accept_encoding'] = 1
273
274 self.putrequest(method, url, **skips)
275
276 # chunked encoding will happen if HTTP/1.1 is used and either
277 # the caller passes encode_chunked=True or the following
278 # conditions hold:
279 # 1. content-length has not been explicitly set
280 # 2. the body is a file or iterable, but not a str or bytes-like
281 # 3. Transfer-Encoding has NOT been explicitly set by the caller
282
283 if 'content-length' not in header_names:
284 # only chunk body if not explicitly set for backwards
285 # compatibility, assuming the client code is already handling the
286 # chunking
287 if 'transfer-encoding' not in header_names:
288 # if content-length cannot be automatically determined, fall
289 # back to chunked encoding
290 encode_chunked = False
291 content_length = self._get_content_length(body, method)
292 if content_length is None:
293 if body is not None:
294 if self.debuglevel > 0:
295 print('Unable to determine size of %r' % body)
296 encode_chunked = True
297 self.putheader('Transfer-Encoding', 'chunked')
298 else:
299 self.putheader('Content-Length', str(content_length))
300 else:
301 encode_chunked = False
302
303 for hdr, value in headers.items():
304 self.putheader(hdr, value)
305 if isinstance(body, str):
306 # RFC 2616 Section 3.7.1 says that text default has a
307 # default charset of iso-8859-1.
308 body = _encode(body, 'body')
309> self.endheaders(body, encode_chunked=encode_chunked)
310
311/usr/lib/python3.7/http/client.py:1290:
312_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
313
314self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, message_body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>
315
316 def endheaders(self, message_body=None, *, encode_chunked=False):
317 """Indicate that the last header line has been sent to the server.
318
319 This method sends the request to the server. The optional message_body
320 argument can be used to pass a message body associated with the
321 request.
322 """
323 if self.__state == _CS_REQ_STARTED:
324 self.__state = _CS_REQ_SENT
325 else:
326 raise CannotSendHeader()
327> self._send_output(message_body, encode_chunked=encode_chunked)
328
329/usr/lib/python3.7/http/client.py:1239:
330_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
331
332self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, message_body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, encode_chunked = False
333
334 def _send_output(self, message_body=None, encode_chunked=False):
335 """Send the currently buffered request and clear the buffer.
336
337 Appends an extra \\r\\n to the buffer.
338 A message_body may be specified, to be appended to the request.
339 """
340 self._buffer.extend((b"", b""))
341 msg = b"\r\n".join(self._buffer)
342 del self._buffer[:]
343> self.send(msg)
344
345/usr/lib/python3.7/http/client.py:1026:
346_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
347
348self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>
349data = b'POST /v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sou...p, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: application/tar\r\nContent-Length: 491520\r\n\r\n'
350
351 def send(self, data):
352 """Send `data' to the server.
353 ``data`` can be a string object, a bytes object, an array object, a
354 file-like object that supports a .read() method, or an iterable object.
355 """
356
357 if self.sock is None:
358 if self.auto_open:
359> self.connect()
360
361/usr/lib/python3.7/http/client.py:966:
362_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
363
364self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>
365
366 def connect(self):
367 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
368 sock.settimeout(self.timeout)
369> sock.connect(self.unix_socket)
370E PermissionError: [Errno 13] Permission denied
371
372../env/lib/python3.7/site-packages/docker/transport/unixconn.py:43: PermissionError
373
374During handling of the above exception, another exception occurred:
375
376self = <docker.transport.unixconn.UnixHTTPAdapter object at 0x7f07a9ff7f60>, request = <PreparedRequest [POST]>, stream = True, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa19a518>, verify = True, cert = None, proxies = OrderedDict()
377
378 def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
379 """Sends PreparedRequest object. Returns Response object.
380
381 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
382 :param stream: (optional) Whether to stream the request content.
383 :param timeout: (optional) How long to wait for the server to send
384 data before giving up, as a float, or a :ref:`(connect timeout,
385 read timeout) <timeouts>` tuple.
386 :type timeout: float or tuple or urllib3 Timeout object
387 :param verify: (optional) Either a boolean, in which case it controls whether
388 we verify the server's TLS certificate, or a string, in which case it
389 must be a path to a CA bundle to use
390 :param cert: (optional) Any user-provided SSL certificate to be trusted.
391 :param proxies: (optional) The proxies dictionary to apply to the request.
392 :rtype: requests.Response
393 """
394
395 try:
396 conn = self.get_connection(request.url, proxies)
397 except LocationValueError as e:
398 raise InvalidURL(e, request=request)
399
400 self.cert_verify(conn, request.url, verify, cert)
401 url = self.request_url(request, proxies)
402 self.add_headers(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
403
404 chunked = not (request.body is None or 'Content-Length' in request.headers)
405
406 if isinstance(timeout, tuple):
407 try:
408 connect, read = timeout
409 timeout = TimeoutSauce(connect=connect, read=read)
410 except ValueError as e:
411 # this may raise a string formatting error.
412 err = ("Invalid timeout {}. Pass a (connect, read) "
413 "timeout tuple, or a single float to set "
414 "both timeouts to the same value".format(timeout))
415 raise ValueError(err)
416 elif isinstance(timeout, TimeoutSauce):
417 pass
418 else:
419 timeout = TimeoutSauce(connect=timeout, read=timeout)
420
421 try:
422 if not chunked:
423 resp = conn.urlopen(
424 method=request.method,
425 url=url,
426 body=request.body,
427 headers=request.headers,
428 redirect=False,
429 assert_same_host=False,
430 preload_content=False,
431 decode_content=False,
432 retries=self.max_retries,
433> timeout=timeout
434 )
435
436../env/lib/python3.7/site-packages/requests/adapters.py:449:
437_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
438
439self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1dda20>, method = 'POST'
440url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D', body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>
441headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}, retries = Retry(total=0, connect=None, read=False, redirect=None, status=None)
442redirect = False, assert_same_host = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa19a518>, pool_timeout = None, release_conn = False, chunked = False, body_pos = 0, response_kw = {'decode_content': False, 'preload_content': False}, conn = None
443release_this_conn = True, err = None, clean_exit = False, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff320>, is_new_proxy_conn = False
444
445 def urlopen(
446 self,
447 method,
448 url,
449 body=None,
450 headers=None,
451 retries=None,
452 redirect=True,
453 assert_same_host=True,
454 timeout=_Default,
455 pool_timeout=None,
456 release_conn=None,
457 chunked=False,
458 body_pos=None,
459 **response_kw
460 ):
461 """
462 Get a connection from the pool and perform an HTTP request. This is the
463 lowest level call for making a request, so you'll need to specify all
464 the raw details.
465
466 .. note::
467
468 More commonly, it's appropriate to use a convenience method provided
469 by :class:`.RequestMethods`, such as :meth:`request`.
470
471 .. note::
472
473 `release_conn` will only behave as expected if
474 `preload_content=False` because we want to make
475 `preload_content=False` the default behaviour someday soon without
476 breaking backwards compatibility.
477
478 :param method:
479 HTTP request method (such as GET, POST, PUT, etc.)
480
481 :param body:
482 Data to send in the request body (useful for creating
483 POST requests, see HTTPConnectionPool.post_url for
484 more convenience).
485
486 :param headers:
487 Dictionary of custom headers to send, such as User-Agent,
488 If-None-Match, etc. If None, pool headers are used. If provided,
489 these headers completely replace any pool-specific headers.
490
491 :param retries:
492 Configure the number of retries to allow before raising a
493 :class:`~urllib3.exceptions.MaxRetryError` exception.
494
495 Pass ``None`` to retry until you receive a response. Pass a
496 :class:`~urllib3.util.retry.Retry` object for fine-grained control
497 over different types of retries.
498 Pass an integer number to retry connection errors that many times,
499 but no other types of errors. Pass zero to never retry.
500
501 If ``False``, then retries are disabled and any exception is raised
502 immediately. Also, instead of raising a MaxRetryError on redirects,
503 the redirect response will be returned.
504
505 :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
506
507 :param redirect:
508 If True, automatically handle redirects (status codes 301, 302,
509 303, 307, 308). Each redirect counts as a retry. Disabling retries
510 will disable redirect, too.
511
512 :param assert_same_host:
513 If ``True``, will make sure that the host of the pool requests is
514 consistent else will raise HostChangedError. When False, you can
515 use the pool on an HTTP proxy and request foreign hosts.
516
517 :param timeout:
518 If specified, overrides the default timeout for this one
519 request. It may be a float (in seconds) or an instance of
520 :class:`urllib3.util.Timeout`.
521
522 :param pool_timeout:
523 If set and the pool is set to block=True, then this method will
524 block for ``pool_timeout`` seconds and raise EmptyPoolError if no
525 connection is available within the time period.
526
527 :param release_conn:
528 If False, then the urlopen call will not release the connection
529 back into the pool once a response is received (but will release if
530 you read the entire contents of the response such as when
531 `preload_content=True`). This is useful if you're not preloading
532 the response's content immediately. You will need to call
533 ``r.release_conn()`` on the response ``r`` to return the connection
534 back into the pool. If None, it takes the value of
535 ``response_kw.get('preload_content', True)``.
536
537 :param chunked:
538 If True, urllib3 will send the body using chunked transfer
539 encoding. Otherwise, urllib3 will send the body using the standard
540 content-length form. Defaults to False.
541
542 :param int body_pos:
543 Position to seek to in file-like body in the event of a retry or
544 redirect. Typically this won't need to be set because urllib3 will
545 auto-populate the value when needed.
546
547 :param \\**response_kw:
548 Additional parameters are passed to
549 :meth:`urllib3.response.HTTPResponse.from_httplib`
550 """
551 if headers is None:
552 headers = self.headers
553
554 if not isinstance(retries, Retry):
555 retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
556
557 if release_conn is None:
558 release_conn = response_kw.get("preload_content", True)
559
560 # Check host
561 if assert_same_host and not self.is_same_host(url):
562 raise HostChangedError(self, url, retries)
563
564 # Ensure that the URL we're connecting to is properly encoded
565 if url.startswith("/"):
566 url = six.ensure_str(_encode_target(url))
567 else:
568 url = six.ensure_str(parse_url(url).url)
569
570 conn = None
571
572 # Track whether `conn` needs to be released before
573 # returning/raising/recursing. Update this variable if necessary, and
574 # leave `release_conn` constant throughout the function. That way, if
575 # the function recurses, the original value of `release_conn` will be
576 # passed down into the recursive call, and its value will be respected.
577 #
578 # See issue #651 [1] for details.
579 #
580 # [1] <https://github.com/shazow/urllib3/issues/651>
581 release_this_conn = release_conn
582
583 # Merge the proxy headers. Only do this in HTTP. We have to copy the
584 # headers dict so we can safely change it without those changes being
585 # reflected in anyone else's copy.
586 if self.scheme == "http":
587 headers = headers.copy()
588 headers.update(self.proxy_headers)
589
590 # Must keep the exception bound to a separate variable or else Python 3
591 # complains about UnboundLocalError.
592 err = None
593
594 # Keep track of whether we cleanly exited the except block. This
595 # ensures we do proper cleanup in finally.
596 clean_exit = False
597
598 # Rewind body position, if needed. Record current position
599 # for future rewinds in the event of a redirect/retry.
600 body_pos = set_file_position(body, body_pos)
601
602 try:
603 # Request a connection from the queue.
604 timeout_obj = self._get_timeout(timeout)
605 conn = self._get_conn(timeout=pool_timeout)
606
607 conn.timeout = timeout_obj.connect_timeout
608
609 is_new_proxy_conn = self.proxy is not None and not getattr(
610 conn, "sock", None
611 )
612 if is_new_proxy_conn:
613 self._prepare_proxy(conn)
614
615 # Make the request on the httplib connection object.
616 httplib_response = self._make_request(
617 conn,
618 method,
619 url,
620 timeout=timeout_obj,
621 body=body,
622 headers=headers,
623 chunked=chunked,
624 )
625
626 # If we're going to release the connection in ``finally:``, then
627 # the response doesn't need to know about the connection. Otherwise
628 # it will also try to release it and we'll have a double-release
629 # mess.
630 response_conn = conn if not release_conn else None
631
632 # Pass method to Response for length checking
633 response_kw["request_method"] = method
634
635 # Import httplib's response into our own wrapper object
636 response = self.ResponseCls.from_httplib(
637 httplib_response,
638 pool=self,
639 connection=response_conn,
640 retries=retries,
641 **response_kw
642 )
643
644 # Everything went great!
645 clean_exit = True
646
647 except queue.Empty:
648 # Timed out by queue.
649 raise EmptyPoolError(self, "No pool connections are available.")
650
651 except (
652 TimeoutError,
653 HTTPException,
654 SocketError,
655 ProtocolError,
656 BaseSSLError,
657 SSLError,
658 CertificateError,
659 ) as e:
660 # Discard the connection for these exceptions. It will be
661 # replaced during the next _get_conn() call.
662 clean_exit = False
663 if isinstance(e, (BaseSSLError, CertificateError)):
664 e = SSLError(e)
665 elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
666 e = ProxyError("Cannot connect to proxy.", e)
667 elif isinstance(e, (SocketError, HTTPException)):
668 e = ProtocolError("Connection aborted.", e)
669
670 retries = retries.increment(
671> method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
672 )
673
674../env/lib/python3.7/site-packages/urllib3/connectionpool.py:720:
675_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
676
677self = Retry(total=0, connect=None, read=False, redirect=None, status=None), method = 'POST', url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D'
678response = None, error = ProtocolError('Connection aborted.', PermissionError(13, 'Permission denied')), _pool = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1dda20>, _stacktrace = <traceback object at 0x7f07aa18dc08>
679
680 def increment(
681 self,
682 method=None,
683 url=None,
684 response=None,
685 error=None,
686 _pool=None,
687 _stacktrace=None,
688 ):
689 """ Return a new Retry object with incremented retry counters.
690
691 :param response: A response object, or None, if the server did not
692 return a response.
693 :type response: :class:`~urllib3.response.HTTPResponse`
694 :param Exception error: An error encountered during the request, or
695 None if the response was received successfully.
696
697 :return: A new ``Retry`` object.
698 """
699 if self.total is False and error:
700 # Disabled, indicate to re-raise the error.
701 raise six.reraise(type(error), error, _stacktrace)
702
703 total = self.total
704 if total is not None:
705 total -= 1
706
707 connect = self.connect
708 read = self.read
709 redirect = self.redirect
710 status_count = self.status
711 cause = "unknown"
712 status = None
713 redirect_location = None
714
715 if error and self._is_connection_error(error):
716 # Connect retry?
717 if connect is False:
718 raise six.reraise(type(error), error, _stacktrace)
719 elif connect is not None:
720 connect -= 1
721
722 elif error and self._is_read_error(error):
723 # Read retry?
724 if read is False or not self._is_method_retryable(method):
725> raise six.reraise(type(error), error, _stacktrace)
726
727../env/lib/python3.7/site-packages/urllib3/util/retry.py:400:
728_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
729
730tp = <class 'urllib3.exceptions.ProtocolError'>, value = None, tb = None
731
732 def reraise(tp, value, tb=None):
733 try:
734 if value is None:
735 value = tp()
736 if value.__traceback__ is not tb:
737> raise value.with_traceback(tb)
738
739../env/lib/python3.7/site-packages/urllib3/packages/six.py:734:
740_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
741
742self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1dda20>, method = 'POST'
743url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D', body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>
744headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}, retries = Retry(total=0, connect=None, read=False, redirect=None, status=None)
745redirect = False, assert_same_host = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa19a518>, pool_timeout = None, release_conn = False, chunked = False, body_pos = 0, response_kw = {'decode_content': False, 'preload_content': False}, conn = None
746release_this_conn = True, err = None, clean_exit = False, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff320>, is_new_proxy_conn = False
747
748 def urlopen(
749 self,
750 method,
751 url,
752 body=None,
753 headers=None,
754 retries=None,
755 redirect=True,
756 assert_same_host=True,
757 timeout=_Default,
758 pool_timeout=None,
759 release_conn=None,
760 chunked=False,
761 body_pos=None,
762 **response_kw
763 ):
764 """
765 Get a connection from the pool and perform an HTTP request. This is the
766 lowest level call for making a request, so you'll need to specify all
767 the raw details.
768
769 .. note::
770
771 More commonly, it's appropriate to use a convenience method provided
772 by :class:`.RequestMethods`, such as :meth:`request`.
773
774 .. note::
775
776 `release_conn` will only behave as expected if
777 `preload_content=False` because we want to make
778 `preload_content=False` the default behaviour someday soon without
779 breaking backwards compatibility.
780
781 :param method:
782 HTTP request method (such as GET, POST, PUT, etc.)
783
784 :param body:
785 Data to send in the request body (useful for creating
786 POST requests, see HTTPConnectionPool.post_url for
787 more convenience).
788
789 :param headers:
790 Dictionary of custom headers to send, such as User-Agent,
791 If-None-Match, etc. If None, pool headers are used. If provided,
792 these headers completely replace any pool-specific headers.
793
794 :param retries:
795 Configure the number of retries to allow before raising a
796 :class:`~urllib3.exceptions.MaxRetryError` exception.
797
798 Pass ``None`` to retry until you receive a response. Pass a
799 :class:`~urllib3.util.retry.Retry` object for fine-grained control
800 over different types of retries.
801 Pass an integer number to retry connection errors that many times,
802 but no other types of errors. Pass zero to never retry.
803
804 If ``False``, then retries are disabled and any exception is raised
805 immediately. Also, instead of raising a MaxRetryError on redirects,
806 the redirect response will be returned.
807
808 :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
809
810 :param redirect:
811 If True, automatically handle redirects (status codes 301, 302,
812 303, 307, 308). Each redirect counts as a retry. Disabling retries
813 will disable redirect, too.
814
815 :param assert_same_host:
816 If ``True``, will make sure that the host of the pool requests is
817 consistent else will raise HostChangedError. When False, you can
818 use the pool on an HTTP proxy and request foreign hosts.
819
820 :param timeout:
821 If specified, overrides the default timeout for this one
822 request. It may be a float (in seconds) or an instance of
823 :class:`urllib3.util.Timeout`.
824
825 :param pool_timeout:
826 If set and the pool is set to block=True, then this method will
827 block for ``pool_timeout`` seconds and raise EmptyPoolError if no
828 connection is available within the time period.
829
830 :param release_conn:
831 If False, then the urlopen call will not release the connection
832 back into the pool once a response is received (but will release if
833 you read the entire contents of the response such as when
834 `preload_content=True`). This is useful if you're not preloading
835 the response's content immediately. You will need to call
836 ``r.release_conn()`` on the response ``r`` to return the connection
837 back into the pool. If None, it takes the value of
838 ``response_kw.get('preload_content', True)``.
839
840 :param chunked:
841 If True, urllib3 will send the body using chunked transfer
842 encoding. Otherwise, urllib3 will send the body using the standard
843 content-length form. Defaults to False.
844
845 :param int body_pos:
846 Position to seek to in file-like body in the event of a retry or
847 redirect. Typically this won't need to be set because urllib3 will
848 auto-populate the value when needed.
849
850 :param \\**response_kw:
851 Additional parameters are passed to
852 :meth:`urllib3.response.HTTPResponse.from_httplib`
853 """
854 if headers is None:
855 headers = self.headers
856
857 if not isinstance(retries, Retry):
858 retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
859
860 if release_conn is None:
861 release_conn = response_kw.get("preload_content", True)
862
863 # Check host
864 if assert_same_host and not self.is_same_host(url):
865 raise HostChangedError(self, url, retries)
866
867 # Ensure that the URL we're connecting to is properly encoded
868 if url.startswith("/"):
869 url = six.ensure_str(_encode_target(url))
870 else:
871 url = six.ensure_str(parse_url(url).url)
872
873 conn = None
874
875 # Track whether `conn` needs to be released before
876 # returning/raising/recursing. Update this variable if necessary, and
877 # leave `release_conn` constant throughout the function. That way, if
878 # the function recurses, the original value of `release_conn` will be
879 # passed down into the recursive call, and its value will be respected.
880 #
881 # See issue #651 [1] for details.
882 #
883 # [1] <https://github.com/shazow/urllib3/issues/651>
884 release_this_conn = release_conn
885
886 # Merge the proxy headers. Only do this in HTTP. We have to copy the
887 # headers dict so we can safely change it without those changes being
888 # reflected in anyone else's copy.
889 if self.scheme == "http":
890 headers = headers.copy()
891 headers.update(self.proxy_headers)
892
893 # Must keep the exception bound to a separate variable or else Python 3
894 # complains about UnboundLocalError.
895 err = None
896
897 # Keep track of whether we cleanly exited the except block. This
898 # ensures we do proper cleanup in finally.
899 clean_exit = False
900
901 # Rewind body position, if needed. Record current position
902 # for future rewinds in the event of a redirect/retry.
903 body_pos = set_file_position(body, body_pos)
904
905 try:
906 # Request a connection from the queue.
907 timeout_obj = self._get_timeout(timeout)
908 conn = self._get_conn(timeout=pool_timeout)
909
910 conn.timeout = timeout_obj.connect_timeout
911
912 is_new_proxy_conn = self.proxy is not None and not getattr(
913 conn, "sock", None
914 )
915 if is_new_proxy_conn:
916 self._prepare_proxy(conn)
917
918 # Make the request on the httplib connection object.
919 httplib_response = self._make_request(
920 conn,
921 method,
922 url,
923 timeout=timeout_obj,
924 body=body,
925 headers=headers,
926> chunked=chunked,
927 )
928
929../env/lib/python3.7/site-packages/urllib3/connectionpool.py:672:
930_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
931
932self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1dda20>, conn = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, method = 'POST'
933url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D', timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff320>, chunked = False
934httplib_request_kw = {'body': <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, 'headers': {'User-Agent': 'docker-sdk-python/4.1.0... deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}}
935timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ffba8>
936
937 def _make_request(
938 self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw
939 ):
940 """
941 Perform a request on a given urllib connection object taken from our
942 pool.
943
944 :param conn:
945 a connection from one of our connection pools
946
947 :param timeout:
948 Socket timeout in seconds for the request. This can be a
949 float or integer, which will set the same timeout value for
950 the socket connect and the socket read, or an instance of
951 :class:`urllib3.util.Timeout`, which gives you more fine-grained
952 control over your timeouts.
953 """
954 self.num_requests += 1
955
956 timeout_obj = self._get_timeout(timeout)
957 timeout_obj.start_connect()
958 conn.timeout = timeout_obj.connect_timeout
959
960 # Trigger any extra validation we need to do.
961 try:
962 self._validate_conn(conn)
963 except (SocketTimeout, BaseSSLError) as e:
964 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
965 self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
966 raise
967
968 # conn.request() calls httplib.*.request, not the method in
969 # urllib3.request. It also calls makefile (recv) on the socket.
970 if chunked:
971 conn.request_chunked(method, url, **httplib_request_kw)
972 else:
973> conn.request(method, url, **httplib_request_kw)
974
975../env/lib/python3.7/site-packages/urllib3/connectionpool.py:387:
976_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
977
978self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, method = 'POST', url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D'
979body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}
980
981 def request(self, method, url, body=None, headers={}, *,
982 encode_chunked=False):
983 """Send a complete request to the server."""
984> self._send_request(method, url, body, headers, encode_chunked)
985
986/usr/lib/python3.7/http/client.py:1244:
987_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
988
989self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, method = 'POST', url = '/v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sourceCode.java%22%2C+%22stdinfpath%22%3A+%22input.txt%22%7D'
990body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/tar', 'Content-Length': '491520'}
991encode_chunked = False
992
993 def _send_request(self, method, url, body, headers, encode_chunked):
994 # Honor explicitly requested Host: and Accept-Encoding: headers.
995 header_names = frozenset(k.lower() for k in headers)
996 skips = {}
997 if 'host' in header_names:
998 skips['skip_host'] = 1
999 if 'accept-encoding' in header_names:
1000 skips['skip_accept_encoding'] = 1
1001
1002 self.putrequest(method, url, **skips)
1003
1004 # chunked encoding will happen if HTTP/1.1 is used and either
1005 # the caller passes encode_chunked=True or the following
1006 # conditions hold:
1007 # 1. content-length has not been explicitly set
1008 # 2. the body is a file or iterable, but not a str or bytes-like
1009 # 3. Transfer-Encoding has NOT been explicitly set by the caller
1010
1011 if 'content-length' not in header_names:
1012 # only chunk body if not explicitly set for backwards
1013 # compatibility, assuming the client code is already handling the
1014 # chunking
1015 if 'transfer-encoding' not in header_names:
1016 # if content-length cannot be automatically determined, fall
1017 # back to chunked encoding
1018 encode_chunked = False
1019 content_length = self._get_content_length(body, method)
1020 if content_length is None:
1021 if body is not None:
1022 if self.debuglevel > 0:
1023 print('Unable to determine size of %r' % body)
1024 encode_chunked = True
1025 self.putheader('Transfer-Encoding', 'chunked')
1026 else:
1027 self.putheader('Content-Length', str(content_length))
1028 else:
1029 encode_chunked = False
1030
1031 for hdr, value in headers.items():
1032 self.putheader(hdr, value)
1033 if isinstance(body, str):
1034 # RFC 2616 Section 3.7.1 says that text default has a
1035 # default charset of iso-8859-1.
1036 body = _encode(body, 'body')
1037> self.endheaders(body, encode_chunked=encode_chunked)
1038
1039/usr/lib/python3.7/http/client.py:1290:
1040_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1041
1042self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, message_body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>
1043
1044 def endheaders(self, message_body=None, *, encode_chunked=False):
1045 """Indicate that the last header line has been sent to the server.
1046
1047 This method sends the request to the server. The optional message_body
1048 argument can be used to pass a message body associated with the
1049 request.
1050 """
1051 if self.__state == _CS_REQ_STARTED:
1052 self.__state = _CS_REQ_SENT
1053 else:
1054 raise CannotSendHeader()
1055> self._send_output(message_body, encode_chunked=encode_chunked)
1056
1057/usr/lib/python3.7/http/client.py:1239:
1058_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1059
1060self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>, message_body = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, encode_chunked = False
1061
1062 def _send_output(self, message_body=None, encode_chunked=False):
1063 """Send the currently buffered request and clear the buffer.
1064
1065 Appends an extra \\r\\n to the buffer.
1066 A message_body may be specified, to be appended to the request.
1067 """
1068 self._buffer.extend((b"", b""))
1069 msg = b"\r\n".join(self._buffer)
1070 del self._buffer[:]
1071> self.send(msg)
1072
1073/usr/lib/python3.7/http/client.py:1026:
1074_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1075
1076self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>
1077data = b'POST /v1.35/build?t=runner&q=False&nocache=False&rm=True&forcerm=False&pull=False&buildargs=%7B%22fpath%22%3A+%22sou...p, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: application/tar\r\nContent-Length: 491520\r\n\r\n'
1078
1079 def send(self, data):
1080 """Send `data' to the server.
1081 ``data`` can be a string object, a bytes object, an array object, a
1082 file-like object that supports a .read() method, or an iterable object.
1083 """
1084
1085 if self.sock is None:
1086 if self.auto_open:
1087> self.connect()
1088
1089/usr/lib/python3.7/http/client.py:966:
1090_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1091
1092self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ffa20>
1093
1094 def connect(self):
1095 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
1096 sock.settimeout(self.timeout)
1097> sock.connect(self.unix_socket)
1098E urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))
1099
1100../env/lib/python3.7/site-packages/docker/transport/unixconn.py:43: ProtocolError
1101
1102During handling of the above exception, another exception occurred:
1103
1104codefpath = '/home/slid3rek/Dokumenty/MWO/iwsoj/iwsoj/iwsoj/tmp/sourceCode.java', stdinfpath = '/home/slid3rek/Dokumenty/MWO/iwsoj/iwsoj/iwsoj/tmp/input.txt'
1105
1106 def soSorryYouLose(codefpath: str, stdinfpath: str) -> str:
1107 """
1108 Executes the
1109 :param codefpath: The path to the code to be run
1110 :param stdinfpath: The path to the input file
1111 :return: stdout of both the compile and the run step of the file in question
1112 """
1113
1114 imagetag = "runner"
1115 lang = Lang.from_file(codefpath)
1116
1117 dockerfile_path = get_dockerfile_dir(lang)
1118 dockerc = docker.from_env()
1119
1120 try:
1121 ctx2cwd(dockerfile_path, codefpath, stdinfpath)
1122 short_codefname = os.path.basename(codefpath)
1123 short_stdinfname = os.path.basename(stdinfpath)
1124> dockerc.images.build(path=os.getcwd(), buildargs={"fpath": short_codefname, "stdinfpath": short_stdinfname}, tag=imagetag, rm=True)
1125
1126runner/runner.py:105:
1127_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1128
1129self = <docker.models.images.ImageCollection object at 0x7f07a9ff7eb8>, kwargs = {'buildargs': {'fpath': 'sourceCode.java', 'stdinfpath': 'input.txt'}, 'path': '/home/slid3rek/Dokumenty/MWO/iwsoj/iwsoj/iwsoj', 'rm': True, 'tag': 'runner'}
1130
1131 def build(self, **kwargs):
1132 """
1133 Build an image and return it. Similar to the ``docker build``
1134 command. Either ``path`` or ``fileobj`` must be set.
1135
1136 If you have a tar file for the Docker build context (including a
1137 Dockerfile) already, pass a readable file-like object to ``fileobj``
1138 and also pass ``custom_context=True``. If the stream is compressed
1139 also, set ``encoding`` to the correct value (e.g ``gzip``).
1140
1141 If you want to get the raw output of the build, use the
1142 :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
1143 low-level API.
1144
1145 Args:
1146 path (str): Path to the directory containing the Dockerfile
1147 fileobj: A file object to use as the Dockerfile. (Or a file-like
1148 object)
1149 tag (str): A tag to add to the final image
1150 quiet (bool): Whether to return the status
1151 nocache (bool): Don't use the cache when set to ``True``
1152 rm (bool): Remove intermediate containers. The ``docker build``
1153 command now defaults to ``--rm=true``, but we have kept the old
1154 default of `False` to preserve backward compatibility
1155 timeout (int): HTTP timeout
1156 custom_context (bool): Optional if using ``fileobj``
1157 encoding (str): The encoding for a stream. Set to ``gzip`` for
1158 compressing
1159 pull (bool): Downloads any updates to the FROM image in Dockerfiles
1160 forcerm (bool): Always remove intermediate containers, even after
1161 unsuccessful builds
1162 dockerfile (str): path within the build context to the Dockerfile
1163 buildargs (dict): A dictionary of build arguments
1164 container_limits (dict): A dictionary of limits applied to each
1165 container created by the build process. Valid keys:
1166
1167 - memory (int): set memory limit for build
1168 - memswap (int): Total memory (memory + swap), -1 to disable
1169 swap
1170 - cpushares (int): CPU shares (relative weight)
1171 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
1172 ``"0-3"``, ``"0,1"``
1173 shmsize (int): Size of `/dev/shm` in bytes. The size must be
1174 greater than 0. If omitted the system uses 64MB
1175 labels (dict): A dictionary of labels to set on the image
1176 cache_from (list): A list of images used for build cache
1177 resolution
1178 target (str): Name of the build-stage to build in a multi-stage
1179 Dockerfile
1180 network_mode (str): networking mode for the run commands during
1181 build
1182 squash (bool): Squash the resulting images layers into a
1183 single layer.
1184 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
1185 containers, as a mapping of hostname to IP address.
1186 platform (str): Platform in the format ``os[/arch[/variant]]``.
1187 isolation (str): Isolation technology used during build.
1188 Default: `None`.
1189 use_config_proxy (bool): If ``True``, and if the docker client
1190 configuration file (``~/.docker/config.json`` by default)
1191 contains a proxy configuration, the corresponding environment
1192 variables will be set in the container being built.
1193
1194 Returns:
1195 (tuple): The first item is the :py:class:`Image` object for the
1196 image that was build. The second item is a generator of the
1197 build logs as JSON-decoded objects.
1198
1199 Raises:
1200 :py:class:`docker.errors.BuildError`
1201 If there is an error during the build.
1202 :py:class:`docker.errors.APIError`
1203 If the server returns any other error.
1204 ``TypeError``
1205 If neither ``path`` nor ``fileobj`` is specified.
1206 """
1207> resp = self.client.api.build(**kwargs)
1208
1209../env/lib/python3.7/site-packages/docker/models/images.py:279:
1210_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1211
1212self = <docker.api.client.APIClient object at 0x7f07a9ff7cc0>, path = '/home/slid3rek/Dokumenty/MWO/iwsoj/iwsoj/iwsoj', tag = 'runner', quiet = False, fileobj = None, nocache = False, rm = True, timeout = None, custom_context = False, encoding = None, pull = False
1213forcerm = False, dockerfile = (None, None), container_limits = {}, decode = False, buildargs = {'fpath': 'sourceCode.java', 'stdinfpath': 'input.txt'}, gzip = False, shmsize = None, labels = None, cache_from = None, target = None, network_mode = None, squash = None
1214extra_hosts = None, platform = None, isolation = None, use_config_proxy = True
1215
1216 def build(self, path=None, tag=None, quiet=False, fileobj=None,
1217 nocache=False, rm=False, timeout=None,
1218 custom_context=False, encoding=None, pull=False,
1219 forcerm=False, dockerfile=None, container_limits=None,
1220 decode=False, buildargs=None, gzip=False, shmsize=None,
1221 labels=None, cache_from=None, target=None, network_mode=None,
1222 squash=None, extra_hosts=None, platform=None, isolation=None,
1223 use_config_proxy=True):
1224 """
1225 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
1226 needs to be set. ``path`` can be a local path (to a directory
1227 containing a Dockerfile) or a remote URL. ``fileobj`` must be a
1228 readable file-like object to a Dockerfile.
1229
1230 If you have a tar file for the Docker build context (including a
1231 Dockerfile) already, pass a readable file-like object to ``fileobj``
1232 and also pass ``custom_context=True``. If the stream is compressed
1233 also, set ``encoding`` to the correct value (e.g ``gzip``).
1234
1235 Example:
1236 >>> from io import BytesIO
1237 >>> from docker import APIClient
1238 >>> dockerfile = '''
1239 ... # Shared Volume
1240 ... FROM busybox:buildroot-2014.02
1241 ... VOLUME /data
1242 ... CMD ["/bin/sh"]
1243 ... '''
1244 >>> f = BytesIO(dockerfile.encode('utf-8'))
1245 >>> cli = APIClient(base_url='tcp://127.0.0.1:2375')
1246 >>> response = [line for line in cli.build(
1247 ... fileobj=f, rm=True, tag='yourname/volume'
1248 ... )]
1249 >>> response
1250 ['{"stream":" ---\\u003e a9eb17255234\\n"}',
1251 '{"stream":"Step 1 : VOLUME /data\\n"}',
1252 '{"stream":" ---\\u003e Running in abdc1e6896c6\\n"}',
1253 '{"stream":" ---\\u003e 713bca62012e\\n"}',
1254 '{"stream":"Removing intermediate container abdc1e6896c6\\n"}',
1255 '{"stream":"Step 2 : CMD [\\"/bin/sh\\"]\\n"}',
1256 '{"stream":" ---\\u003e Running in dba30f2a1a7e\\n"}',
1257 '{"stream":" ---\\u003e 032b8b2855fc\\n"}',
1258 '{"stream":"Removing intermediate container dba30f2a1a7e\\n"}',
1259 '{"stream":"Successfully built 032b8b2855fc\\n"}']
1260
1261 Args:
1262 path (str): Path to the directory containing the Dockerfile
1263 fileobj: A file object to use as the Dockerfile. (Or a file-like
1264 object)
1265 tag (str): A tag to add to the final image
1266 quiet (bool): Whether to return the status
1267 nocache (bool): Don't use the cache when set to ``True``
1268 rm (bool): Remove intermediate containers. The ``docker build``
1269 command now defaults to ``--rm=true``, but we have kept the old
1270 default of `False` to preserve backward compatibility
1271 timeout (int): HTTP timeout
1272 custom_context (bool): Optional if using ``fileobj``
1273 encoding (str): The encoding for a stream. Set to ``gzip`` for
1274 compressing
1275 pull (bool): Downloads any updates to the FROM image in Dockerfiles
1276 forcerm (bool): Always remove intermediate containers, even after
1277 unsuccessful builds
1278 dockerfile (str): path within the build context to the Dockerfile
1279 buildargs (dict): A dictionary of build arguments
1280 container_limits (dict): A dictionary of limits applied to each
1281 container created by the build process. Valid keys:
1282
1283 - memory (int): set memory limit for build
1284 - memswap (int): Total memory (memory + swap), -1 to disable
1285 swap
1286 - cpushares (int): CPU shares (relative weight)
1287 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
1288 ``"0-3"``, ``"0,1"``
1289 decode (bool): If set to ``True``, the returned stream will be
1290 decoded into dicts on the fly. Default ``False``
1291 shmsize (int): Size of `/dev/shm` in bytes. The size must be
1292 greater than 0. If omitted the system uses 64MB
1293 labels (dict): A dictionary of labels to set on the image
1294 cache_from (:py:class:`list`): A list of images used for build
1295 cache resolution
1296 target (str): Name of the build-stage to build in a multi-stage
1297 Dockerfile
1298 network_mode (str): networking mode for the run commands during
1299 build
1300 squash (bool): Squash the resulting images layers into a
1301 single layer.
1302 extra_hosts (dict): Extra hosts to add to /etc/hosts in building
1303 containers, as a mapping of hostname to IP address.
1304 platform (str): Platform in the format ``os[/arch[/variant]]``
1305 isolation (str): Isolation technology used during build.
1306 Default: `None`.
1307 use_config_proxy (bool): If ``True``, and if the docker client
1308 configuration file (``~/.docker/config.json`` by default)
1309 contains a proxy configuration, the corresponding environment
1310 variables will be set in the container being built.
1311
1312 Returns:
1313 A generator for the build output.
1314
1315 Raises:
1316 :py:class:`docker.errors.APIError`
1317 If the server returns an error.
1318 ``TypeError``
1319 If neither ``path`` nor ``fileobj`` is specified.
1320 """
1321 remote = context = None
1322 headers = {}
1323 container_limits = container_limits or {}
1324 buildargs = buildargs or {}
1325 if path is None and fileobj is None:
1326 raise TypeError("Either path or fileobj needs to be provided.")
1327 if gzip and encoding is not None:
1328 raise errors.DockerException(
1329 'Can not use custom encoding if gzip is enabled'
1330 )
1331
1332 for key in container_limits.keys():
1333 if key not in constants.CONTAINER_LIMITS_KEYS:
1334 raise errors.DockerException(
1335 'Invalid container_limits key {0}'.format(key)
1336 )
1337
1338 if custom_context:
1339 if not fileobj:
1340 raise TypeError("You must specify fileobj with custom_context")
1341 context = fileobj
1342 elif fileobj is not None:
1343 context = utils.mkbuildcontext(fileobj)
1344 elif path.startswith(('http://', 'https://',
1345 'git://', 'github.com/', 'git@')):
1346 remote = path
1347 elif not os.path.isdir(path):
1348 raise TypeError("You must specify a directory to build in path")
1349 else:
1350 dockerignore = os.path.join(path, '.dockerignore')
1351 exclude = None
1352 if os.path.exists(dockerignore):
1353 with open(dockerignore, 'r') as f:
1354 exclude = list(filter(
1355 lambda x: x != '' and x[0] != '#',
1356 [l.strip() for l in f.read().splitlines()]
1357 ))
1358 dockerfile = process_dockerfile(dockerfile, path)
1359 context = utils.tar(
1360 path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
1361 )
1362 encoding = 'gzip' if gzip else encoding
1363
1364 u = self._url('/build')
1365 params = {
1366 't': tag,
1367 'remote': remote,
1368 'q': quiet,
1369 'nocache': nocache,
1370 'rm': rm,
1371 'forcerm': forcerm,
1372 'pull': pull,
1373 'dockerfile': dockerfile,
1374 }
1375 params.update(container_limits)
1376
1377 if use_config_proxy:
1378 proxy_args = self._proxy_configs.get_environment()
1379 for k, v in proxy_args.items():
1380 buildargs.setdefault(k, v)
1381 if buildargs:
1382 params.update({'buildargs': json.dumps(buildargs)})
1383
1384 if shmsize:
1385 if utils.version_gte(self._version, '1.22'):
1386 params.update({'shmsize': shmsize})
1387 else:
1388 raise errors.InvalidVersion(
1389 'shmsize was only introduced in API version 1.22'
1390 )
1391
1392 if labels:
1393 if utils.version_gte(self._version, '1.23'):
1394 params.update({'labels': json.dumps(labels)})
1395 else:
1396 raise errors.InvalidVersion(
1397 'labels was only introduced in API version 1.23'
1398 )
1399
1400 if cache_from:
1401 if utils.version_gte(self._version, '1.25'):
1402 params.update({'cachefrom': json.dumps(cache_from)})
1403 else:
1404 raise errors.InvalidVersion(
1405 'cache_from was only introduced in API version 1.25'
1406 )
1407
1408 if target:
1409 if utils.version_gte(self._version, '1.29'):
1410 params.update({'target': target})
1411 else:
1412 raise errors.InvalidVersion(
1413 'target was only introduced in API version 1.29'
1414 )
1415
1416 if network_mode:
1417 if utils.version_gte(self._version, '1.25'):
1418 params.update({'networkmode': network_mode})
1419 else:
1420 raise errors.InvalidVersion(
1421 'network_mode was only introduced in API version 1.25'
1422 )
1423
1424 if squash:
1425 if utils.version_gte(self._version, '1.25'):
1426 params.update({'squash': squash})
1427 else:
1428 raise errors.InvalidVersion(
1429 'squash was only introduced in API version 1.25'
1430 )
1431
1432 if extra_hosts is not None:
1433 if utils.version_lt(self._version, '1.27'):
1434 raise errors.InvalidVersion(
1435 'extra_hosts was only introduced in API version 1.27'
1436 )
1437
1438 if isinstance(extra_hosts, dict):
1439 extra_hosts = utils.format_extra_hosts(extra_hosts)
1440 params.update({'extrahosts': extra_hosts})
1441
1442 if platform is not None:
1443 if utils.version_lt(self._version, '1.32'):
1444 raise errors.InvalidVersion(
1445 'platform was only introduced in API version 1.32'
1446 )
1447 params['platform'] = platform
1448
1449 if isolation is not None:
1450 if utils.version_lt(self._version, '1.24'):
1451 raise errors.InvalidVersion(
1452 'isolation was only introduced in API version 1.24'
1453 )
1454 params['isolation'] = isolation
1455
1456 if context is not None:
1457 headers = {'Content-Type': 'application/tar'}
1458 if encoding:
1459 headers['Content-Encoding'] = encoding
1460
1461 self._set_auth_headers(headers)
1462
1463 response = self._post(
1464 u,
1465 data=context,
1466 params=params,
1467 headers=headers,
1468 stream=True,
1469> timeout=timeout,
1470 )
1471
1472../env/lib/python3.7/site-packages/docker/api/build.py:269:
1473_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1474
1475self = <docker.api.client.APIClient object at 0x7f07a9ff7cc0>, args = ('http+docker://localhost/v1.35/build',)
1476kwargs = {'data': <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, 'headers': {'Content-Type': 'application/tar'}, 'p..."stdinfpath": "input.txt"}', 'dockerfile': (None, None), 'forcerm': False, 'nocache': False, ...}, 'stream': True, ...}
1477
1478 def inner(self, *args, **kwargs):
1479 if 'HttpHeaders' in self._general_configs:
1480 if not kwargs.get('headers'):
1481 kwargs['headers'] = self._general_configs['HttpHeaders']
1482 else:
1483 kwargs['headers'].update(self._general_configs['HttpHeaders'])
1484> return f(self, *args, **kwargs)
1485
1486../env/lib/python3.7/site-packages/docker/utils/decorators.py:46:
1487_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1488
1489self = <docker.api.client.APIClient object at 0x7f07a9ff7cc0>, url = 'http+docker://localhost/v1.35/build'
1490kwargs = {'data': <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, 'headers': {'Content-Type': 'application/tar'}, 'p..."stdinfpath": "input.txt"}', 'dockerfile': (None, None), 'forcerm': False, 'nocache': False, ...}, 'stream': True, ...}
1491
1492 @update_headers
1493 def _post(self, url, **kwargs):
1494> return self.post(url, **self._set_request_timeout(kwargs))
1495
1496../env/lib/python3.7/site-packages/docker/api/client.py:226:
1497_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1498
1499self = <docker.api.client.APIClient object at 0x7f07a9ff7cc0>, url = 'http+docker://localhost/v1.35/build', data = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, json = None
1500kwargs = {'headers': {'Content-Type': 'application/tar'}, 'params': {'buildargs': '{"fpath": "sourceCode.java", "stdinfpath": "input.txt"}', 'dockerfile': (None, None), 'forcerm': False, 'nocache': False, ...}, 'stream': True, 'timeout': None}
1501
1502 def post(self, url, data=None, json=None, **kwargs):
1503 r"""Sends a POST request. Returns :class:`Response` object.
1504
1505 :param url: URL for the new :class:`Request` object.
1506 :param data: (optional) Dictionary, list of tuples, bytes, or file-like
1507 object to send in the body of the :class:`Request`.
1508 :param json: (optional) json to send in the body of the :class:`Request`.
1509 :param \*\*kwargs: Optional arguments that ``request`` takes.
1510 :rtype: requests.Response
1511 """
1512
1513> return self.request('POST', url, data=data, json=json, **kwargs)
1514
1515../env/lib/python3.7/site-packages/requests/sessions.py:581:
1516_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1517
1518self = <docker.api.client.APIClient object at 0x7f07a9ff7cc0>, method = 'POST', url = 'http+docker://localhost/v1.35/build', params = {'buildargs': '{"fpath": "sourceCode.java", "stdinfpath": "input.txt"}', 'dockerfile': (None, None), 'forcerm': False, 'nocache': False, ...}
1519data = <tempfile._TemporaryFileWrapper object at 0x7f07a9ff7d30>, headers = {'Content-Type': 'application/tar'}, cookies = None, files = None, auth = None, timeout = None, allow_redirects = True, proxies = {}, hooks = None, stream = True, verify = None, cert = None
1520json = None
1521
1522 def request(self, method, url,
1523 params=None, data=None, headers=None, cookies=None, files=None,
1524 auth=None, timeout=None, allow_redirects=True, proxies=None,
1525 hooks=None, stream=None, verify=None, cert=None, json=None):
1526 """Constructs a :class:`Request <Request>`, prepares it and sends it.
1527 Returns :class:`Response <Response>` object.
1528
1529 :param method: method for the new :class:`Request` object.
1530 :param url: URL for the new :class:`Request` object.
1531 :param params: (optional) Dictionary or bytes to be sent in the query
1532 string for the :class:`Request`.
1533 :param data: (optional) Dictionary, list of tuples, bytes, or file-like
1534 object to send in the body of the :class:`Request`.
1535 :param json: (optional) json to send in the body of the
1536 :class:`Request`.
1537 :param headers: (optional) Dictionary of HTTP Headers to send with the
1538 :class:`Request`.
1539 :param cookies: (optional) Dict or CookieJar object to send with the
1540 :class:`Request`.
1541 :param files: (optional) Dictionary of ``'filename': file-like-objects``
1542 for multipart encoding upload.
1543 :param auth: (optional) Auth tuple or callable to enable
1544 Basic/Digest/Custom HTTP Auth.
1545 :param timeout: (optional) How long to wait for the server to send
1546 data before giving up, as a float, or a :ref:`(connect timeout,
1547 read timeout) <timeouts>` tuple.
1548 :type timeout: float or tuple
1549 :param allow_redirects: (optional) Set to True by default.
1550 :type allow_redirects: bool
1551 :param proxies: (optional) Dictionary mapping protocol or protocol and
1552 hostname to the URL of the proxy.
1553 :param stream: (optional) whether to immediately download the response
1554 content. Defaults to ``False``.
1555 :param verify: (optional) Either a boolean, in which case it controls whether we verify
1556 the server's TLS certificate, or a string, in which case it must be a path
1557 to a CA bundle to use. Defaults to ``True``.
1558 :param cert: (optional) if String, path to ssl client cert file (.pem).
1559 If Tuple, ('cert', 'key') pair.
1560 :rtype: requests.Response
1561 """
1562 # Create the Request.
1563 req = Request(
1564 method=method.upper(),
1565 url=url,
1566 headers=headers,
1567 files=files,
1568 data=data or {},
1569 json=json,
1570 params=params or {},
1571 auth=auth,
1572 cookies=cookies,
1573 hooks=hooks,
1574 )
1575 prep = self.prepare_request(req)
1576
1577 proxies = proxies or {}
1578
1579 settings = self.merge_environment_settings(
1580 prep.url, proxies, stream, verify, cert
1581 )
1582
1583 # Send the request.
1584 send_kwargs = {
1585 'timeout': timeout,
1586 'allow_redirects': allow_redirects,
1587 }
1588 send_kwargs.update(settings)
1589> resp = self.send(prep, **send_kwargs)
1590
1591../env/lib/python3.7/site-packages/requests/sessions.py:533:
1592_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1593
1594self = <docker.api.client.APIClient object at 0x7f07a9ff7cc0>, request = <PreparedRequest [POST]>, kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': True, 'timeout': None, ...}, allow_redirects = True, stream = True, hooks = {'response': []}
1595adapter = <docker.transport.unixconn.UnixHTTPAdapter object at 0x7f07a9ff7f60>, start = 1572391381.9525895
1596
1597 def send(self, request, **kwargs):
1598 """Send a given PreparedRequest.
1599
1600 :rtype: requests.Response
1601 """
1602 # Set defaults that the hooks can utilize to ensure they always have
1603 # the correct parameters to reproduce the previous request.
1604 kwargs.setdefault('stream', self.stream)
1605 kwargs.setdefault('verify', self.verify)
1606 kwargs.setdefault('cert', self.cert)
1607 kwargs.setdefault('proxies', self.proxies)
1608
1609 # It's possible that users might accidentally send a Request object.
1610 # Guard against that specific failure case.
1611 if isinstance(request, Request):
1612 raise ValueError('You can only send PreparedRequests.')
1613
1614 # Set up variables needed for resolve_redirects and dispatching of hooks
1615 allow_redirects = kwargs.pop('allow_redirects', True)
1616 stream = kwargs.get('stream')
1617 hooks = request.hooks
1618
1619 # Get the appropriate adapter to use
1620 adapter = self.get_adapter(url=request.url)
1621
1622 # Start time (approximately) of the request
1623 start = preferred_clock()
1624
1625 # Send the request
1626> r = adapter.send(request, **kwargs)
1627
1628../env/lib/python3.7/site-packages/requests/sessions.py:646:
1629_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1630
1631self = <docker.transport.unixconn.UnixHTTPAdapter object at 0x7f07a9ff7f60>, request = <PreparedRequest [POST]>, stream = True, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa19a518>, verify = True, cert = None, proxies = OrderedDict()
1632
1633 def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
1634 """Sends PreparedRequest object. Returns Response object.
1635
1636 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
1637 :param stream: (optional) Whether to stream the request content.
1638 :param timeout: (optional) How long to wait for the server to send
1639 data before giving up, as a float, or a :ref:`(connect timeout,
1640 read timeout) <timeouts>` tuple.
1641 :type timeout: float or tuple or urllib3 Timeout object
1642 :param verify: (optional) Either a boolean, in which case it controls whether
1643 we verify the server's TLS certificate, or a string, in which case it
1644 must be a path to a CA bundle to use
1645 :param cert: (optional) Any user-provided SSL certificate to be trusted.
1646 :param proxies: (optional) The proxies dictionary to apply to the request.
1647 :rtype: requests.Response
1648 """
1649
1650 try:
1651 conn = self.get_connection(request.url, proxies)
1652 except LocationValueError as e:
1653 raise InvalidURL(e, request=request)
1654
1655 self.cert_verify(conn, request.url, verify, cert)
1656 url = self.request_url(request, proxies)
1657 self.add_headers(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
1658
1659 chunked = not (request.body is None or 'Content-Length' in request.headers)
1660
1661 if isinstance(timeout, tuple):
1662 try:
1663 connect, read = timeout
1664 timeout = TimeoutSauce(connect=connect, read=read)
1665 except ValueError as e:
1666 # this may raise a string formatting error.
1667 err = ("Invalid timeout {}. Pass a (connect, read) "
1668 "timeout tuple, or a single float to set "
1669 "both timeouts to the same value".format(timeout))
1670 raise ValueError(err)
1671 elif isinstance(timeout, TimeoutSauce):
1672 pass
1673 else:
1674 timeout = TimeoutSauce(connect=timeout, read=timeout)
1675
1676 try:
1677 if not chunked:
1678 resp = conn.urlopen(
1679 method=request.method,
1680 url=url,
1681 body=request.body,
1682 headers=request.headers,
1683 redirect=False,
1684 assert_same_host=False,
1685 preload_content=False,
1686 decode_content=False,
1687 retries=self.max_retries,
1688 timeout=timeout
1689 )
1690
1691 # Send the request.
1692 else:
1693 if hasattr(conn, 'proxy_pool'):
1694 conn = conn.proxy_pool
1695
1696 low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)
1697
1698 try:
1699 low_conn.putrequest(request.method,
1700 url,
1701 skip_accept_encoding=True)
1702
1703 for header, value in request.headers.items():
1704 low_conn.putheader(header, value)
1705
1706 low_conn.endheaders()
1707
1708 for i in request.body:
1709 low_conn.send(hex(len(i))[2:].encode('utf-8'))
1710 low_conn.send(b'\r\n')
1711 low_conn.send(i)
1712 low_conn.send(b'\r\n')
1713 low_conn.send(b'0\r\n\r\n')
1714
1715 # Receive the response from the server
1716 try:
1717 # For Python 2.7, use buffering of HTTP responses
1718 r = low_conn.getresponse(buffering=True)
1719 except TypeError:
1720 # For compatibility with Python 3.3+
1721 r = low_conn.getresponse()
1722
1723 resp = HTTPResponse.from_httplib(
1724 r,
1725 pool=conn,
1726 connection=low_conn,
1727 preload_content=False,
1728 decode_content=False
1729 )
1730 except:
1731 # If we hit any problems here, clean up the connection.
1732 # Then, reraise so that we can handle the actual exception.
1733 low_conn.close()
1734 raise
1735
1736 except (ProtocolError, socket.error) as err:
1737> raise ConnectionError(err, request=request)
1738E requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))
1739
1740../env/lib/python3.7/site-packages/requests/adapters.py:498: ConnectionError
1741
1742During handling of the above exception, another exception occurred:
1743
1744self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1ff390>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', body = None
1745headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}, retries = Retry(total=0, connect=None, read=False, redirect=None, status=None), redirect = False
1746assert_same_host = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff048>, pool_timeout = None, release_conn = False, chunked = False, body_pos = None, response_kw = {'decode_content': False, 'preload_content': False}, conn = None, release_this_conn = True
1747err = None, clean_exit = False, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff6a0>, is_new_proxy_conn = False
1748
1749 def urlopen(
1750 self,
1751 method,
1752 url,
1753 body=None,
1754 headers=None,
1755 retries=None,
1756 redirect=True,
1757 assert_same_host=True,
1758 timeout=_Default,
1759 pool_timeout=None,
1760 release_conn=None,
1761 chunked=False,
1762 body_pos=None,
1763 **response_kw
1764 ):
1765 """
1766 Get a connection from the pool and perform an HTTP request. This is the
1767 lowest level call for making a request, so you'll need to specify all
1768 the raw details.
1769
1770 .. note::
1771
1772 More commonly, it's appropriate to use a convenience method provided
1773 by :class:`.RequestMethods`, such as :meth:`request`.
1774
1775 .. note::
1776
1777 `release_conn` will only behave as expected if
1778 `preload_content=False` because we want to make
1779 `preload_content=False` the default behaviour someday soon without
1780 breaking backwards compatibility.
1781
1782 :param method:
1783 HTTP request method (such as GET, POST, PUT, etc.)
1784
1785 :param body:
1786 Data to send in the request body (useful for creating
1787 POST requests, see HTTPConnectionPool.post_url for
1788 more convenience).
1789
1790 :param headers:
1791 Dictionary of custom headers to send, such as User-Agent,
1792 If-None-Match, etc. If None, pool headers are used. If provided,
1793 these headers completely replace any pool-specific headers.
1794
1795 :param retries:
1796 Configure the number of retries to allow before raising a
1797 :class:`~urllib3.exceptions.MaxRetryError` exception.
1798
1799 Pass ``None`` to retry until you receive a response. Pass a
1800 :class:`~urllib3.util.retry.Retry` object for fine-grained control
1801 over different types of retries.
1802 Pass an integer number to retry connection errors that many times,
1803 but no other types of errors. Pass zero to never retry.
1804
1805 If ``False``, then retries are disabled and any exception is raised
1806 immediately. Also, instead of raising a MaxRetryError on redirects,
1807 the redirect response will be returned.
1808
1809 :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
1810
1811 :param redirect:
1812 If True, automatically handle redirects (status codes 301, 302,
1813 303, 307, 308). Each redirect counts as a retry. Disabling retries
1814 will disable redirect, too.
1815
1816 :param assert_same_host:
1817 If ``True``, will make sure that the host of the pool requests is
1818 consistent else will raise HostChangedError. When False, you can
1819 use the pool on an HTTP proxy and request foreign hosts.
1820
1821 :param timeout:
1822 If specified, overrides the default timeout for this one
1823 request. It may be a float (in seconds) or an instance of
1824 :class:`urllib3.util.Timeout`.
1825
1826 :param pool_timeout:
1827 If set and the pool is set to block=True, then this method will
1828 block for ``pool_timeout`` seconds and raise EmptyPoolError if no
1829 connection is available within the time period.
1830
1831 :param release_conn:
1832 If False, then the urlopen call will not release the connection
1833 back into the pool once a response is received (but will release if
1834 you read the entire contents of the response such as when
1835 `preload_content=True`). This is useful if you're not preloading
1836 the response's content immediately. You will need to call
1837 ``r.release_conn()`` on the response ``r`` to return the connection
1838 back into the pool. If None, it takes the value of
1839 ``response_kw.get('preload_content', True)``.
1840
1841 :param chunked:
1842 If True, urllib3 will send the body using chunked transfer
1843 encoding. Otherwise, urllib3 will send the body using the standard
1844 content-length form. Defaults to False.
1845
1846 :param int body_pos:
1847 Position to seek to in file-like body in the event of a retry or
1848 redirect. Typically this won't need to be set because urllib3 will
1849 auto-populate the value when needed.
1850
1851 :param \\**response_kw:
1852 Additional parameters are passed to
1853 :meth:`urllib3.response.HTTPResponse.from_httplib`
1854 """
1855 if headers is None:
1856 headers = self.headers
1857
1858 if not isinstance(retries, Retry):
1859 retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
1860
1861 if release_conn is None:
1862 release_conn = response_kw.get("preload_content", True)
1863
1864 # Check host
1865 if assert_same_host and not self.is_same_host(url):
1866 raise HostChangedError(self, url, retries)
1867
1868 # Ensure that the URL we're connecting to is properly encoded
1869 if url.startswith("/"):
1870 url = six.ensure_str(_encode_target(url))
1871 else:
1872 url = six.ensure_str(parse_url(url).url)
1873
1874 conn = None
1875
1876 # Track whether `conn` needs to be released before
1877 # returning/raising/recursing. Update this variable if necessary, and
1878 # leave `release_conn` constant throughout the function. That way, if
1879 # the function recurses, the original value of `release_conn` will be
1880 # passed down into the recursive call, and its value will be respected.
1881 #
1882 # See issue #651 [1] for details.
1883 #
1884 # [1] <https://github.com/shazow/urllib3/issues/651>
1885 release_this_conn = release_conn
1886
1887 # Merge the proxy headers. Only do this in HTTP. We have to copy the
1888 # headers dict so we can safely change it without those changes being
1889 # reflected in anyone else's copy.
1890 if self.scheme == "http":
1891 headers = headers.copy()
1892 headers.update(self.proxy_headers)
1893
1894 # Must keep the exception bound to a separate variable or else Python 3
1895 # complains about UnboundLocalError.
1896 err = None
1897
1898 # Keep track of whether we cleanly exited the except block. This
1899 # ensures we do proper cleanup in finally.
1900 clean_exit = False
1901
1902 # Rewind body position, if needed. Record current position
1903 # for future rewinds in the event of a redirect/retry.
1904 body_pos = set_file_position(body, body_pos)
1905
1906 try:
1907 # Request a connection from the queue.
1908 timeout_obj = self._get_timeout(timeout)
1909 conn = self._get_conn(timeout=pool_timeout)
1910
1911 conn.timeout = timeout_obj.connect_timeout
1912
1913 is_new_proxy_conn = self.proxy is not None and not getattr(
1914 conn, "sock", None
1915 )
1916 if is_new_proxy_conn:
1917 self._prepare_proxy(conn)
1918
1919 # Make the request on the httplib connection object.
1920 httplib_response = self._make_request(
1921 conn,
1922 method,
1923 url,
1924 timeout=timeout_obj,
1925 body=body,
1926 headers=headers,
1927> chunked=chunked,
1928 )
1929
1930../env/lib/python3.7/site-packages/urllib3/connectionpool.py:672:
1931_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1932
1933self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1ff390>, conn = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False'
1934timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff6a0>, chunked = False
1935httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}}, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff2e8>
1936
1937 def _make_request(
1938 self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw
1939 ):
1940 """
1941 Perform a request on a given urllib connection object taken from our
1942 pool.
1943
1944 :param conn:
1945 a connection from one of our connection pools
1946
1947 :param timeout:
1948 Socket timeout in seconds for the request. This can be a
1949 float or integer, which will set the same timeout value for
1950 the socket connect and the socket read, or an instance of
1951 :class:`urllib3.util.Timeout`, which gives you more fine-grained
1952 control over your timeouts.
1953 """
1954 self.num_requests += 1
1955
1956 timeout_obj = self._get_timeout(timeout)
1957 timeout_obj.start_connect()
1958 conn.timeout = timeout_obj.connect_timeout
1959
1960 # Trigger any extra validation we need to do.
1961 try:
1962 self._validate_conn(conn)
1963 except (SocketTimeout, BaseSSLError) as e:
1964 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
1965 self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
1966 raise
1967
1968 # conn.request() calls httplib.*.request, not the method in
1969 # urllib3.request. It also calls makefile (recv) on the socket.
1970 if chunked:
1971 conn.request_chunked(method, url, **httplib_request_kw)
1972 else:
1973> conn.request(method, url, **httplib_request_kw)
1974
1975../env/lib/python3.7/site-packages/urllib3/connectionpool.py:387:
1976_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1977
1978self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', body = None
1979headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}
1980
1981 def request(self, method, url, body=None, headers={}, *,
1982 encode_chunked=False):
1983 """Send a complete request to the server."""
1984> self._send_request(method, url, body, headers, encode_chunked)
1985
1986/usr/lib/python3.7/http/client.py:1244:
1987_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1988
1989self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', body = None
1990headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}, encode_chunked = False
1991
1992 def _send_request(self, method, url, body, headers, encode_chunked):
1993 # Honor explicitly requested Host: and Accept-Encoding: headers.
1994 header_names = frozenset(k.lower() for k in headers)
1995 skips = {}
1996 if 'host' in header_names:
1997 skips['skip_host'] = 1
1998 if 'accept-encoding' in header_names:
1999 skips['skip_accept_encoding'] = 1
2000
2001 self.putrequest(method, url, **skips)
2002
2003 # chunked encoding will happen if HTTP/1.1 is used and either
2004 # the caller passes encode_chunked=True or the following
2005 # conditions hold:
2006 # 1. content-length has not been explicitly set
2007 # 2. the body is a file or iterable, but not a str or bytes-like
2008 # 3. Transfer-Encoding has NOT been explicitly set by the caller
2009
2010 if 'content-length' not in header_names:
2011 # only chunk body if not explicitly set for backwards
2012 # compatibility, assuming the client code is already handling the
2013 # chunking
2014 if 'transfer-encoding' not in header_names:
2015 # if content-length cannot be automatically determined, fall
2016 # back to chunked encoding
2017 encode_chunked = False
2018 content_length = self._get_content_length(body, method)
2019 if content_length is None:
2020 if body is not None:
2021 if self.debuglevel > 0:
2022 print('Unable to determine size of %r' % body)
2023 encode_chunked = True
2024 self.putheader('Transfer-Encoding', 'chunked')
2025 else:
2026 self.putheader('Content-Length', str(content_length))
2027 else:
2028 encode_chunked = False
2029
2030 for hdr, value in headers.items():
2031 self.putheader(hdr, value)
2032 if isinstance(body, str):
2033 # RFC 2616 Section 3.7.1 says that text default has a
2034 # default charset of iso-8859-1.
2035 body = _encode(body, 'body')
2036> self.endheaders(body, encode_chunked=encode_chunked)
2037
2038/usr/lib/python3.7/http/client.py:1290:
2039_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2040
2041self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, message_body = None
2042
2043 def endheaders(self, message_body=None, *, encode_chunked=False):
2044 """Indicate that the last header line has been sent to the server.
2045
2046 This method sends the request to the server. The optional message_body
2047 argument can be used to pass a message body associated with the
2048 request.
2049 """
2050 if self.__state == _CS_REQ_STARTED:
2051 self.__state = _CS_REQ_SENT
2052 else:
2053 raise CannotSendHeader()
2054> self._send_output(message_body, encode_chunked=encode_chunked)
2055
2056/usr/lib/python3.7/http/client.py:1239:
2057_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2058
2059self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, message_body = None, encode_chunked = False
2060
2061 def _send_output(self, message_body=None, encode_chunked=False):
2062 """Send the currently buffered request and clear the buffer.
2063
2064 Appends an extra \\r\\n to the buffer.
2065 A message_body may be specified, to be appended to the request.
2066 """
2067 self._buffer.extend((b"", b""))
2068 msg = b"\r\n".join(self._buffer)
2069 del self._buffer[:]
2070> self.send(msg)
2071
2072/usr/lib/python3.7/http/client.py:1026:
2073_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2074
2075self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>
2076data = b'DELETE /v1.35/images/runner?force=False&noprune=False HTTP/1.1\r\nHost: localhost\r\nUser-Agent: docker-sdk-python/4.1.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n'
2077
2078 def send(self, data):
2079 """Send `data' to the server.
2080 ``data`` can be a string object, a bytes object, an array object, a
2081 file-like object that supports a .read() method, or an iterable object.
2082 """
2083
2084 if self.sock is None:
2085 if self.auto_open:
2086> self.connect()
2087
2088/usr/lib/python3.7/http/client.py:966:
2089_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2090
2091self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>
2092
2093 def connect(self):
2094 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
2095 sock.settimeout(self.timeout)
2096> sock.connect(self.unix_socket)
2097E PermissionError: [Errno 13] Permission denied
2098
2099../env/lib/python3.7/site-packages/docker/transport/unixconn.py:43: PermissionError
2100
2101During handling of the above exception, another exception occurred:
2102
2103self = <docker.transport.unixconn.UnixHTTPAdapter object at 0x7f07a9ff7f60>, request = <PreparedRequest [DELETE]>, stream = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff048>, verify = True, cert = None, proxies = OrderedDict()
2104
2105 def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
2106 """Sends PreparedRequest object. Returns Response object.
2107
2108 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
2109 :param stream: (optional) Whether to stream the request content.
2110 :param timeout: (optional) How long to wait for the server to send
2111 data before giving up, as a float, or a :ref:`(connect timeout,
2112 read timeout) <timeouts>` tuple.
2113 :type timeout: float or tuple or urllib3 Timeout object
2114 :param verify: (optional) Either a boolean, in which case it controls whether
2115 we verify the server's TLS certificate, or a string, in which case it
2116 must be a path to a CA bundle to use
2117 :param cert: (optional) Any user-provided SSL certificate to be trusted.
2118 :param proxies: (optional) The proxies dictionary to apply to the request.
2119 :rtype: requests.Response
2120 """
2121
2122 try:
2123 conn = self.get_connection(request.url, proxies)
2124 except LocationValueError as e:
2125 raise InvalidURL(e, request=request)
2126
2127 self.cert_verify(conn, request.url, verify, cert)
2128 url = self.request_url(request, proxies)
2129 self.add_headers(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
2130
2131 chunked = not (request.body is None or 'Content-Length' in request.headers)
2132
2133 if isinstance(timeout, tuple):
2134 try:
2135 connect, read = timeout
2136 timeout = TimeoutSauce(connect=connect, read=read)
2137 except ValueError as e:
2138 # this may raise a string formatting error.
2139 err = ("Invalid timeout {}. Pass a (connect, read) "
2140 "timeout tuple, or a single float to set "
2141 "both timeouts to the same value".format(timeout))
2142 raise ValueError(err)
2143 elif isinstance(timeout, TimeoutSauce):
2144 pass
2145 else:
2146 timeout = TimeoutSauce(connect=timeout, read=timeout)
2147
2148 try:
2149 if not chunked:
2150 resp = conn.urlopen(
2151 method=request.method,
2152 url=url,
2153 body=request.body,
2154 headers=request.headers,
2155 redirect=False,
2156 assert_same_host=False,
2157 preload_content=False,
2158 decode_content=False,
2159 retries=self.max_retries,
2160> timeout=timeout
2161 )
2162
2163../env/lib/python3.7/site-packages/requests/adapters.py:449:
2164_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2165
2166self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1ff390>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', body = None
2167headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}, retries = Retry(total=0, connect=None, read=False, redirect=None, status=None), redirect = False
2168assert_same_host = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff048>, pool_timeout = None, release_conn = False, chunked = False, body_pos = None, response_kw = {'decode_content': False, 'preload_content': False}, conn = None, release_this_conn = True
2169err = None, clean_exit = False, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff6a0>, is_new_proxy_conn = False
2170
2171 def urlopen(
2172 self,
2173 method,
2174 url,
2175 body=None,
2176 headers=None,
2177 retries=None,
2178 redirect=True,
2179 assert_same_host=True,
2180 timeout=_Default,
2181 pool_timeout=None,
2182 release_conn=None,
2183 chunked=False,
2184 body_pos=None,
2185 **response_kw
2186 ):
2187 """
2188 Get a connection from the pool and perform an HTTP request. This is the
2189 lowest level call for making a request, so you'll need to specify all
2190 the raw details.
2191
2192 .. note::
2193
2194 More commonly, it's appropriate to use a convenience method provided
2195 by :class:`.RequestMethods`, such as :meth:`request`.
2196
2197 .. note::
2198
2199 `release_conn` will only behave as expected if
2200 `preload_content=False` because we want to make
2201 `preload_content=False` the default behaviour someday soon without
2202 breaking backwards compatibility.
2203
2204 :param method:
2205 HTTP request method (such as GET, POST, PUT, etc.)
2206
2207 :param body:
2208 Data to send in the request body (useful for creating
2209 POST requests, see HTTPConnectionPool.post_url for
2210 more convenience).
2211
2212 :param headers:
2213 Dictionary of custom headers to send, such as User-Agent,
2214 If-None-Match, etc. If None, pool headers are used. If provided,
2215 these headers completely replace any pool-specific headers.
2216
2217 :param retries:
2218 Configure the number of retries to allow before raising a
2219 :class:`~urllib3.exceptions.MaxRetryError` exception.
2220
2221 Pass ``None`` to retry until you receive a response. Pass a
2222 :class:`~urllib3.util.retry.Retry` object for fine-grained control
2223 over different types of retries.
2224 Pass an integer number to retry connection errors that many times,
2225 but no other types of errors. Pass zero to never retry.
2226
2227 If ``False``, then retries are disabled and any exception is raised
2228 immediately. Also, instead of raising a MaxRetryError on redirects,
2229 the redirect response will be returned.
2230
2231 :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
2232
2233 :param redirect:
2234 If True, automatically handle redirects (status codes 301, 302,
2235 303, 307, 308). Each redirect counts as a retry. Disabling retries
2236 will disable redirect, too.
2237
2238 :param assert_same_host:
2239 If ``True``, will make sure that the host of the pool requests is
2240 consistent else will raise HostChangedError. When False, you can
2241 use the pool on an HTTP proxy and request foreign hosts.
2242
2243 :param timeout:
2244 If specified, overrides the default timeout for this one
2245 request. It may be a float (in seconds) or an instance of
2246 :class:`urllib3.util.Timeout`.
2247
2248 :param pool_timeout:
2249 If set and the pool is set to block=True, then this method will
2250 block for ``pool_timeout`` seconds and raise EmptyPoolError if no
2251 connection is available within the time period.
2252
2253 :param release_conn:
2254 If False, then the urlopen call will not release the connection
2255 back into the pool once a response is received (but will release if
2256 you read the entire contents of the response such as when
2257 `preload_content=True`). This is useful if you're not preloading
2258 the response's content immediately. You will need to call
2259 ``r.release_conn()`` on the response ``r`` to return the connection
2260 back into the pool. If None, it takes the value of
2261 ``response_kw.get('preload_content', True)``.
2262
2263 :param chunked:
2264 If True, urllib3 will send the body using chunked transfer
2265 encoding. Otherwise, urllib3 will send the body using the standard
2266 content-length form. Defaults to False.
2267
2268 :param int body_pos:
2269 Position to seek to in file-like body in the event of a retry or
2270 redirect. Typically this won't need to be set because urllib3 will
2271 auto-populate the value when needed.
2272
2273 :param \\**response_kw:
2274 Additional parameters are passed to
2275 :meth:`urllib3.response.HTTPResponse.from_httplib`
2276 """
2277 if headers is None:
2278 headers = self.headers
2279
2280 if not isinstance(retries, Retry):
2281 retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
2282
2283 if release_conn is None:
2284 release_conn = response_kw.get("preload_content", True)
2285
2286 # Check host
2287 if assert_same_host and not self.is_same_host(url):
2288 raise HostChangedError(self, url, retries)
2289
2290 # Ensure that the URL we're connecting to is properly encoded
2291 if url.startswith("/"):
2292 url = six.ensure_str(_encode_target(url))
2293 else:
2294 url = six.ensure_str(parse_url(url).url)
2295
2296 conn = None
2297
2298 # Track whether `conn` needs to be released before
2299 # returning/raising/recursing. Update this variable if necessary, and
2300 # leave `release_conn` constant throughout the function. That way, if
2301 # the function recurses, the original value of `release_conn` will be
2302 # passed down into the recursive call, and its value will be respected.
2303 #
2304 # See issue #651 [1] for details.
2305 #
2306 # [1] <https://github.com/shazow/urllib3/issues/651>
2307 release_this_conn = release_conn
2308
2309 # Merge the proxy headers. Only do this in HTTP. We have to copy the
2310 # headers dict so we can safely change it without those changes being
2311 # reflected in anyone else's copy.
2312 if self.scheme == "http":
2313 headers = headers.copy()
2314 headers.update(self.proxy_headers)
2315
2316 # Must keep the exception bound to a separate variable or else Python 3
2317 # complains about UnboundLocalError.
2318 err = None
2319
2320 # Keep track of whether we cleanly exited the except block. This
2321 # ensures we do proper cleanup in finally.
2322 clean_exit = False
2323
2324 # Rewind body position, if needed. Record current position
2325 # for future rewinds in the event of a redirect/retry.
2326 body_pos = set_file_position(body, body_pos)
2327
2328 try:
2329 # Request a connection from the queue.
2330 timeout_obj = self._get_timeout(timeout)
2331 conn = self._get_conn(timeout=pool_timeout)
2332
2333 conn.timeout = timeout_obj.connect_timeout
2334
2335 is_new_proxy_conn = self.proxy is not None and not getattr(
2336 conn, "sock", None
2337 )
2338 if is_new_proxy_conn:
2339 self._prepare_proxy(conn)
2340
2341 # Make the request on the httplib connection object.
2342 httplib_response = self._make_request(
2343 conn,
2344 method,
2345 url,
2346 timeout=timeout_obj,
2347 body=body,
2348 headers=headers,
2349 chunked=chunked,
2350 )
2351
2352 # If we're going to release the connection in ``finally:``, then
2353 # the response doesn't need to know about the connection. Otherwise
2354 # it will also try to release it and we'll have a double-release
2355 # mess.
2356 response_conn = conn if not release_conn else None
2357
2358 # Pass method to Response for length checking
2359 response_kw["request_method"] = method
2360
2361 # Import httplib's response into our own wrapper object
2362 response = self.ResponseCls.from_httplib(
2363 httplib_response,
2364 pool=self,
2365 connection=response_conn,
2366 retries=retries,
2367 **response_kw
2368 )
2369
2370 # Everything went great!
2371 clean_exit = True
2372
2373 except queue.Empty:
2374 # Timed out by queue.
2375 raise EmptyPoolError(self, "No pool connections are available.")
2376
2377 except (
2378 TimeoutError,
2379 HTTPException,
2380 SocketError,
2381 ProtocolError,
2382 BaseSSLError,
2383 SSLError,
2384 CertificateError,
2385 ) as e:
2386 # Discard the connection for these exceptions. It will be
2387 # replaced during the next _get_conn() call.
2388 clean_exit = False
2389 if isinstance(e, (BaseSSLError, CertificateError)):
2390 e = SSLError(e)
2391 elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
2392 e = ProxyError("Cannot connect to proxy.", e)
2393 elif isinstance(e, (SocketError, HTTPException)):
2394 e = ProtocolError("Connection aborted.", e)
2395
2396 retries = retries.increment(
2397> method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
2398 )
2399
2400../env/lib/python3.7/site-packages/urllib3/connectionpool.py:720:
2401_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2402
2403self = Retry(total=0, connect=None, read=False, redirect=None, status=None), method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', response = None, error = ProtocolError('Connection aborted.', PermissionError(13, 'Permission denied'))
2404_pool = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1ff390>, _stacktrace = <traceback object at 0x7f07a9d937c8>
2405
2406 def increment(
2407 self,
2408 method=None,
2409 url=None,
2410 response=None,
2411 error=None,
2412 _pool=None,
2413 _stacktrace=None,
2414 ):
2415 """ Return a new Retry object with incremented retry counters.
2416
2417 :param response: A response object, or None, if the server did not
2418 return a response.
2419 :type response: :class:`~urllib3.response.HTTPResponse`
2420 :param Exception error: An error encountered during the request, or
2421 None if the response was received successfully.
2422
2423 :return: A new ``Retry`` object.
2424 """
2425 if self.total is False and error:
2426 # Disabled, indicate to re-raise the error.
2427 raise six.reraise(type(error), error, _stacktrace)
2428
2429 total = self.total
2430 if total is not None:
2431 total -= 1
2432
2433 connect = self.connect
2434 read = self.read
2435 redirect = self.redirect
2436 status_count = self.status
2437 cause = "unknown"
2438 status = None
2439 redirect_location = None
2440
2441 if error and self._is_connection_error(error):
2442 # Connect retry?
2443 if connect is False:
2444 raise six.reraise(type(error), error, _stacktrace)
2445 elif connect is not None:
2446 connect -= 1
2447
2448 elif error and self._is_read_error(error):
2449 # Read retry?
2450 if read is False or not self._is_method_retryable(method):
2451> raise six.reraise(type(error), error, _stacktrace)
2452
2453../env/lib/python3.7/site-packages/urllib3/util/retry.py:400:
2454_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2455
2456tp = <class 'urllib3.exceptions.ProtocolError'>, value = None, tb = None
2457
2458 def reraise(tp, value, tb=None):
2459 try:
2460 if value is None:
2461 value = tp()
2462 if value.__traceback__ is not tb:
2463> raise value.with_traceback(tb)
2464
2465../env/lib/python3.7/site-packages/urllib3/packages/six.py:734:
2466_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2467
2468self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1ff390>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', body = None
2469headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}, retries = Retry(total=0, connect=None, read=False, redirect=None, status=None), redirect = False
2470assert_same_host = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff048>, pool_timeout = None, release_conn = False, chunked = False, body_pos = None, response_kw = {'decode_content': False, 'preload_content': False}, conn = None, release_this_conn = True
2471err = None, clean_exit = False, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff6a0>, is_new_proxy_conn = False
2472
2473 def urlopen(
2474 self,
2475 method,
2476 url,
2477 body=None,
2478 headers=None,
2479 retries=None,
2480 redirect=True,
2481 assert_same_host=True,
2482 timeout=_Default,
2483 pool_timeout=None,
2484 release_conn=None,
2485 chunked=False,
2486 body_pos=None,
2487 **response_kw
2488 ):
2489 """
2490 Get a connection from the pool and perform an HTTP request. This is the
2491 lowest level call for making a request, so you'll need to specify all
2492 the raw details.
2493
2494 .. note::
2495
2496 More commonly, it's appropriate to use a convenience method provided
2497 by :class:`.RequestMethods`, such as :meth:`request`.
2498
2499 .. note::
2500
2501 `release_conn` will only behave as expected if
2502 `preload_content=False` because we want to make
2503 `preload_content=False` the default behaviour someday soon without
2504 breaking backwards compatibility.
2505
2506 :param method:
2507 HTTP request method (such as GET, POST, PUT, etc.)
2508
2509 :param body:
2510 Data to send in the request body (useful for creating
2511 POST requests, see HTTPConnectionPool.post_url for
2512 more convenience).
2513
2514 :param headers:
2515 Dictionary of custom headers to send, such as User-Agent,
2516 If-None-Match, etc. If None, pool headers are used. If provided,
2517 these headers completely replace any pool-specific headers.
2518
2519 :param retries:
2520 Configure the number of retries to allow before raising a
2521 :class:`~urllib3.exceptions.MaxRetryError` exception.
2522
2523 Pass ``None`` to retry until you receive a response. Pass a
2524 :class:`~urllib3.util.retry.Retry` object for fine-grained control
2525 over different types of retries.
2526 Pass an integer number to retry connection errors that many times,
2527 but no other types of errors. Pass zero to never retry.
2528
2529 If ``False``, then retries are disabled and any exception is raised
2530 immediately. Also, instead of raising a MaxRetryError on redirects,
2531 the redirect response will be returned.
2532
2533 :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
2534
2535 :param redirect:
2536 If True, automatically handle redirects (status codes 301, 302,
2537 303, 307, 308). Each redirect counts as a retry. Disabling retries
2538 will disable redirect, too.
2539
2540 :param assert_same_host:
2541 If ``True``, will make sure that the host of the pool requests is
2542 consistent else will raise HostChangedError. When False, you can
2543 use the pool on an HTTP proxy and request foreign hosts.
2544
2545 :param timeout:
2546 If specified, overrides the default timeout for this one
2547 request. It may be a float (in seconds) or an instance of
2548 :class:`urllib3.util.Timeout`.
2549
2550 :param pool_timeout:
2551 If set and the pool is set to block=True, then this method will
2552 block for ``pool_timeout`` seconds and raise EmptyPoolError if no
2553 connection is available within the time period.
2554
2555 :param release_conn:
2556 If False, then the urlopen call will not release the connection
2557 back into the pool once a response is received (but will release if
2558 you read the entire contents of the response such as when
2559 `preload_content=True`). This is useful if you're not preloading
2560 the response's content immediately. You will need to call
2561 ``r.release_conn()`` on the response ``r`` to return the connection
2562 back into the pool. If None, it takes the value of
2563 ``response_kw.get('preload_content', True)``.
2564
2565 :param chunked:
2566 If True, urllib3 will send the body using chunked transfer
2567 encoding. Otherwise, urllib3 will send the body using the standard
2568 content-length form. Defaults to False.
2569
2570 :param int body_pos:
2571 Position to seek to in file-like body in the event of a retry or
2572 redirect. Typically this won't need to be set because urllib3 will
2573 auto-populate the value when needed.
2574
2575 :param \\**response_kw:
2576 Additional parameters are passed to
2577 :meth:`urllib3.response.HTTPResponse.from_httplib`
2578 """
2579 if headers is None:
2580 headers = self.headers
2581
2582 if not isinstance(retries, Retry):
2583 retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
2584
2585 if release_conn is None:
2586 release_conn = response_kw.get("preload_content", True)
2587
2588 # Check host
2589 if assert_same_host and not self.is_same_host(url):
2590 raise HostChangedError(self, url, retries)
2591
2592 # Ensure that the URL we're connecting to is properly encoded
2593 if url.startswith("/"):
2594 url = six.ensure_str(_encode_target(url))
2595 else:
2596 url = six.ensure_str(parse_url(url).url)
2597
2598 conn = None
2599
2600 # Track whether `conn` needs to be released before
2601 # returning/raising/recursing. Update this variable if necessary, and
2602 # leave `release_conn` constant throughout the function. That way, if
2603 # the function recurses, the original value of `release_conn` will be
2604 # passed down into the recursive call, and its value will be respected.
2605 #
2606 # See issue #651 [1] for details.
2607 #
2608 # [1] <https://github.com/shazow/urllib3/issues/651>
2609 release_this_conn = release_conn
2610
2611 # Merge the proxy headers. Only do this in HTTP. We have to copy the
2612 # headers dict so we can safely change it without those changes being
2613 # reflected in anyone else's copy.
2614 if self.scheme == "http":
2615 headers = headers.copy()
2616 headers.update(self.proxy_headers)
2617
2618 # Must keep the exception bound to a separate variable or else Python 3
2619 # complains about UnboundLocalError.
2620 err = None
2621
2622 # Keep track of whether we cleanly exited the except block. This
2623 # ensures we do proper cleanup in finally.
2624 clean_exit = False
2625
2626 # Rewind body position, if needed. Record current position
2627 # for future rewinds in the event of a redirect/retry.
2628 body_pos = set_file_position(body, body_pos)
2629
2630 try:
2631 # Request a connection from the queue.
2632 timeout_obj = self._get_timeout(timeout)
2633 conn = self._get_conn(timeout=pool_timeout)
2634
2635 conn.timeout = timeout_obj.connect_timeout
2636
2637 is_new_proxy_conn = self.proxy is not None and not getattr(
2638 conn, "sock", None
2639 )
2640 if is_new_proxy_conn:
2641 self._prepare_proxy(conn)
2642
2643 # Make the request on the httplib connection object.
2644 httplib_response = self._make_request(
2645 conn,
2646 method,
2647 url,
2648 timeout=timeout_obj,
2649 body=body,
2650 headers=headers,
2651> chunked=chunked,
2652 )
2653
2654../env/lib/python3.7/site-packages/urllib3/connectionpool.py:672:
2655_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2656
2657self = <docker.transport.unixconn.UnixHTTPConnectionPool object at 0x7f07aa1ff390>, conn = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False'
2658timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff6a0>, chunked = False
2659httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}}, timeout_obj = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff2e8>
2660
2661 def _make_request(
2662 self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw
2663 ):
2664 """
2665 Perform a request on a given urllib connection object taken from our
2666 pool.
2667
2668 :param conn:
2669 a connection from one of our connection pools
2670
2671 :param timeout:
2672 Socket timeout in seconds for the request. This can be a
2673 float or integer, which will set the same timeout value for
2674 the socket connect and the socket read, or an instance of
2675 :class:`urllib3.util.Timeout`, which gives you more fine-grained
2676 control over your timeouts.
2677 """
2678 self.num_requests += 1
2679
2680 timeout_obj = self._get_timeout(timeout)
2681 timeout_obj.start_connect()
2682 conn.timeout = timeout_obj.connect_timeout
2683
2684 # Trigger any extra validation we need to do.
2685 try:
2686 self._validate_conn(conn)
2687 except (SocketTimeout, BaseSSLError) as e:
2688 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
2689 self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
2690 raise
2691
2692 # conn.request() calls httplib.*.request, not the method in
2693 # urllib3.request. It also calls makefile (recv) on the socket.
2694 if chunked:
2695 conn.request_chunked(method, url, **httplib_request_kw)
2696 else:
2697> conn.request(method, url, **httplib_request_kw)
2698
2699../env/lib/python3.7/site-packages/urllib3/connectionpool.py:387:
2700_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2701
2702self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', body = None
2703headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}
2704
2705 def request(self, method, url, body=None, headers={}, *,
2706 encode_chunked=False):
2707 """Send a complete request to the server."""
2708> self._send_request(method, url, body, headers, encode_chunked)
2709
2710/usr/lib/python3.7/http/client.py:1244:
2711_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2712
2713self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, method = 'DELETE', url = '/v1.35/images/runner?force=False&noprune=False', body = None
2714headers = {'User-Agent': 'docker-sdk-python/4.1.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0'}, encode_chunked = False
2715
2716 def _send_request(self, method, url, body, headers, encode_chunked):
2717 # Honor explicitly requested Host: and Accept-Encoding: headers.
2718 header_names = frozenset(k.lower() for k in headers)
2719 skips = {}
2720 if 'host' in header_names:
2721 skips['skip_host'] = 1
2722 if 'accept-encoding' in header_names:
2723 skips['skip_accept_encoding'] = 1
2724
2725 self.putrequest(method, url, **skips)
2726
2727 # chunked encoding will happen if HTTP/1.1 is used and either
2728 # the caller passes encode_chunked=True or the following
2729 # conditions hold:
2730 # 1. content-length has not been explicitly set
2731 # 2. the body is a file or iterable, but not a str or bytes-like
2732 # 3. Transfer-Encoding has NOT been explicitly set by the caller
2733
2734 if 'content-length' not in header_names:
2735 # only chunk body if not explicitly set for backwards
2736 # compatibility, assuming the client code is already handling the
2737 # chunking
2738 if 'transfer-encoding' not in header_names:
2739 # if content-length cannot be automatically determined, fall
2740 # back to chunked encoding
2741 encode_chunked = False
2742 content_length = self._get_content_length(body, method)
2743 if content_length is None:
2744 if body is not None:
2745 if self.debuglevel > 0:
2746 print('Unable to determine size of %r' % body)
2747 encode_chunked = True
2748 self.putheader('Transfer-Encoding', 'chunked')
2749 else:
2750 self.putheader('Content-Length', str(content_length))
2751 else:
2752 encode_chunked = False
2753
2754 for hdr, value in headers.items():
2755 self.putheader(hdr, value)
2756 if isinstance(body, str):
2757 # RFC 2616 Section 3.7.1 says that text default has a
2758 # default charset of iso-8859-1.
2759 body = _encode(body, 'body')
2760> self.endheaders(body, encode_chunked=encode_chunked)
2761
2762/usr/lib/python3.7/http/client.py:1290:
2763_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2764
2765self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, message_body = None
2766
2767 def endheaders(self, message_body=None, *, encode_chunked=False):
2768 """Indicate that the last header line has been sent to the server.
2769
2770 This method sends the request to the server. The optional message_body
2771 argument can be used to pass a message body associated with the
2772 request.
2773 """
2774 if self.__state == _CS_REQ_STARTED:
2775 self.__state = _CS_REQ_SENT
2776 else:
2777 raise CannotSendHeader()
2778> self._send_output(message_body, encode_chunked=encode_chunked)
2779
2780/usr/lib/python3.7/http/client.py:1239:
2781_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2782
2783self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>, message_body = None, encode_chunked = False
2784
2785 def _send_output(self, message_body=None, encode_chunked=False):
2786 """Send the currently buffered request and clear the buffer.
2787
2788 Appends an extra \\r\\n to the buffer.
2789 A message_body may be specified, to be appended to the request.
2790 """
2791 self._buffer.extend((b"", b""))
2792 msg = b"\r\n".join(self._buffer)
2793 del self._buffer[:]
2794> self.send(msg)
2795
2796/usr/lib/python3.7/http/client.py:1026:
2797_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2798
2799self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>
2800data = b'DELETE /v1.35/images/runner?force=False&noprune=False HTTP/1.1\r\nHost: localhost\r\nUser-Agent: docker-sdk-python/4.1.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n'
2801
2802 def send(self, data):
2803 """Send `data' to the server.
2804 ``data`` can be a string object, a bytes object, an array object, a
2805 file-like object that supports a .read() method, or an iterable object.
2806 """
2807
2808 if self.sock is None:
2809 if self.auto_open:
2810> self.connect()
2811
2812/usr/lib/python3.7/http/client.py:966:
2813_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2814
2815self = <docker.transport.unixconn.UnixHTTPConnection object at 0x7f07aa1ff278>
2816
2817 def connect(self):
2818 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
2819 sock.settimeout(self.timeout)
2820> sock.connect(self.unix_socket)
2821E urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))
2822
2823../env/lib/python3.7/site-packages/docker/transport/unixconn.py:43: ProtocolError
2824
2825During handling of the above exception, another exception occurred:
2826
2827valid_user_serializer = UserSerializer(data={'username': 'testuser', 'password': 'testpassword12!', 'first_name': 'firstname', 'last_name': 'l...=[<UniqueValidator(queryset=<QuerySet [<User: testuser>]>)>])
2828 password = CharField(max_length=128, write_only=True)
2829valid_task_serializer = TaskSerializer(data={'title': 'Simple task', 'statement': 'Multiply by two!', 'complexity': 2, 'input': '1 input', 'ou... = CharField(style={'base_template': 'textarea.html'})
2830 output = CharField(style={'base_template': 'textarea.html'})
2831
2832 @pytest.mark.django_db
2833 def test_api_submissions(valid_user_serializer, valid_task_serializer):
2834 user = valid_user_serializer.save()
2835 task = valid_task_serializer.save()
2836
2837 data = {
2838 "task": task.id,
2839 "language": "Java",
2840 "sourceCode": "Some test code"
2841 }
2842
2843 factory = APIRequestFactory()
2844
2845 view = SubmissionViewSet.as_view({'post': 'create', 'get': 'retrieve'})
2846
2847 request = factory.post("/api/submissions/", data=data)
2848 force_authenticate(request, user=user)
2849> response=view(request)
2850
2851tests/submissions/test_api.py:25:
2852_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2853../env/lib/python3.7/site-packages/django/views/decorators/csrf.py:54: in wrapped_view
2854 return view_func(*args, **kwargs)
2855../env/lib/python3.7/site-packages/rest_framework/viewsets.py:114: in view
2856 return self.dispatch(request, *args, **kwargs)
2857../env/lib/python3.7/site-packages/rest_framework/views.py:505: in dispatch
2858 response = self.handle_exception(exc)
2859../env/lib/python3.7/site-packages/rest_framework/views.py:465: in handle_exception
2860 self.raise_uncaught_exception(exc)
2861../env/lib/python3.7/site-packages/rest_framework/views.py:476: in raise_uncaught_exception
2862 raise exc
2863../env/lib/python3.7/site-packages/rest_framework/views.py:502: in dispatch
2864 response = handler(request, *args, **kwargs)
2865../env/lib/python3.7/site-packages/rest_framework/mixins.py:19: in create
2866 self.perform_create(serializer)
2867../env/lib/python3.7/site-packages/rest_framework/mixins.py:24: in perform_create
2868 serializer.save()
2869../env/lib/python3.7/site-packages/rest_framework/serializers.py:213: in save
2870 self.instance = self.create(validated_data)
2871submissions/serializers/submission_serializer.py:22: in create
2872 validation_out = self._validate(sourceCode, language, task)
2873submissions/serializers/submission_serializer.py:41: in _validate
2874 return validate_code(source_code, language, task)
2875submissions/code_validator/code_validator.py:18: in validate_code
2876 output = soSorryYouLose(code_file, input_file)
2877runner/runner.py:111: in soSorryYouLose
2878 dockerc.images.remove(imagetag)
2879../env/lib/python3.7/site-packages/docker/models/images.py:463: in remove
2880 self.client.api.remove_image(*args, **kwargs)
2881../env/lib/python3.7/site-packages/docker/utils/decorators.py:19: in wrapped
2882 return f(self, resource_id, *args, **kwargs)
2883../env/lib/python3.7/site-packages/docker/api/image.py:494: in remove_image
2884 res = self._delete(self._url("/images/{0}", image), params=params)
2885../env/lib/python3.7/site-packages/docker/utils/decorators.py:46: in inner
2886 return f(self, *args, **kwargs)
2887../env/lib/python3.7/site-packages/docker/api/client.py:238: in _delete
2888 return self.delete(url, **self._set_request_timeout(kwargs))
2889../env/lib/python3.7/site-packages/requests/sessions.py:615: in delete
2890 return self.request('DELETE', url, **kwargs)
2891../env/lib/python3.7/site-packages/requests/sessions.py:533: in request
2892 resp = self.send(prep, **send_kwargs)
2893../env/lib/python3.7/site-packages/requests/sessions.py:646: in send
2894 r = adapter.send(request, **kwargs)
2895_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2896
2897self = <docker.transport.unixconn.UnixHTTPAdapter object at 0x7f07a9ff7f60>, request = <PreparedRequest [DELETE]>, stream = False, timeout = <urllib3.util.timeout.Timeout object at 0x7f07aa1ff048>, verify = True, cert = None, proxies = OrderedDict()
2898
2899 def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
2900 """Sends PreparedRequest object. Returns Response object.
2901
2902 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
2903 :param stream: (optional) Whether to stream the request content.
2904 :param timeout: (optional) How long to wait for the server to send
2905 data before giving up, as a float, or a :ref:`(connect timeout,
2906 read timeout) <timeouts>` tuple.
2907 :type timeout: float or tuple or urllib3 Timeout object
2908 :param verify: (optional) Either a boolean, in which case it controls whether
2909 we verify the server's TLS certificate, or a string, in which case it
2910 must be a path to a CA bundle to use
2911 :param cert: (optional) Any user-provided SSL certificate to be trusted.
2912 :param proxies: (optional) The proxies dictionary to apply to the request.
2913 :rtype: requests.Response
2914 """
2915
2916 try:
2917 conn = self.get_connection(request.url, proxies)
2918 except LocationValueError as e:
2919 raise InvalidURL(e, request=request)
2920
2921 self.cert_verify(conn, request.url, verify, cert)
2922 url = self.request_url(request, proxies)
2923 self.add_headers(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
2924
2925 chunked = not (request.body is None or 'Content-Length' in request.headers)
2926
2927 if isinstance(timeout, tuple):
2928 try:
2929 connect, read = timeout
2930 timeout = TimeoutSauce(connect=connect, read=read)
2931 except ValueError as e:
2932 # this may raise a string formatting error.
2933 err = ("Invalid timeout {}. Pass a (connect, read) "
2934 "timeout tuple, or a single float to set "
2935 "both timeouts to the same value".format(timeout))
2936 raise ValueError(err)
2937 elif isinstance(timeout, TimeoutSauce):
2938 pass
2939 else:
2940 timeout = TimeoutSauce(connect=timeout, read=timeout)
2941
2942 try:
2943 if not chunked:
2944 resp = conn.urlopen(
2945 method=request.method,
2946 url=url,
2947 body=request.body,
2948 headers=request.headers,
2949 redirect=False,
2950 assert_same_host=False,
2951 preload_content=False,
2952 decode_content=False,
2953 retries=self.max_retries,
2954 timeout=timeout
2955 )
2956
2957 # Send the request.
2958 else:
2959 if hasattr(conn, 'proxy_pool'):
2960 conn = conn.proxy_pool
2961
2962 low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)
2963
2964 try:
2965 low_conn.putrequest(request.method,
2966 url,
2967 skip_accept_encoding=True)
2968
2969 for header, value in request.headers.items():
2970 low_conn.putheader(header, value)
2971
2972 low_conn.endheaders()
2973
2974 for i in request.body:
2975 low_conn.send(hex(len(i))[2:].encode('utf-8'))
2976 low_conn.send(b'\r\n')
2977 low_conn.send(i)
2978 low_conn.send(b'\r\n')
2979 low_conn.send(b'0\r\n\r\n')
2980
2981 # Receive the response from the server
2982 try:
2983 # For Python 2.7, use buffering of HTTP responses
2984 r = low_conn.getresponse(buffering=True)
2985 except TypeError:
2986 # For compatibility with Python 3.3+
2987 r = low_conn.getresponse()
2988
2989 resp = HTTPResponse.from_httplib(
2990 r,
2991 pool=conn,
2992 connection=low_conn,
2993 preload_content=False,
2994 decode_content=False
2995 )
2996 except:
2997 # If we hit any problems here, clean up the connection.
2998 # Then, reraise so that we can handle the actual exception.
2999 low_conn.close()
3000 raise
3001
3002 except (ProtocolError, socket.error) as err:
3003> raise ConnectionError(err, request=request)
3004E requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))
3005
3006../env/lib/python3.7/site-packages/requests/adapters.py:498: ConnectionError
3007=========================================================================================================================== 1 failed, 1 passed in 0.65s ===========================================================================================================================
3008(env) slid3rek@MSI-Gaming3-Z97-i5-4690K-GTX970:~/Dokumenty/MWO/iwsoj/iwsoj/iwsoj$