Skip to content

Commit

Permalink
Update code with botocore changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleknap committed Nov 20, 2014
1 parent 59e3678 commit 4da2697
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 2 additions & 6 deletions awscli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,8 @@ def add_to_params(self, parameters, value):
# below. Sometimes this can be more complicated, and subclasses
# can customize as they need.
unpacked = self._unpack_argument(value)
try:
LOG.debug('Unpacked value of "%s" for parameter "%s": %s',
value, self.py_name, unpacked)
except UnicodeDecodeError:
LOG.debug('Unpacked value of "%r" for parameter "%s": %r',
value, self.py_name, unpacked)
LOG.debug('Unpacked value of %r for parameter "%s": %r', value,
self.py_name, unpacked)
parameters[self._serialized_name] = unpacked

def _unpack_argument(self, value):
Expand Down
7 changes: 5 additions & 2 deletions awscli/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def __init__(self):
def remove_all(self):
shutil.rmtree(self.rootdir)

def create_file(self, filename, contents, mtime=None):
def create_file(self, filename, contents, mtime=None, mode='w'):
"""Creates a file in a tmpdir
``filename`` should be a relative path, e.g. "foo/bar/baz.txt"
Expand All @@ -367,13 +367,16 @@ def create_file(self, filename, contents, mtime=None):
mtime will be set to the provided value (must be an epoch time).
Otherwise the mtime is left untouched.
``mode`` is the mode the file should be opened either as ``w`` or
`wb``.
Returns the full path to the file.
"""
full_path = os.path.join(self.rootdir, filename)
if not os.path.isdir(os.path.dirname(full_path)):
os.makedirs(os.path.dirname(full_path))
with open(full_path, 'w') as f:
with open(full_path, mode) as f:
f.write(contents)
current_time = os.path.getmtime(full_path)
# Subtract a few years off the last modification date.
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/s3/test_put_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def test_website_redirect(self):

def test_sse_key_with_binary_file(self):
# Create contents that do not get mapped to ascii
contents = '\xc2'
filename = self.files.create_file('key', contents)
contents = b'\xc2'
filename = self.files.create_file('key', contents, mode='wb')
cmdline = self.prefix
cmdline += ' --bucket mybucket'
cmdline += ' --key mykey'
Expand All @@ -105,7 +105,8 @@ def test_sse_key_with_binary_file(self):
'Bucket': 'mybucket',
'Key': 'mykey',
'SSECustomerAlgorithm': 'AES256',
'SSECustomerKey': contents
'SSECustomerKey': 'wg==', # Note the key gets base64 encoded.
'SSECustomerKeyMD5': 'ZGXa0dMXUr4/MoPo9w/u9w=='
}
self.assert_params_for_cmd2(cmdline, expected)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_paramfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ def test_binary_file(self):
filename = self.files.create_file('foo', contents)
prefixed_filename = 'fileb://' + filename
data = get_paramfile(prefixed_filename)
self.assertEqual(data, contents)
self.assertEqual(data, b'This is a test')
self.assertIsInstance(data, six.binary_type)

0 comments on commit 4da2697

Please sign in to comment.