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

ls output misaligned (formatting issue) #956

Closed
vpresnyak opened this issue Feb 13, 2018 · 2 comments
Closed

ls output misaligned (formatting issue) #956

vpresnyak opened this issue Feb 13, 2018 · 2 comments

Comments

@vpresnyak
Copy link

vpresnyak commented Feb 13, 2018

Hello,

I've had some issues with the output of the ls command. It seems to misalign files, which makes them hard to read. This started with the upgrade to py3 and v2.0.1 - previous versions of s3cmd didn't seem to have this issue.

$ s3cmd ls s3://my_bucket/files/2017/

2017-03-10 17:29 14069483520   s3://my_bucket/files/2017/file1.tar
2017-03-10 17:29 32289597440   s3://my_bucket/files/2017/file2.tar
2017-03-15 16:13 283443200   s3://my_bucket/files/2017/file3.tar
2017-03-10 16:51 9882787840   s3://my_bucket/files/2017/file4.tar
2017-10-23 21:15 66645022720   s3://my_bucket/files/2017/file5.tar
2017-08-04 22:03 229539840   s3://my_bucket/files/2017/file6.tar
2017-03-10 16:48 12873990656   s3://my_bucket/files/2017/file7.tar

oddly, adding the --human-readable-sizes parameter only makes things worse. It doesn't look like it's rounding correctly.

$ s3cmd ls -H s3://my_bucket/files/2017/

2017-03-10 17:29 13.103227615356445G  s3://my_bucket/files/2017/file1.tar
2017-03-10 17:29 30.072031021118164G  s3://my_bucket/files/2017/file2.tar
2017-03-15 16:13  270.3125M  s3://my_bucket/files/2017/file3.tar
2017-03-10 16:51 9.204063415527344G  s3://my_bucket/files/2017/file4.tar
2017-10-23 21:15 62.06801414489746G  s3://my_bucket/files/2017/file5.tar
2017-08-04 22:03 218.90625M  s3://my_bucket/files/2017/file6.tar
2017-03-10 16:48 11.989838123321533G  s3://my_bucket/files/2017/file7.tar

Thanks!

@mouchar
Copy link
Contributor

mouchar commented Mar 5, 2018

The first issue (misaligned columns) appears with older Python and older s3cmd as well.
It is caused by too narrow column size for object size (9 characters) as defined in format_string u"%(timestamp)16s %(size)9s%(coeff)1s %(uri)s"
As big file sizes are quite common these days, format might be extended at the expense of wider rows.

Problem with human-readable-sizes is definitely caused by the change how division is made by Python.
While Python 2 returns integer, Python 3 returns float. Simple wrapping with int() could improve the output and get rid of those ugly floats.

fviard added a commit to fviard/s3cmd that referenced this issue Jul 22, 2018
… multiple of 1024

Important note fot automatic scripts:
Output change: "125k" in will now be 125K
@fviard fviard closed this as completed in 16bec96 Jul 22, 2018
@fviard
Copy link
Contributor

fviard commented Jul 22, 2018

@mouchar was right that the alignment issue was also caused by too narrow columns.
I did change the column sizes and alignments to better fit big files and datasets.
Let's hope that the wider rows will not annoy too many people and that this change will not hurt too many automatic scripts that would be parsing the output.

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

No branches or pull requests

3 participants