PyFilesystem / pyfilesystem

Python filesystem abstraction layer
http://pyfilesystem.org/
BSD 3-Clause "New" or "Revised" License
285 stars 63 forks source link

HTTPFS.getinfo doesn't work well on python3 #220

Open kseistrup opened 8 years ago

kseistrup commented 8 years ago

Python 3:

$ fsinfo http://www.github.com/
fsinfo: Error - 'HTTPMessage' object has no attribute 'dict'
[/] No description available

Python 2:

$ fsinfo2 http://www.github.com/
[/] No description available
cache-control              no-cache
connection                 close
content-security-policy    default-src *; script-src assets-cdn.github.com; object-src assets-cdn.github.com; style-src 'self' 'unsafe-inline' 'unsafe-eval' assets-cdn.github.com; img-src 'self' data: assets-cdn.github.com identicons.github.com www.google-analytics.com checkout.paypal.com collector.githubapp.com *.githubusercontent.com *.gravatar.com *.wp.com; media-src 'none'; frame-src 'self' render.githubusercontent.com gist.github.com www.youtube.com player.vimeo.com checkout.paypal.com; font-src assets-cdn.github.com; connect-src 'self' live.github.com wss://live.github.com uploads.github.com status.github.com api.github.com www.google-analytics.com api.braintreegateway.com client-analytics.braintreegateway.com github-cloud.s3.amazonaws.com; base-uri 'self'; form-action 'self' github.com gist.github.com
content-type               text/html; charset=utf-8
date                       Sat, 14 Nov 2015 13:05:17 GMT
public-key-pins            max-age=300; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="JbQbUG5JMJUoI6brnx0x3vZF6jilxsapbXGVfjhN8Fg="; includeSubDomains
server                     GitHub.com
set-cookie                 logged_in=no; domain=.github.com; path=/; expires=Wed, 14 Nov 2035 13:05:17 -0000; secure; HttpOnly, _gh_sess=eyJzZXNzaW9uX2lkIjoiNWYzNTM0M2RjYmVlOGM1ODFkNTk5MzljZTNjZjk3OTUiLCJfY3NyZl90b2tlbiI6InZ5L21mU2FNVEx4SkdBUjE5NFdoLzNnM2xxVEtvZnFPK21ubU03LzFXaEU9In0%3D--bab56fdfe2767a7f92d06cd1992e086c029e433c; path=/; secure; HttpOnly
status                     200 OK
strict-transport-security  max-age=31536000; includeSubdomains; preload
transfer-encoding          chunked
vary                       X-PJAX, Accept-Encoding
x-content-type-options     nosniff
x-frame-options            deny
x-github-request-id        D99D899D:09B2:29D84735:5647318C
x-request-id               aca1873e07dc979c064a880560812bd4
x-runtime                  0.009096
x-served-by                a128136e4734a9f74c013356c773ece7
x-ua-compatible            IE=Edge,chrome=1
x-xss-protection           1; mode=block

This is community/python-fs 0.5.4 on ArchLinux.

kseistrup commented 8 years ago

With --debug:

Traceback (most recent call last):
  File "/usr/bin/fsinfo", line 9, in <module>
    load_entry_point('fs==0.5.4', 'console_scripts', 'fsinfo')()
  File "/usr/lib/python3.5/site-packages/fs/commands/fsinfo.py", line 77, in run
    return FSInfo().run()         
  File "/usr/lib/python3.5/site-packages/fs/commands/runner.py", line 352, in run
    return self.do_run(options, args) or 0
  File "/usr/lib/python3.5/site-packages/fs/commands/fsinfo.py", line 55, in do_run
    info = fs.getinfo(path)
  File "/usr/lib/python3.5/site-packages/fs/httpfs.py", line 90, in getinfo
    info = urlopen(url).info().dict
AttributeError: 'HTTPMessage' object has no attribute 'dict'
lurch commented 8 years ago

It's actually a bug in HTTPFS, rather than a bug in fsinfo:

(pyfs34)andrew@shyknee:/tmp/test$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from fs.httpfs import HTTPFS
>>> h = HTTPFS('http://www.github.com')
>>> h.getinfo('/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/test/pyfs34/lib/python3.4/site-packages/fs/httpfs.py", line 90, in getinfo
    info = urlopen(url).info().dict
AttributeError: 'HTTPMessage' object has no attribute 'dict'