2012-07-05 25 views
3

文件當我運行蟒蛇manage.py collectstatic,我得到:廣東話壓縮與Django的管道和YUI

Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/fceruti/Development/Arriendas.cl/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line 
    utility.execute() 
    File "/Users/fceruti/Development/xxxxx/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/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute 
    output = self.handle(*args, **options) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle 
    return self.handle_noargs(**options) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs 
    collected = self.collect() 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 119, in collect 
    dry_run=self.dry_run) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/pipeline/storage.py", line 30, in post_process 
    packager.pack_stylesheets(package) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/pipeline/packager.py", line 90, in pack_stylesheets 
    variant=package.variant, **kwargs) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/pipeline/packager.py", line 100, in pack 
    content = compress(paths, **kwargs) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/pipeline/compressors/__init__.py", line 72, in compress_css 
    css = self.concatenate_and_rewrite(paths, output_filename, variant) 
    File "/Users/fceruti/Development/Arriendas.cl/venv/lib/python2.7/site-packages/pipeline/compressors/__init__.py", line 135, in concatenate_and_rewrite 
    content = self.read_file(path) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/pipeline/compressors/__init__.py", line 208, in read_file 
    file = default_storage.open(path, 'rb') 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/django/core/files/storage.py", line 33, in open 
    return self._open(name, mode) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/pipeline/storage.py", line 114, in _open 
    storage = self.find_storage(name) 
    File "/Users/fceruti/Development/xxxxx/venv/lib/python2.7/site-packages/pipeline/storage.py", line 111, in find_storage 
    raise ValueError("The file '%s' could not be found with %r." % (name, self)) 
ValueError: The file 'css/960_24_col.css' could not be found with <pipeline.storage.PipelineFinderStorage object at 0x101da4d50>. 

當我運行蟒蛇manage.py findstatic CSS/960_24_col.css,我得到

Found 'css/960_24_col.css' here: 
    /Users/fceruti/Development/xxxxxxx/Arriendas/static/css/960_24_col.css 

我的設置是:

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') 

STATICFILES_DIRS = (
    ('css', os.path.join(STATIC_ROOT, 'css')), 
    ('img', os.path.join(STATIC_ROOT, 'img')), 
    ('js', os.path.join(STATIC_ROOT, 'js')), 
    ('fonts', os.path.join(STATIC_ROOT, 'fonts')), 
) 

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder', 
    'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
    'django.contrib.staticfiles.finders.DefaultStorageFinder', 
) 
PIPELINE = True 
PIPELINE_CSS = { 
    'app': { 
     'source_filenames': (
      'css/960_24_col.css', 
      'css/base.scss', 
     ), 
     'output_filename': 'css/app.css', 
     'extra_context': { 
      'media': 'screen,projection', 
     }, 
    }, 
} 
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor' 
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor' 
PIPELINE_YUI_CSS_ARGUMENTS = '' 
PIPELINE_YUI_JS_ARGUMENTS = '' 
PIPELINE_YUI_BINARY = os.path.join(PROJECT_ROOT, 'libs/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar') 

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' 
PIPELINE_SASS_BINARY = '/usr/bin/sass' 

當我添加

PIPELINE_COMPILERS = (
    'pipeline.compilers.sass.SASSCompiler', 
) 

並運行網頁,我得到:

Exception Type: CompilerError 
Exception Value:  
Unable to apply SASSCompiler compiler 

我在做什麼錯?

編輯:

我使用的軟件是:

  • 薩斯3.1.19(聰明貝蒂)
  • YUI壓縮機2.4.7
  • django的流水線== 1.2。 11
  • Django 1.4
+0

它似乎沒有將它們與您的STATIC_ROOT相結合。您是否嘗試過使用'PipelineStorage'而不是'PipelineCachedStorage'?也可以嘗試「PipelineFinderStorage」,因爲它說明了它的開發服務器。 – jdi

+0

我試過了,但是失敗了,因爲collectstatic並沒有生成輸出文件,而且我得到了404錯誤 – fceruti

+0

您可以添加您的靜態文件設置,您正在使用的管道版本以及CompilerError的完整回溯。謝謝。 – cyberdelia

回答

1

首先,你不應該把該jar爲PIPELINE_YUI_BINARY,但你應該指向一個使用java調用jar的腳本(大多數情況下,它打包時會捆綁它)。它看起來像這樣:

#!/bin/sh 
java -jar "/path/to/yuicompressor-2.4.7.jar" [email protected] 
+0

你能給我一個關於腳本的地方的提示,或者我應該如何構建它? – fceruti

+0

@fceruti我已將它添加到我的答案。 – cyberdelia

-1

我想你想你的STATICFILES_DIRS看起來是這樣的:

STATICFILES_DIRS = ('./static/') 

如果不工作,嘗試這樣的事情。

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)[0: (os.path.dirname(__file__).rindex(os.sep + 'src' + os.sep))]) 
STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, 'static/')) 

(這個想法是設置PROJECT_ROOT到頂級目錄爲您的應用程序)

你有它設置它看起來在每個子目錄中的「CSS/960_24_col.css方式「換句話說,它會尋找

  • STATIC_ROOT/CSS/CSS /960_24_col.css
  • STATIC_ROOT/IMG/CSS/960_24_col.css
  • STATIC_ROOT/js/css/960_24_col.css
  • STATIC_ROOT/fonts/css/960_24_col。CSS

,它不會找到它,因爲該文件是在

STATIC_ROOT/css/960_24_col.css 

一般來說,STATICFILES_DIRS是包含在不同的應用程序/靜態/目錄的集合。如果yourApp包含myApp,並且myApp有一個靜態目錄,則應將您的應用的靜態目錄和myApps靜態目錄放在列表中。 Collectstatic會將它們組合成STATIC_ROOT,然後運行Pipeline。