import types
import apiclient
-import apiclient.discovery
-import apiclient.errors
+from apiclient import discovery as apiclient_discovery
+from apiclient import errors as apiclient_errors
import config
import errors
import util
# Monkey patch discovery._cast() so objects and arrays get serialized
# with json.dumps() instead of str().
-_cast_orig = apiclient.discovery._cast
+_cast_orig = apiclient_discovery._cast
def _cast_objects_too(value, schema_type):
global _cast_orig
if (type(value) != type('') and
return json.dumps(value)
else:
return _cast_orig(value, schema_type)
-apiclient.discovery._cast = _cast_objects_too
+apiclient_discovery._cast = _cast_objects_too
# Convert apiclient's HttpErrors into our own API error subclass for better
# error reporting.
-# Reassigning apiclient.errors.HttpError is not sufficient because most of the
+# Reassigning apiclient_errors.HttpError is not sufficient because most of the
# apiclient submodules import the class into their own namespace.
def _new_http_error(cls, *args, **kwargs):
- return super(apiclient.errors.HttpError, cls).__new__(
+ return super(apiclient_errors.HttpError, cls).__new__(
errors.ApiError, *args, **kwargs)
-apiclient.errors.HttpError.__new__ = staticmethod(_new_http_error)
+apiclient_errors.HttpError.__new__ = staticmethod(_new_http_error)
def http_cache(data_type):
path = os.environ['HOME'] + '/.cache/arvados/' + data_type
* insecure: If True, ignore SSL certificate validation errors.
Additional keyword arguments will be passed directly to
- `apiclient.discovery.build` if a new Resource object is created.
+ `apiclient_discovery.build` if a new Resource object is created.
If the `discoveryServiceUrl` or `http` keyword arguments are
missing, this function will set default values for them, based on
the current Arvados configuration settings.
credentials = CredentialsFromToken(api_token=token)
kwargs['http'] = credentials.authorize(kwargs['http'])
- svc = apiclient.discovery.build('arvados', version, **kwargs)
+ svc = apiclient_discovery.build('arvados', version, **kwargs)
svc.api_token = token
kwargs['http'].cache = None
if cache:
# TODO:
# --md5sum - display md5 of each file as read from disk
-import apiclient.errors
import argparse
import arvados
import base64
import socket
import sys
import tempfile
+from apiclient import errors as apiclient_errors
import arvados.commands._util as arv_cmd
try:
project_uuid = desired_project_uuid(api_client, args.project_uuid,
args.retries)
- except (apiclient.errors.Error, ValueError) as error:
+ except (apiclient_errors.Error, ValueError) as error:
print >>stderr, error
sys.exit(1)
else:
output = collection['uuid']
- except apiclient.errors.Error as error:
+ except apiclient_errors.Error as error:
print >>stderr, (
"arv-put: Error creating Collection on project: {}.".format(
error))
# errors.py - Arvados-specific exceptions.
-import apiclient.errors
import json
+from apiclient import errors as apiclient_errors
-class ApiError(apiclient.errors.HttpError):
+class ApiError(apiclient_errors.HttpError):
def _get_reason(self):
try:
return '; '.join(json.loads(self.content)['errors'])
],
install_requires=[
'python-gflags',
- 'google-api-python-client<1.3',
+ 'google-api-python-client',
'httplib2',
'urllib3',
'ws4py'
#!/usr/bin/env python
-import apiclient.errors
import arvados
import httplib2
import json
import os
import run_test_server
import unittest
+from apiclient import errors as apiclient_errors
+from apiclient import http as apiclient_http
-from apiclient.http import RequestMockBuilder
from arvados_testutil import fake_httplib2_response
if not mimetypes.inited:
'arvados.humans.list': (None, json.dumps(
{'items_available': 0, 'items': []})),
}
- req_builder = RequestMockBuilder(mock_responses)
+ req_builder = apiclient_http.RequestMockBuilder(mock_responses)
cls.api = arvados.api('v1', cache=False,
host=os.environ['ARVADOS_API_HOST'],
token='discovery-doc-only-no-token-needed',
self.assertEqual(answer['items_available'], len(answer['items']))
def test_exceptions_include_errors(self):
- with self.assertRaises(apiclient.errors.HttpError) as err_ctx:
+ with self.assertRaises(apiclient_errors.HttpError) as err_ctx:
self.api.humans().get(uuid='xyz-xyz-abcdef').execute()
err_s = str(err_ctx.exception)
for msg in ["Bad UUID format", "Bad output format"]:
self.assertIn(msg, err_s)
def test_exceptions_without_errors_have_basic_info(self):
- with self.assertRaises(apiclient.errors.HttpError) as err_ctx:
+ with self.assertRaises(apiclient_errors.HttpError) as err_ctx:
self.api.humans().delete(uuid='xyz-xyz-abcdef').execute()
self.assertIn("500", str(err_ctx.exception))
import logging
import ssl
-import apiclient.errors as apierror
import arvados
import httplib2
import libcloud.common.types as cloud_types
import pykka
+from apiclient import errors as apierror
# IOError is the base class for socket.error and friends.
# It seems like it hits the sweet spot for operations we want to retry: