本文整理汇总了Python中six.moves.http_client.NOT_FOUND属性的典型用法代码示例。如果您正苦于以下问题:Python http_client.NOT_FOUND属性的具体用法?Python http_client.NOT_FOUND怎么用?Python http_client.NOT_FOUND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类six.moves.http_client
的用法示例。
在下文中一共展示了http_client.NOT_FOUND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_for_new_build_config_instance
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def wait_for_new_build_config_instance(self, build_config_id, prev_version):
logger.info("waiting for build config %s to get instantiated", build_config_id)
for changetype, obj in self.watch_resource("buildconfigs", build_config_id):
if changetype in (None, WATCH_MODIFIED):
version = graceful_chain_get(obj, 'status', 'lastVersion')
if not isinstance(version, numbers.Integral):
logger.error("BuildConfig %s has unexpected lastVersion: %s", build_config_id,
version)
continue
if version > prev_version:
return "%s-%s" % (build_config_id, version)
if changetype == WATCH_DELETED:
logger.error("BuildConfig deleted while waiting for new build instance")
break
raise OsbsResponseException("New BuildConfig instance not found",
http_client.NOT_FOUND)
示例2: _test_get_run_by_id
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def _test_get_run_by_id(self):
response = self.app.get('/runs/1234')
self.assertEqual(http_client.NOT_FOUND, response.status_code)
pb = 'tests/fixtures/playbooks/hello_world.yml'
response = self.app.post(
'/runs',
data=json.dumps(dict(playbook_path=pb,
inventory_file='localhosti,',
options={'connection': 'local'})),
content_type='application/json')
res_dict = json.loads(response.data)
run_id = res_dict['id']
self.assertEqual(http_client.CREATED, response.status_code)
response = self.app.get('/runs/{}'.format(run_id))
self.assertEqual(http_client.OK, response.status_code)
self._wait_for_run_complete(run_id)
示例3: _get_object
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def _get_object(self, location, manager, start=None):
headers = {}
if start is not None:
bytes_range = 'bytes=%d-' % start
headers = {'Range': bytes_range}
try:
resp_headers, resp_body = manager.get_connection().get_object(
location.container, location.obj,
resp_chunk_size=self.CHUNKSIZE, headers=headers)
except swiftclient.ClientException as e:
if e.http_status == http_client.NOT_FOUND:
msg = _("Swift could not find object %s.") % location.obj
LOG.warning(msg)
raise exceptions.NotFound(message=msg)
else:
raise
return (resp_headers, resp_body)
示例4: test__process_response_bad_status
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def test__process_response_bad_status(self):
download = _download.Download(EXAMPLE_URL)
_fix_up_virtual(download)
# Make sure **not finished** before.
assert not download.finished
response = mock.Mock(
status_code=int(http_client.NOT_FOUND), spec=["status_code"]
)
with pytest.raises(common.InvalidResponse) as exc_info:
download._process_response(response)
error = exc_info.value
assert error.response is response
assert len(error.args) == 5
assert error.args[1] == response.status_code
assert error.args[3] == http_client.OK
assert error.args[4] == http_client.PARTIAL_CONTENT
# Make sure **finished** even after a failure.
assert download.finished
示例5: test__process_response_bad_status
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def test__process_response_bad_status(self):
upload = _upload.ResumableUpload(RESUMABLE_URL, ONE_MB)
_fix_up_virtual(upload)
# Make sure the upload is valid before the failure.
assert not upload.invalid
response = _make_response(status_code=http_client.NOT_FOUND)
with pytest.raises(common.InvalidResponse) as exc_info:
upload._process_response(response, None)
error = exc_info.value
assert error.response is response
assert len(error.args) == 5
assert error.args[1] == response.status_code
assert error.args[3] == http_client.OK
assert error.args[4] == resumable_media.PERMANENT_REDIRECT
# Make sure the upload is invalid after the failure.
assert upload.invalid
示例6: _authorize
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def _authorize(self):
"""Performs authorization setting x-auth-session."""
self.headers['authorization'] = 'Basic %s' % self.auth_str
if 'x-auth-session' in self.headers:
del self.headers['x-auth-session']
try:
result = self.post("/access/v1")
del self.headers['authorization']
if result.status == http_client.CREATED:
self.headers['x-auth-session'] = (
result.get_header('x-auth-session'))
self.do_logout = True
log_debug_msg(self, ('ZFSSA version: %s')
% result.get_header('x-zfssa-version'))
elif result.status == http_client.NOT_FOUND:
raise RestClientError(result.status, name="ERR_RESTError",
message=("REST Not Available:"
"Please Upgrade"))
except RestClientError:
del self.headers['authorization']
raise
示例7: test_exists_miss
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def test_exists_miss(self):
NONESUCH = "nonesuch"
not_found_response = ({"status": http_client.NOT_FOUND}, b"")
connection = _Connection(not_found_response)
client = _Client(connection)
bucket = _Bucket(client)
blob = self._make_one(NONESUCH, bucket=bucket)
self.assertFalse(blob.exists(timeout=42))
self.assertEqual(len(connection._requested), 1)
self.assertEqual(
connection._requested[0],
{
"method": "GET",
"path": "/b/name/o/{}".format(NONESUCH),
"query_params": {"fields": "name"},
"_target_object": None,
"timeout": 42,
},
)
示例8: test_delete_wo_generation
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def test_delete_wo_generation(self):
BLOB_NAME = "blob-name"
not_found_response = ({"status": http_client.NOT_FOUND}, b"")
connection = _Connection(not_found_response)
client = _Client(connection)
bucket = _Bucket(client)
blob = self._make_one(BLOB_NAME, bucket=bucket)
bucket._blobs[BLOB_NAME] = 1
blob.delete()
self.assertFalse(blob.exists())
self.assertEqual(
bucket._deleted,
[
(
BLOB_NAME,
None,
None,
self._get_default_timeout(),
None,
None,
None,
None,
)
],
)
示例9: test_instantiate_with_non_existing_vnf_instance
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def test_instantiate_with_non_existing_vnf_instance(
self, mock_vnf_by_id):
mock_vnf_by_id.side_effect = exceptions.VnfInstanceNotFound
body = {"flavourId": "simple"}
req = fake_request.HTTPRequest.blank(
'/vnf_instances/%s/instantiate' % uuidsentinel.vnf_instance_id)
req.body = jsonutils.dump_as_bytes(body)
req.headers['Content-Type'] = 'application/json'
req.method = 'POST'
# Call Instantiate API
resp = req.get_response(self.app)
self.assertEqual(http_client.NOT_FOUND, resp.status_code)
self.assertEqual("Can not find requested vnf instance: %s" %
uuidsentinel.vnf_instance_id,
resp.json['itemNotFound']['message'])
示例10: test_terminate_non_existing_vnf_instance
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def test_terminate_non_existing_vnf_instance(self, mock_vnf_by_id):
body = {'terminationType': 'GRACEFUL',
'gracefulTerminationTimeout': 10}
mock_vnf_by_id.side_effect = exceptions.VnfInstanceNotFound
req = fake_request.HTTPRequest.blank(
'/vnf_instances/%s/terminate' % uuidsentinel.vnf_instance_id)
req.body = jsonutils.dump_as_bytes(body)
req.headers['Content-Type'] = 'application/json'
req.method = 'POST'
resp = req.get_response(self.app)
self.assertEqual(http_client.NOT_FOUND, resp.status_code)
self.assertEqual("Can not find requested vnf instance: %s" %
uuidsentinel.vnf_instance_id,
resp.json['itemNotFound']['message'])
示例11: get_one
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def get_one(self, ref_or_id, requester_user):
try:
trigger_db = self._get_by_ref_or_id(ref_or_id=ref_or_id)
except Exception as e:
LOG.exception(six.text_type(e))
abort(http_client.NOT_FOUND, six.text_type(e))
return
permission_type = PermissionType.TIMER_VIEW
resource_db = TimerDB(pack=trigger_db.pack, name=trigger_db.name)
rbac_utils = get_rbac_backend().get_utils_class()
rbac_utils.assert_user_has_resource_db_permission(user_db=requester_user,
resource_db=resource_db,
permission_type=permission_type)
result = self.model.from_model(trigger_db)
return result
示例12: init
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def init(api, _cors, impl):
"""Configures REST handlers for allocation resource."""
namespace = webutils.namespace(
api, __name__, 'Local nodeinfo redirect API.'
)
@namespace.route('/<hostname>/<path:path>')
class _NodeRedirect(restplus.Resource):
"""Redirects to local nodeinfo endpoint."""
def get(self, hostname, path):
"""Returns list of local instances."""
hostport = impl.get(hostname)
if not hostport:
return 'Host not found.', http_client.NOT_FOUND
url = utils.encode_uri_parts(path)
return flask.redirect('http://%s/%s' % (hostport, url),
code=http_client.FOUND)
示例13: test_get_image_stream_tag_with_retry_retries
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def test_get_image_stream_tag_with_retry_retries(self):
config = Configuration(conf_name=None)
osbs_obj = OSBS(config, config)
name = 'buildroot:latest'
(flexmock(osbs_obj.os)
.should_call('get_image_stream_tag_with_retry')
.with_args(name))
class MockResponse(object):
def __init__(self, status, json=None, content=None):
self.status_code = status
self._json = json or {}
if content:
self.content = content
def json(self):
return self._json
test_json = {'image': {'dockerImageReference': 'spam:maps'}}
bad_response = MockResponse(http_client.NOT_FOUND, None, "not found failure")
good_response = MockResponse(http_client.OK, test_json)
(flexmock(osbs_obj.os)
.should_receive('_get')
.times(2)
.and_return(bad_response)
.and_return(good_response))
response = osbs_obj.get_image_stream_tag_with_retry(name)
ref = response.json()['image']['dockerImageReference']
assert ref == 'spam:maps'
示例14: retry_on_not_found
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def retry_on_not_found(func):
@wraps(func)
def retry(*args, **kwargs):
# Only retry when OsbsResponseException was raised due to not found
def should_retry_cb(ex):
return ex.status_code == http_client.NOT_FOUND
retry_func = RetryFunc(OsbsResponseException, should_retry_cb=should_retry_cb,
retry_times=OS_NOT_FOUND_MAX_RETRIES,
retry_delay=OS_NOT_FOUND_MAX_WAIT)
return retry_func.go(func, *args, **kwargs)
return retry
示例15: delete_resource_quota
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NOT_FOUND [as 别名]
def delete_resource_quota(self, name):
url = self._build_k8s_url("resourcequotas/%s" % name)
response = self._delete(url)
if response.status_code != http_client.NOT_FOUND:
check_response(response)
return response