summaryrefslogtreecommitdiff
path: root/openstackclient/api/object_store_v1.py
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2014-10-08 23:22:24 -0500
committerDean Troyer <dtroyer@gmail.com>2014-10-13 10:34:11 -0500
commitbcf4b3caece9edc6a04be3ce59697301e48ad34a (patch)
tree1117bb54795950170c26432dc0957d58790b2752 /openstackclient/api/object_store_v1.py
parent49c74229b4073b1572357b074e78e2c4674632e7 (diff)
downloadpython-openstackclient-bcf4b3caece9edc6a04be3ce59697301e48ad34a.tar.gz
Update use of open() in object API
* Switch to use io.open() for py3 compatibility and simpler testing. * Open files in 'rb' mode to avoid translation on Windows Previously tests simply relied on files that were present in the repository to run tests using open(). Change the filenames to ensure that no longer happens. requests_mock doesn't have a way to match against the request body for PUT/POST; an attempt to add a new Matcher to do that worked but it needs to subclass the currently private adapter._Matcher class or duplicate most of its functionality. Change-Id: I8c30b41db20af8ecafe67e760e872fc08adec905
Diffstat (limited to 'openstackclient/api/object_store_v1.py')
-rw-r--r--openstackclient/api/object_store_v1.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py
index 57db9063..c52eeb3a 100644
--- a/openstackclient/api/object_store_v1.py
+++ b/openstackclient/api/object_store_v1.py
@@ -13,6 +13,7 @@
"""Object Store v1 API Library"""
+import io
import os
import six
@@ -187,7 +188,12 @@ class APIv1(api.BaseAPI):
return {}
full_url = "%s/%s" % (container, object)
- response = self.create(full_url, method='PUT', data=open(object))
+ with io.open(object, 'rb') as f:
+ response = self.create(
+ full_url,
+ method='PUT',
+ data=f,
+ )
url_parts = urlparse(self.endpoint)
data = {
'account': url_parts.path.split('/')[-1],