Merge branch 'master' into 4232-slow-pipes-n-jobs
[arvados.git] / sdk / python / arvados / keep.py
index f98f899616a6613c958d6cbf345ba6b99320e8e2..71dc7ce7af863f60fb9e741b7bbc1231c22b146b 100644 (file)
@@ -394,11 +394,11 @@ class KeepClient(object):
                     replicas_stored = int(result.headers['x-keep-replicas-stored'])
                 except (KeyError, ValueError):
                     replicas_stored = 1
-                limiter.save_response(result.text.strip(), replicas_stored)
+                limiter.save_response(result.content.strip(), replicas_stored)
             elif status is not None:
                 _logger.debug("Request fail: PUT %s => %s %s",
                               self.args['data_hash'], status,
-                              self.service.last_result.text)
+                              self.service.last_result.content)
 
 
     def __init__(self, api_client=None, proxy=None,
@@ -684,6 +684,12 @@ class KeepClient(object):
           exponential backoff.  The default value is set when the
           KeepClient is initialized.
         """
+
+        if isinstance(data, unicode):
+            data = data.encode("ascii")
+        elif not isinstance(data, str):
+            raise arvados.errors.ArgumentError("Argument 'data' to KeepClient.put must be type 'str'")
+
         data_hash = hashlib.md5(data).hexdigest()
         if copies < 1:
             return data_hash
@@ -739,8 +745,8 @@ class KeepClient(object):
     def local_store_put(self, data, copies=1, num_retries=None):
         """A stub for put().
 
-        This method is used in place of the real put() method in a
-        KeepClient constructed with local_store=True.
+        This method is used in place of the real put() method when
+        using local storage (see constructor's local_store argument).
 
         copies and num_retries arguments are ignored: they are here
         only for the sake of offering the same call signature as