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

BufferedFile should have a 'closed' propery #80

Closed
smunaut opened this issue Sep 10, 2012 · 2 comments
Closed

BufferedFile should have a 'closed' propery #80

smunaut opened this issue Sep 10, 2012 · 2 comments

Comments

@smunaut
Copy link

smunaut commented Sep 10, 2012

The Python file interface seems to publically define a xxx.closed property and some application use it.
Currently there is an internal _closed propery and just exposing it read-only works:

@property
def closed(self):
    return self._closed
@Bockit
Copy link

Bockit commented Oct 17, 2012

I ran into this problem today when running django's collectstatic function with the SFTP backend and some Pipeline'd files.

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs
    collected = self.collect()
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 120, in collect
    for original_path, processed_path, processed in processor:
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 239, in post_process
    saved_name = self._save(hashed_name, original_file)
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/storages/backends/sftpstorage.py", line 167, in _save
    content.open()
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/files/base.py", line 111, in open
    if not self.closed:
  File "/Users/work/Documents/business-development/smudtodo/venv/lib/python2.7/site-packages/django/core/files/base.py", line 51, in _get_closed
    return not self.file or self.file.closed
AttributeError: 'SFTPFile' object has no attribute 'closed'

I eventually tracked it down to this issue (BufferedFile needing a closed property) and had the same solution as suggested.

@bitprophet
Copy link
Member

Thanks to both of you, this fix works for now. (Reckon eventually we'll want to simply make the "private" var public.)

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

3 participants