jazzband / django-pipeline

Pipeline is an asset packaging library for Django.
https://django-pipeline.readthedocs.io/
MIT License
1.5k stars 372 forks source link

PipeLine got TypeError: expected string or buffer #320

Closed raianul closed 10 years ago

raianul commented 10 years ago

@cyberdelia - We have made conversation regarding gzip compression. https://github.com/cyberdelia/django-pipeline/issues/312

We have update our django to 1.6.1. With gzip I am now using PipelineCachedStorage too. But Now we are facing some critical error.

This is my configuration now -

class GZipPipelineStorage(GZIPMixin, PipelineCachedStorage):

    def post_process(self, paths, dry_run=False, **options):
        for name, hashed_name, processed in super(GZipPipelineStorage, self).post_process(paths, dry_run, **options):
            if isinstance(processed, ValueError) and name not in settings.ALL_SOURCE_FILENAMES:
                continue

            yield name, hashed_name, processed

The reason to overridden post_process function is - ignore errors raised on post-processing phase when files are missing. Though there is a conversation regarding this, but I think they didn't solved it - https://github.com/jezdez/django-staticfiles/pull/17

But at some point while post_process is running, I am getting following error -

Post-processed 'websites/bespoke/fonts/specimen_files/grid_12-825-55-15.45e9422c89bf.css.gz' as 'websites/bespoke/fonts/specimen_files/grid_12-825-55-15.45e9422c89bf.css.gz'
Post-processed 'websites/bespoke/fonts/specimen_files/specimen_stylesheet.e2cb9ea14b54.css.gz' as 'websites/bespoke/fonts/specimen_files/specimen_stylesheet.e2cb9ea14b54.css.gz'
Post-processed 'websites/dfm/js/olympics/jquery.countdown.a085c11d8052.js.gz' as 'websites/dfm/js/olympics/jquery.countdown.a085c11d8052.js.gz'
Post-processed 'websites/entertainow/css/fonts/stylesheet.7b7585a64514.css.gz' as 'websites/entertainow/css/fonts/stylesheet.7b7585a64514.css.gz'
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 167, in handle_noargs
    collected = self.collect()
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 118, in collect
    for original_path, processed_path, processed in processor:
  File "/Users/newscred/projects/python/cms/cms/pipeline/pipeline_storage.py", line 7, in post_process
    for name, hashed_name, processed in super(GZipPipelineStorage, self).post_process(paths, dry_run, **options):
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/pipeline/storage.py", line 77, in post_process
    if not matches_patterns(path, self.gzip_patterns):
  File "/Users/newscred/projects/python/pycms/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 14, in matches_patterns
    if fnmatch.fnmatchcase(path, pattern):
  File "/Users/newscred/projects/python/pycms/lib/python2.7/fnmatch.py", line 79, in fnmatchcase
    return _cache[pat].match(name) is not None
TypeError: expected string or buffer

I believe this is the code https://github.com/cyberdelia/django-pipeline/blob/master/pipeline/storage.py#L77 which might be the cause for the error.

_cache[pat].match(name) here I am getting name as None.

raianul commented 10 years ago

@cyberdelia here is the pull request https://github.com/cyberdelia/django-pipeline/pull/321

cyberdelia commented 10 years ago

Thanks again for troubleshooting this!