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
Better handling of the ValueError during the collectstatic #484
Comments
the problem is that since you catch that error, the original code exits at the error raising, where it should continue collection. my solution was the same, except copying and overloading the whole I'll post it here on interest, but I guess you can figure this out for yourself. There is a related issue (closed): #302 |
i think with a option in CSS, it can be resolved it, but i dont know what thing @cyberdelia about this issue |
Unfortunately it's not on what the pipeline people could do here, is to check and remove the nonexistent files from the collection list, so that django's storage.py logic wouldn't raise an exception. |
pasting my custom storage, mentioned in #484 (comment): import warnings
class WsStorage(
PipelineMixin, OptimizedFilesMixin, ManifestStaticFilesStorage):
def hashed_name(self, name, content=None):
"""
This is a slight modification of the hashed name function in
django/contrib/staticfiles/storage.py's HashedFilesMixin class.
It does not raise an error when pipeline instructs it to find a
file that is not there. Update this function from time to time,
as the original changes.
"""
parsed_name = urlsplit(unquote(name))
clean_name = parsed_name.path.strip()
opened = False
if content is None:
if not self.exists(clean_name) and settings.DEBUG:
warnings.warn(
'The file \' % s\' could not be found with %r.' %
(clean_name, self), RuntimeWarning)
# raise ValueError()
try:
content = self.open(clean_name)
except IOError:
# Handle directory paths and fragments
return name
opened = True
try:
file_hash = self.file_hash(clean_name, content)
finally:
if opened:
content.close()
path, filename = os.path.split(clean_name)
root, ext = os.path.splitext(filename)
if file_hash is not None:
file_hash = '.%s' % file_hash
hashed_name = os.path.join(path, '%s%s%s' %
(root, file_hash, ext))
unparsed_name = list(parsed_name)
unparsed_name[2] = hashed_name
# Special casing for a @font-face hack, like url(myfont.eot?#iefix")
# http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
if '?#' in name and not unparsed_name[3]:
unparsed_name[2] += '?'
return urlunsplit(unparsed_name) @cyberdelia, while I realize this is not the problem of |
@karolyi Thank you for this, I'm running into the same exact issues. I don't mind getting warned that a css file is missing, but it's super annoying to have the whole site go 500 error on me :( |
Is there any update about this ? Because I've this issue and he's saying that the output_filename is not there. Or normally pipeline should generates it. here are the log : What should I do ?? I'm on django 1.9.8 and can't figure out what to do. I checked every files listed in my settings and they are all there. The lonely thing is that there is no folder compiled. should I create it ? |
Hello everyone, I got inspiration from a code over internet and I subclassed the Pipeline Storage to avoid the raise of the ValueError in case of problem processing the css.
In the log I see which files are missing, some are from vendor packages and some not. I would like to print in the log also the file that generated the error and which line, but I can't get it in the hashed_name function. Do you have any idea how to get it?
The text was updated successfully, but these errors were encountered: