[ARVADOS] updated: 4c69fbec263b5eeea23d11ee93fb002d028e2b6f
git at public.curoverse.com
git at public.curoverse.com
Thu Jan 2 18:53:31 EST 2014
Summary of changes:
sdk/python/arvados/__init__.py | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
via 4c69fbec263b5eeea23d11ee93fb002d028e2b6f (commit)
from c185e2e2eb0a411b40e8d34c5e0bfe31addedcff (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 4c69fbec263b5eeea23d11ee93fb002d028e2b6f
Author: Tom Clegg <tom at curoverse.com>
Date: Thu Jan 2 15:50:46 2014 -0800
Serialize objects/arrays in query params with json.dumps() instead of str().
closes #1818
diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index f3c7397..ba220cc 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -18,8 +18,8 @@ import fcntl
import time
import threading
-from apiclient import errors
-from apiclient.discovery import build
+import apiclient
+import apiclient.discovery
if 'ARVADOS_DEBUG' in os.environ:
logging.basicConfig(level=logging.DEBUG)
@@ -98,6 +98,18 @@ def current_job():
def getjobparam(*args):
return current_job()['script_parameters'].get(*args)
+# Monkey patch discovery._cast() so objects and arrays get serialized
+# with json.dumps() instead of str().
+_cast_orig = apiclient.discovery._cast
+def _cast_objects_too(value, schema_type):
+ global _cast_orig
+ if (type(value) != type('') and
+ (schema_type == 'object' or schema_type == 'array')):
+ return json.dumps(value)
+ else:
+ return _cast_orig(value, schema_type)
+apiclient.discovery._cast = _cast_objects_too
+
def api(version=None):
global services
if not services.get(version):
@@ -123,7 +135,7 @@ def api(version=None):
if re.match(r'(?i)^(true|1|yes)$',
os.environ.get('ARVADOS_API_HOST_INSECURE', '')):
http.disable_ssl_certificate_validation=True
- services[version] = build(
+ services[version] = apiclient.discovery.build(
'arvados', apiVersion, http=http, discoveryServiceUrl=url)
return services[version]
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list