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

--all flag fails to produce output #9

Closed
Gnafu opened this issue Apr 6, 2018 · 6 comments
Closed

--all flag fails to produce output #9

Gnafu opened this issue Apr 6, 2018 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Gnafu
Copy link

Gnafu commented Apr 6, 2018

The standard: "python list_lambdas.py" command completes successfully, but if I add the "--all" flag the following message is produced:

python list_lambdas.py --all
100% (15 of 15) |#############################################################################################################################| Elapsed Time: 0:00:23 Time: 0:00:23
Traceback (most recent call last):
  File "list_lambdas.py", line 251, in <module>
    print_lambda_list(arguments)
  File "list_lambdas.py", line 191, in print_lambda_list
    print(table.table)
  File "C:\Python36\lib\site-packages\terminaltables\base_table.py", line 216, in table
    dimensions = max_dimensions(self.table_data, self.padding_left, self.padding_right)[:3]
  File "C:\Python36\lib\site-packages\terminaltables\width_and_alignment.py", line 106, in max_dimensions
    inner_heights[j] = max(inner_heights[j], cell.count('\n') + 1)
TypeError: a bytes-like object is required, not 'str'

I'm on Windows 10 with Python 3.6.4

@nshap
Copy link
Contributor

nshap commented Apr 18, 2018

@Gnafu can you please provide a more detailed output? It seems like an issue with the table formatting. Can you provide the original data using "print" in the code?

@Gnafu
Copy link
Author

Gnafu commented Apr 18, 2018

@nshap Sure, which variable you want me to print? (and where in the code? :) )

@nshap
Copy link
Contributor

nshap commented Apr 18, 2018

It seems that the cell.count('\n') fails. According to this thread, this might be an encoding issue: https://stackoverflow.com/questions/33054527/python-3-5-typeerror-a-bytes-like-object-is-required-not-str-when-writing-t

Can you add the following statement before line 191? print(table.table_data)

This should help understand the object which goes through.

@Gnafu
Copy link
Author

Gnafu commented Apr 18, 2018

Here you go:

[['Region', 'Function', 'Memory (MB)', 'Code Size (MB)', 'Timeout (seconds)', 'Runtime', 'Description', 'Last Modified', 'Last Invocation'], ['us-west-2', 'REDACTED', '512', '0.00', '15', 'java8', b'', '21 days ago', 'N/A (no invocations?)'], ['us-west-2', 'REDACTED', '128', '0.00', '3', 'nodejs4.3', b'', '134 days ago', '36 days ago'], ['us-west-2', 'REDACTED', '128', '0.00', '3', 'python3.6', b'', '12 days ago', '12 days ago'], ['us-west-2', 'REDACTED', '256', '18.74', '30', 'java8', b'', '50 days ago', '50 days ago'], ['us-west-2', 'REDACTED', '128', '0.00', '3', 'nodejs6.10', b'', '25 days ago', '25 days ago'], ['us-west-2', 'REDACTED', '192', '8.80', '40', 'java8', b'this is redacted', '40 days ago', 'Today'], ['us-west-2', 'REDACTED', '512', '13.82', '15', 'java8', b'', '13 days ago', 'Yesterday']]

@nshap
Copy link
Contributor

nshap commented Apr 18, 2018

Problem reproduced with Python 3. It is because the "Description" field is byte instead of string:
image

I believe removing the encode('utf-8') should fix that. Creating a fix.

nshap added a commit that referenced this issue Apr 18, 2018
nshap added a commit that referenced this issue Apr 18, 2018
Removing uft-8 encoding, fixing #9
@nshap
Copy link
Contributor

nshap commented Apr 18, 2018

Fixed by #10.

@nshap nshap closed this as completed Apr 18, 2018
@nshap nshap added the bug Something isn't working label Apr 18, 2018
@nshap nshap self-assigned this Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants