gam7 7.19.3__py3-none-any.whl → 7.28.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gam/__init__.py +1836 -700
- gam/__main__.py +6 -1
- gam/gamlib/glapi.py +35 -19
- gam/gamlib/glcfg.py +16 -0
- gam/gamlib/glclargs.py +294 -5
- gam/gamlib/glentity.py +15 -3
- gam/gamlib/glglobals.py +6 -0
- gam/gamlib/glmsgs.py +5 -2
- gam/gamlib/glskus.py +1 -1
- gam/gamlib/glverlibs.py +1 -1
- gam/gamlib/yubikey.py +13 -12
- {gam7-7.19.3.dist-info → gam7-7.28.2.dist-info}/METADATA +10 -4
- {gam7-7.19.3.dist-info → gam7-7.28.2.dist-info}/RECORD +16 -34
- gam/googleapiclient/__init__.py +0 -27
- gam/googleapiclient/_auth.py +0 -167
- gam/googleapiclient/_helpers.py +0 -207
- gam/googleapiclient/channel.py +0 -315
- gam/googleapiclient/discovery.py +0 -1662
- gam/googleapiclient/discovery_cache/__init__.py +0 -78
- gam/googleapiclient/discovery_cache/appengine_memcache.py +0 -55
- gam/googleapiclient/discovery_cache/base.py +0 -46
- gam/googleapiclient/discovery_cache/file_cache.py +0 -145
- gam/googleapiclient/errors.py +0 -197
- gam/googleapiclient/http.py +0 -1962
- gam/googleapiclient/mimeparse.py +0 -183
- gam/googleapiclient/model.py +0 -429
- gam/googleapiclient/schema.py +0 -317
- gam/googleapiclient/version.py +0 -15
- gam/iso8601/__init__.py +0 -28
- gam/iso8601/iso8601.py +0 -160
- gam/six.py +0 -982
- {gam7-7.19.3.dist-info → gam7-7.28.2.dist-info}/WHEEL +0 -0
- {gam7-7.19.3.dist-info → gam7-7.28.2.dist-info}/entry_points.txt +0 -0
- {gam7-7.19.3.dist-info → gam7-7.28.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Copyright 2014 Google Inc. All Rights Reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
"""Caching utility for the discovery document."""
|
|
16
|
-
|
|
17
|
-
from __future__ import absolute_import
|
|
18
|
-
|
|
19
|
-
import logging
|
|
20
|
-
import os
|
|
21
|
-
|
|
22
|
-
LOGGER = logging.getLogger(__name__)
|
|
23
|
-
|
|
24
|
-
DISCOVERY_DOC_MAX_AGE = 60 * 60 * 24 # 1 day
|
|
25
|
-
DISCOVERY_DOC_DIR = os.path.join(
|
|
26
|
-
os.path.dirname(os.path.realpath(__file__)), "documents"
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def autodetect():
|
|
31
|
-
"""Detects an appropriate cache module and returns it.
|
|
32
|
-
|
|
33
|
-
Returns:
|
|
34
|
-
googleapiclient.discovery_cache.base.Cache, a cache object which
|
|
35
|
-
is auto detected, or None if no cache object is available.
|
|
36
|
-
"""
|
|
37
|
-
if "GAE_ENV" in os.environ:
|
|
38
|
-
try:
|
|
39
|
-
from . import appengine_memcache
|
|
40
|
-
|
|
41
|
-
return appengine_memcache.cache
|
|
42
|
-
except Exception:
|
|
43
|
-
pass
|
|
44
|
-
try:
|
|
45
|
-
from . import file_cache
|
|
46
|
-
|
|
47
|
-
return file_cache.cache
|
|
48
|
-
except Exception:
|
|
49
|
-
LOGGER.info(
|
|
50
|
-
"file_cache is only supported with oauth2client<4.0.0", exc_info=False
|
|
51
|
-
)
|
|
52
|
-
return None
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def get_static_doc(serviceName, version):
|
|
56
|
-
"""Retrieves the discovery document from the directory defined in
|
|
57
|
-
DISCOVERY_DOC_DIR corresponding to the serviceName and version provided.
|
|
58
|
-
|
|
59
|
-
Args:
|
|
60
|
-
serviceName: string, name of the service.
|
|
61
|
-
version: string, the version of the service.
|
|
62
|
-
|
|
63
|
-
Returns:
|
|
64
|
-
A string containing the contents of the JSON discovery document,
|
|
65
|
-
otherwise None if the JSON discovery document was not found.
|
|
66
|
-
"""
|
|
67
|
-
|
|
68
|
-
content = None
|
|
69
|
-
doc_name = "{}.{}.json".format(serviceName, version)
|
|
70
|
-
|
|
71
|
-
try:
|
|
72
|
-
with open(os.path.join(DISCOVERY_DOC_DIR, doc_name), "r") as f:
|
|
73
|
-
content = f.read()
|
|
74
|
-
except FileNotFoundError:
|
|
75
|
-
# File does not exist. Nothing to do here.
|
|
76
|
-
pass
|
|
77
|
-
|
|
78
|
-
return content
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Copyright 2014 Google Inc. All Rights Reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
"""App Engine memcache based cache for the discovery document."""
|
|
16
|
-
|
|
17
|
-
import logging
|
|
18
|
-
|
|
19
|
-
# This is only an optional dependency because we only import this
|
|
20
|
-
# module when google.appengine.api.memcache is available.
|
|
21
|
-
from google.appengine.api import memcache
|
|
22
|
-
|
|
23
|
-
from . import base
|
|
24
|
-
from ..discovery_cache import DISCOVERY_DOC_MAX_AGE
|
|
25
|
-
|
|
26
|
-
LOGGER = logging.getLogger(__name__)
|
|
27
|
-
|
|
28
|
-
NAMESPACE = "google-api-client"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class Cache(base.Cache):
|
|
32
|
-
"""A cache with app engine memcache API."""
|
|
33
|
-
|
|
34
|
-
def __init__(self, max_age):
|
|
35
|
-
"""Constructor.
|
|
36
|
-
|
|
37
|
-
Args:
|
|
38
|
-
max_age: Cache expiration in seconds.
|
|
39
|
-
"""
|
|
40
|
-
self._max_age = max_age
|
|
41
|
-
|
|
42
|
-
def get(self, url):
|
|
43
|
-
try:
|
|
44
|
-
return memcache.get(url, namespace=NAMESPACE)
|
|
45
|
-
except Exception as e:
|
|
46
|
-
LOGGER.warning(e, exc_info=True)
|
|
47
|
-
|
|
48
|
-
def set(self, url, content):
|
|
49
|
-
try:
|
|
50
|
-
memcache.set(url, content, time=int(self._max_age), namespace=NAMESPACE)
|
|
51
|
-
except Exception as e:
|
|
52
|
-
LOGGER.warning(e, exc_info=True)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
cache = Cache(max_age=DISCOVERY_DOC_MAX_AGE)
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Copyright 2014 Google Inc. All Rights Reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
"""An abstract class for caching the discovery document."""
|
|
16
|
-
|
|
17
|
-
import abc
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class Cache(object):
|
|
21
|
-
"""A base abstract cache class."""
|
|
22
|
-
|
|
23
|
-
__metaclass__ = abc.ABCMeta
|
|
24
|
-
|
|
25
|
-
@abc.abstractmethod
|
|
26
|
-
def get(self, url):
|
|
27
|
-
"""Gets the content from the memcache with a given key.
|
|
28
|
-
|
|
29
|
-
Args:
|
|
30
|
-
url: string, the key for the cache.
|
|
31
|
-
|
|
32
|
-
Returns:
|
|
33
|
-
object, the value in the cache for the given key, or None if the key is
|
|
34
|
-
not in the cache.
|
|
35
|
-
"""
|
|
36
|
-
raise NotImplementedError()
|
|
37
|
-
|
|
38
|
-
@abc.abstractmethod
|
|
39
|
-
def set(self, url, content):
|
|
40
|
-
"""Sets the given key and content in the cache.
|
|
41
|
-
|
|
42
|
-
Args:
|
|
43
|
-
url: string, the key for the cache.
|
|
44
|
-
content: string, the discovery document.
|
|
45
|
-
"""
|
|
46
|
-
raise NotImplementedError()
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
# Copyright 2014 Google Inc. All Rights Reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
"""File based cache for the discovery document.
|
|
16
|
-
|
|
17
|
-
The cache is stored in a single file so that multiple processes can
|
|
18
|
-
share the same cache. It locks the file whenever accessing to the
|
|
19
|
-
file. When the cache content is corrupted, it will be initialized with
|
|
20
|
-
an empty cache.
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
from __future__ import division
|
|
24
|
-
|
|
25
|
-
import datetime
|
|
26
|
-
import json
|
|
27
|
-
import logging
|
|
28
|
-
import os
|
|
29
|
-
import tempfile
|
|
30
|
-
|
|
31
|
-
try:
|
|
32
|
-
from oauth2client.contrib.locked_file import LockedFile
|
|
33
|
-
except ImportError:
|
|
34
|
-
# oauth2client < 2.0.0
|
|
35
|
-
try:
|
|
36
|
-
from oauth2client.locked_file import LockedFile
|
|
37
|
-
except ImportError:
|
|
38
|
-
# oauth2client > 4.0.0 or google-auth
|
|
39
|
-
raise ImportError(
|
|
40
|
-
"file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth"
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
from . import base
|
|
44
|
-
from ..discovery_cache import DISCOVERY_DOC_MAX_AGE
|
|
45
|
-
|
|
46
|
-
LOGGER = logging.getLogger(__name__)
|
|
47
|
-
|
|
48
|
-
FILENAME = "google-api-python-client-discovery-doc.cache"
|
|
49
|
-
EPOCH = datetime.datetime(1970, 1, 1)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def _to_timestamp(date):
|
|
53
|
-
try:
|
|
54
|
-
return (date - EPOCH).total_seconds()
|
|
55
|
-
except AttributeError:
|
|
56
|
-
# The following is the equivalent of total_seconds() in Python2.6.
|
|
57
|
-
# See also: https://docs.python.org/2/library/datetime.html
|
|
58
|
-
delta = date - EPOCH
|
|
59
|
-
return (
|
|
60
|
-
delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10**6
|
|
61
|
-
) / 10**6
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _read_or_initialize_cache(f):
|
|
65
|
-
f.file_handle().seek(0)
|
|
66
|
-
try:
|
|
67
|
-
cache = json.load(f.file_handle())
|
|
68
|
-
except Exception:
|
|
69
|
-
# This means it opens the file for the first time, or the cache is
|
|
70
|
-
# corrupted, so initializing the file with an empty dict.
|
|
71
|
-
cache = {}
|
|
72
|
-
f.file_handle().truncate(0)
|
|
73
|
-
f.file_handle().seek(0)
|
|
74
|
-
json.dump(cache, f.file_handle())
|
|
75
|
-
return cache
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class Cache(base.Cache):
|
|
79
|
-
"""A file based cache for the discovery documents."""
|
|
80
|
-
|
|
81
|
-
def __init__(self, max_age):
|
|
82
|
-
"""Constructor.
|
|
83
|
-
|
|
84
|
-
Args:
|
|
85
|
-
max_age: Cache expiration in seconds.
|
|
86
|
-
"""
|
|
87
|
-
self._max_age = max_age
|
|
88
|
-
self._file = os.path.join(tempfile.gettempdir(), FILENAME)
|
|
89
|
-
f = LockedFile(self._file, "a+", "r")
|
|
90
|
-
try:
|
|
91
|
-
f.open_and_lock()
|
|
92
|
-
if f.is_locked():
|
|
93
|
-
_read_or_initialize_cache(f)
|
|
94
|
-
# If we can not obtain the lock, other process or thread must
|
|
95
|
-
# have initialized the file.
|
|
96
|
-
except Exception as e:
|
|
97
|
-
LOGGER.warning(e, exc_info=True)
|
|
98
|
-
finally:
|
|
99
|
-
f.unlock_and_close()
|
|
100
|
-
|
|
101
|
-
def get(self, url):
|
|
102
|
-
f = LockedFile(self._file, "r+", "r")
|
|
103
|
-
try:
|
|
104
|
-
f.open_and_lock()
|
|
105
|
-
if f.is_locked():
|
|
106
|
-
cache = _read_or_initialize_cache(f)
|
|
107
|
-
if url in cache:
|
|
108
|
-
content, t = cache.get(url, (None, 0))
|
|
109
|
-
if _to_timestamp(datetime.datetime.now()) < t + self._max_age:
|
|
110
|
-
return content
|
|
111
|
-
return None
|
|
112
|
-
else:
|
|
113
|
-
LOGGER.debug("Could not obtain a lock for the cache file.")
|
|
114
|
-
return None
|
|
115
|
-
except Exception as e:
|
|
116
|
-
LOGGER.warning(e, exc_info=True)
|
|
117
|
-
finally:
|
|
118
|
-
f.unlock_and_close()
|
|
119
|
-
|
|
120
|
-
def set(self, url, content):
|
|
121
|
-
f = LockedFile(self._file, "r+", "r")
|
|
122
|
-
try:
|
|
123
|
-
f.open_and_lock()
|
|
124
|
-
if f.is_locked():
|
|
125
|
-
cache = _read_or_initialize_cache(f)
|
|
126
|
-
cache[url] = (content, _to_timestamp(datetime.datetime.now()))
|
|
127
|
-
# Remove stale cache.
|
|
128
|
-
for k, (_, timestamp) in list(cache.items()):
|
|
129
|
-
if (
|
|
130
|
-
_to_timestamp(datetime.datetime.now())
|
|
131
|
-
>= timestamp + self._max_age
|
|
132
|
-
):
|
|
133
|
-
del cache[k]
|
|
134
|
-
f.file_handle().truncate(0)
|
|
135
|
-
f.file_handle().seek(0)
|
|
136
|
-
json.dump(cache, f.file_handle())
|
|
137
|
-
else:
|
|
138
|
-
LOGGER.debug("Could not obtain a lock for the cache file.")
|
|
139
|
-
except Exception as e:
|
|
140
|
-
LOGGER.warning(e, exc_info=True)
|
|
141
|
-
finally:
|
|
142
|
-
f.unlock_and_close()
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
cache = Cache(max_age=DISCOVERY_DOC_MAX_AGE)
|
gam/googleapiclient/errors.py
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
# Copyright 2014 Google Inc. All Rights Reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
"""Errors for the library.
|
|
16
|
-
|
|
17
|
-
All exceptions defined by the library
|
|
18
|
-
should be defined in this file.
|
|
19
|
-
"""
|
|
20
|
-
from __future__ import absolute_import
|
|
21
|
-
|
|
22
|
-
__author__ = "jcgregorio@google.com (Joe Gregorio)"
|
|
23
|
-
|
|
24
|
-
import json
|
|
25
|
-
|
|
26
|
-
from googleapiclient import _helpers as util
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class Error(Exception):
|
|
30
|
-
"""Base error for this module."""
|
|
31
|
-
|
|
32
|
-
pass
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class HttpError(Error):
|
|
36
|
-
"""HTTP data was invalid or unexpected."""
|
|
37
|
-
|
|
38
|
-
@util.positional(3)
|
|
39
|
-
def __init__(self, resp, content, uri=None):
|
|
40
|
-
self.resp = resp
|
|
41
|
-
if not isinstance(content, bytes):
|
|
42
|
-
raise TypeError("HTTP content should be bytes")
|
|
43
|
-
self.content = content
|
|
44
|
-
self.uri = uri
|
|
45
|
-
self.error_details = ""
|
|
46
|
-
self.reason = self._get_reason()
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def status_code(self):
|
|
50
|
-
"""Return the HTTP status code from the response content."""
|
|
51
|
-
return self.resp.status
|
|
52
|
-
|
|
53
|
-
def _get_reason(self):
|
|
54
|
-
"""Calculate the reason for the error from the response content."""
|
|
55
|
-
reason = self.resp.reason
|
|
56
|
-
try:
|
|
57
|
-
try:
|
|
58
|
-
data = json.loads(self.content.decode("utf-8"))
|
|
59
|
-
except json.JSONDecodeError:
|
|
60
|
-
# In case it is not json
|
|
61
|
-
data = self.content.decode("utf-8")
|
|
62
|
-
if isinstance(data, dict):
|
|
63
|
-
reason = data["error"]["message"]
|
|
64
|
-
error_detail_keyword = next(
|
|
65
|
-
(
|
|
66
|
-
kw
|
|
67
|
-
for kw in ["detail", "details", "errors", "message"]
|
|
68
|
-
if kw in data["error"]
|
|
69
|
-
),
|
|
70
|
-
"",
|
|
71
|
-
)
|
|
72
|
-
if error_detail_keyword:
|
|
73
|
-
self.error_details = data["error"][error_detail_keyword]
|
|
74
|
-
elif isinstance(data, list) and len(data) > 0:
|
|
75
|
-
first_error = data[0]
|
|
76
|
-
reason = first_error["error"]["message"]
|
|
77
|
-
if "details" in first_error["error"]:
|
|
78
|
-
self.error_details = first_error["error"]["details"]
|
|
79
|
-
else:
|
|
80
|
-
self.error_details = data
|
|
81
|
-
except (ValueError, KeyError, TypeError):
|
|
82
|
-
pass
|
|
83
|
-
if reason is None:
|
|
84
|
-
reason = ""
|
|
85
|
-
return reason.strip()
|
|
86
|
-
|
|
87
|
-
def __repr__(self):
|
|
88
|
-
if self.error_details:
|
|
89
|
-
return '<HttpError %s when requesting %s returned "%s". Details: "%s">' % (
|
|
90
|
-
self.resp.status,
|
|
91
|
-
self.uri,
|
|
92
|
-
self.reason,
|
|
93
|
-
self.error_details,
|
|
94
|
-
)
|
|
95
|
-
elif self.uri:
|
|
96
|
-
return '<HttpError %s when requesting %s returned "%s">' % (
|
|
97
|
-
self.resp.status,
|
|
98
|
-
self.uri,
|
|
99
|
-
self.reason,
|
|
100
|
-
)
|
|
101
|
-
else:
|
|
102
|
-
return '<HttpError %s "%s">' % (self.resp.status, self.reason)
|
|
103
|
-
|
|
104
|
-
__str__ = __repr__
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
class InvalidJsonError(Error):
|
|
108
|
-
"""The JSON returned could not be parsed."""
|
|
109
|
-
|
|
110
|
-
pass
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
class UnknownFileType(Error):
|
|
114
|
-
"""File type unknown or unexpected."""
|
|
115
|
-
|
|
116
|
-
pass
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
class UnknownLinkType(Error):
|
|
120
|
-
"""Link type unknown or unexpected."""
|
|
121
|
-
|
|
122
|
-
pass
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
class UnknownApiNameOrVersion(Error):
|
|
126
|
-
"""No API with that name and version exists."""
|
|
127
|
-
|
|
128
|
-
pass
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
class UnacceptableMimeTypeError(Error):
|
|
132
|
-
"""That is an unacceptable mimetype for this operation."""
|
|
133
|
-
|
|
134
|
-
pass
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
class MediaUploadSizeError(Error):
|
|
138
|
-
"""Media is larger than the method can accept."""
|
|
139
|
-
|
|
140
|
-
pass
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
class ResumableUploadError(HttpError):
|
|
144
|
-
"""Error occurred during resumable upload."""
|
|
145
|
-
|
|
146
|
-
pass
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
class InvalidChunkSizeError(Error):
|
|
150
|
-
"""The given chunksize is not valid."""
|
|
151
|
-
|
|
152
|
-
pass
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
class InvalidNotificationError(Error):
|
|
156
|
-
"""The channel Notification is invalid."""
|
|
157
|
-
|
|
158
|
-
pass
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
class BatchError(HttpError):
|
|
162
|
-
"""Error occurred during batch operations."""
|
|
163
|
-
|
|
164
|
-
@util.positional(2)
|
|
165
|
-
def __init__(self, reason, resp=None, content=None):
|
|
166
|
-
self.resp = resp
|
|
167
|
-
self.content = content
|
|
168
|
-
self.reason = reason
|
|
169
|
-
|
|
170
|
-
def __repr__(self):
|
|
171
|
-
if getattr(self.resp, "status", None) is None:
|
|
172
|
-
return '<BatchError "%s">' % (self.reason)
|
|
173
|
-
else:
|
|
174
|
-
return '<BatchError %s "%s">' % (self.resp.status, self.reason)
|
|
175
|
-
|
|
176
|
-
__str__ = __repr__
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
class UnexpectedMethodError(Error):
|
|
180
|
-
"""Exception raised by RequestMockBuilder on unexpected calls."""
|
|
181
|
-
|
|
182
|
-
@util.positional(1)
|
|
183
|
-
def __init__(self, methodId=None):
|
|
184
|
-
"""Constructor for an UnexpectedMethodError."""
|
|
185
|
-
super(UnexpectedMethodError, self).__init__(
|
|
186
|
-
"Received unexpected call %s" % methodId
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
class UnexpectedBodyError(Error):
|
|
191
|
-
"""Exception raised by RequestMockBuilder on unexpected bodies."""
|
|
192
|
-
|
|
193
|
-
def __init__(self, expected, provided):
|
|
194
|
-
"""Constructor for an UnexpectedMethodError."""
|
|
195
|
-
super(UnexpectedBodyError, self).__init__(
|
|
196
|
-
"Expected: [%s] - Provided: [%s]" % (expected, provided)
|
|
197
|
-
)
|