Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read file in bytes using fileb:// #1010

Merged
merged 3 commits into from
Nov 20, 2014
Merged

Add read file in bytes using fileb:// #1010

merged 3 commits into from
Nov 20, 2014

Conversation

kyleknap
Copy link
Contributor

Fixes #814, #815

If you want to read the file as binary, simply prepend file name with fileb:// instead of file://

cc @jamesls @danielgtaylor

try:
LOG.debug('Unpacked value of "%s" for parameter "%s": %s',
value, self.py_name, unpacked)
except UnicodeDecodeError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just use %r always? I think we if we remove the quotes from the "%s" it should look almost the same.

'Unpacked value of %r for param %s: %r'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be good with changing that as it would mean less code to maintain. I only originally had it in there to avoid the least amount of change in behavior. Yet again if anything changes in the debug output, it should be minimal because we would only be using repr() instead of str()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'd test to make sure, but I think just using %r always would be easier to maintain. It's a debug log anyways so we're free to alter the messages and the formatting.

@jamesls
Copy link
Member

jamesls commented Nov 19, 2014

I believe one of the test failures will be fixed once boto/botocore#383 is merged, but it looks like there's another test failure as well where we aren't checking the file contents as bytes:

AssertionError: b'This is a test' != 'This is a test'

https://travis-ci.org/aws/aws-cli/jobs/41430653#L576

Otherwise looks good.

@jamesls
Copy link
Member

jamesls commented Nov 20, 2014

:shipit: Looks good.

kyleknap added a commit that referenced this pull request Nov 20, 2014
Add read file in bytes using fileb://
@kyleknap kyleknap merged commit 2404108 into aws:develop Nov 20, 2014
@spazm
Copy link

spazm commented Nov 20, 2014

Thanks Kyle. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--user-data is broken if file contains non-utf-8 characters
3 participants