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

Diferent behaviour if du arguments has a final slash #4

Open
funollet opened this issue Feb 20, 2012 · 0 comments
Open

Diferent behaviour if du arguments has a final slash #4

funollet opened this issue Feb 20, 2012 · 0 comments

Comments

@funollet
Copy link
Contributor

Two test files have been generated on my system with

$ du /boot > test1
$ du /boot/ > test2

I created a couple of tests, checking that read_du_file_maybe() generates the same dictionary for both. You can find the test code and the generated files on my fork (just run py.test on the dircloud root directory).

dircloud runs ok with the first file; visiting `http://localhost:2010:/boot/' gets:

$ ./dircloud.py tests/fixtures/du.boot

Bottle server starting up (using WSGIRefServer())...
Listening on http://localhost:2010/
Hit Ctrl-C to quit.

dirpath = [boot/]
localhost - - [20/Feb/2012 17:04:24] "GET /boot/ HTTP/1.1" 200 3468

While the other file raises an exception for the same request:

$ ./dircloud.py tests/fixtures/du.boot_with_final_slash 

Bottle server starting up (using WSGIRefServer())...
Listening on http://localhost:2010/
Hit Ctrl-C to quit.

dirpath = [boot/]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 737, in _handle
    return route.call(**args)
  File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 1456, in wrapper
    rv = callback(*a, **ka)
  File "./dircloud.py", line 106, in dircloud
    search='', body=cloud, footer=footer)
  File "./dircloud.py", line 312, in make_html_page
    filesize = du[dirpath.rstrip(read_from_disk)]
KeyError: 'boot/'
localhost - - [20/Feb/2012 17:04:34] "GET /boot/ HTTP/1.1" 500 1416

I've added a print du just before the line raising the exception. I don't fully understand why, but that's what it shows:

{'boot/grub/locale/': 16384, 'boot//': 138924032, 'boot/grub/': 4460544}
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

No branches or pull requests

1 participant