Skip to content

Commit b22a007

Browse files
author
Jon Wayne Parrott
committed
Start removing httplib2 usage from datastore
1 parent a88a6d9 commit b22a007

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

bigquery/google/cloud/bigquery/table.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
"""Define API Datasets."""
1616

17+
import collections
1718
import datetime
1819
import os
1920

20-
import httplib2
2121
import six
2222

2323
import google.auth.transport.requests
@@ -50,6 +50,8 @@
5050
'{:d} bytes remaining.')
5151
_DEFAULT_NUM_RETRIES = 6
5252

53+
_FakeResponse = collections.namedtuple('_FakeResponse', ['status'])
54+
5355

5456
class Table(object):
5557
"""Tables represent a set of rows whose values correspond to a schema.
@@ -1314,6 +1316,6 @@ def _raise_from_invalid_response(error, error_info=None):
13141316
to the failed status code
13151317
"""
13161318
response = error.response
1317-
faux_response = httplib2.Response({'status': response.status_code})
1319+
faux_response = _FakeResponse(status=response.status_code)
13181320
raise make_exception(faux_response, response.content,
13191321
error_info=error_info, use_json=False)

bigquery/tests/system.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def setUp(self):
8787

8888
def tearDown(self):
8989
from google.cloud.bigquery.dataset import Dataset
90-
from google.cloud.storage import Bucket
90+
#from google.cloud.storage import Bucket
91+
# TODO: FIX
92+
Bucket = None
9193
from google.cloud.exceptions import BadRequest
9294
from google.cloud.exceptions import Conflict
9395

datastore/google/cloud/datastore/_http.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,17 @@ def _request(http, project, method, data, base_url):
6868
connection_module.CLIENT_INFO_HEADER: _CLIENT_INFO,
6969
}
7070
api_url = build_api_url(project, method, base_url)
71-
headers, content = http.request(
72-
uri=api_url, method='POST', headers=headers, body=data)
71+
response = http.request(
72+
url=api_url, method='POST', headers=headers, data=data)
7373

74-
status = headers['status']
75-
if status != '200':
76-
error_status = status_pb2.Status.FromString(content)
74+
if response.status_code != 200:
75+
error_status = status_pb2.Status.FromString(response.content)
76+
# TODO: Fix
77+
raise exceptions.GoogleCloudError(error_status.message)
7778
raise exceptions.make_exception(
7879
headers, error_status.message, use_json=False)
7980

80-
return content
81+
return response.content
8182

8283

8384
def _rpc(http, project, method, base_url, request_pb, response_pb_cls):

0 commit comments

Comments
 (0)