Kaydet (Commit) 9987c1bc authored tarafından Joffrey F's avatar Joffrey F

Fix docs examples to work with Python 3

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 5467658b
......@@ -42,8 +42,8 @@ class DaemonApiMixin(object):
Example:
>>> for event in client.events()
... print event
>>> for event in client.events(decode=True)
... print(event)
{u'from': u'image/with:tag',
u'id': u'container-id',
u'status': u'start',
......@@ -54,7 +54,7 @@ class DaemonApiMixin(object):
>>> events = client.events()
>>> for event in events:
... print event
... print(event)
>>> # and cancel from another thread
>>> events.close()
"""
......
......@@ -352,8 +352,8 @@ class ImageApiMixin(object):
Example:
>>> for line in cli.pull('busybox', stream=True):
... print(json.dumps(json.loads(line), indent=4))
>>> for line in cli.pull('busybox', stream=True, decode=True):
... print(json.dumps(line, indent=4))
{
"status": "Pulling image (latest) from busybox",
"progressDetail": {},
......@@ -428,12 +428,12 @@ class ImageApiMixin(object):
If the server returns an error.
Example:
>>> for line in cli.push('yourname/app', stream=True):
... print line
{"status":"Pushing repository yourname/app (1 tags)"}
{"status":"Pushing","progressDetail":{},"id":"511136ea3c5a"}
{"status":"Image already pushed, skipping","progressDetail":{},
"id":"511136ea3c5a"}
>>> for line in cli.push('yourname/app', stream=True, decode=True):
... print(line)
{'status': 'Pushing repository yourname/app (1 tags)'}
{'status': 'Pushing','progressDetail': {}, 'id': '511136ea3c5a'}
{'status': 'Image already pushed, skipping', 'progressDetail':{},
'id': '511136ea3c5a'}
...
"""
......
from typing import Any, Dict, Iterable, List, Optional, Union
import requests
from ..constants import DEFAULT_DOCKER_API_VERSION, DEFAULT_TIMEOUT_SECONDS
class BaseMixin(object):
base_url: str = ''
credstore_env: Optional[Dict[str, str]] = None
timeout: int = DEFAULT_TIMEOUT_SECONDS
_auth_configs: Dict[str, Dict]
_general_configs: Dict[str, Dict]
_version: str = DEFAULT_DOCKER_API_VERSION
def _url(self, pathfmt: str, *args, **kwargs) -> str:
raise NotImplemented
def _post(self, url: str, **kwargs) -> requests.Response:
raise NotImplemented
def _get(self, url: str, **kwargs) -> requests.Response:
raise NotImplemented
def _put(self, url: str, **kwargs) -> requests.Response:
raise NotImplemented
def _delete(self, url: str, **kwargs) -> requests.Response:
raise NotImplemented
def _post_json(self, url: str, data: Optional[Union[Dict[str, Any], List[Any]]], **kwargs) -> requests.Response:
raise NotImplemented
def _raise_for_status(self, response: requests.Response) -> None:
raise NotImplemented
def _result(self, response: requests.Response, json: bool=False, binary: bool=False) -> Any:
raise NotImplemented
def _stream_helper(self, response: requests.Response, decode: bool = False) -> Iterable:
raise NotImplemented
def _get_raw_response_socket(self, response: requests.Response) -> Iterable:
raise NotImplemented
def _read_from_socket(
self,
response: requests.Response,
stream: bool,
tty: bool = False) -> Union[Iterable[bytes], bytes]:
raise NotImplemented
def _stream_raw_result(
self,
response: requests.Response,
chunk_size: int = 1,
decode: bool = True) -> Iterable[bytes]:
raise NotImplemented
......@@ -15,7 +15,7 @@ class CancellableStream(object):
Example:
>>> events = client.events()
>>> for event in events:
... print event
... print(event)
>>> # and cancel from another thread
>>> events.close()
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment