Permalink
Browse files

Only print out all unfound images if --verbosity=2

  • Loading branch information...
1 parent 5a25446 commit bb460dcb9109fa29ae85cb4cefe6a187212fdadb @gkoberger gkoberger committed Sep 22, 2011
Showing with 16 additions and 2 deletions.
  1. +4 −0 README.rst
  2. +12 −2 jingo_minify/management/commands/compress_assets.py
View
@@ -168,6 +168,10 @@ It will go through your CSS, and find any reference to local resources. It
will append the short id for the commit that most recently modified the
resource, so that it only cache busts resources that are actually modified.
+The list of images that couldn't be found can be displayed by running the
+command with `--verbosity=2` (or `-v2`).
+
+ manage.py compress_assets -v2
.. note::
This is off by default. It does a lot of I/O, so be careful if you have
@@ -26,6 +26,8 @@ class Command(BaseCommand): # pragma: no cover
checked_hash = {}
bundle_hashes = {}
+ missing_files = 0
+
def update_hashes(self, update=False):
def gitid(path):
id = (git.repo.Repo(os.path.join(settings.ROOT, path))
@@ -56,7 +58,7 @@ def handle(self, **options):
'yuicompressor-2.4.4.jar')
path_to_jar = os.path.realpath(os.path.join(*jar_path))
- self.v = '-v' if options.get('verbosity', False) == 2 else ''
+ self.v = '-v' if options.get('verbosity', False) == '2' else ''
cachebust_imgs = getattr(settings, 'CACHEBUST_IMGS', False)
if not cachebust_imgs:
@@ -135,6 +137,12 @@ def _cachebust(self, css_file, bundle_name):
# Return bundle hash for cachebusting JS/CSS files.
file_hash = hashlib.md5(css_parsed).hexdigest()[0:7]
self.checked_hash[css_file] = file_hash
+
+ if not self.v and self.missing_files:
+ print " - Error finding %s images (-v2 for info)" % (
+ self.missing_files,)
+ self.missing_files = 0
+
return file_hash
def _minify(self, ftype, file_in, file_out):
@@ -165,7 +173,9 @@ def _file_hash(self, url):
with open(url) as f:
file_hash = hashlib.md5(f.read()).hexdigest()[0:7]
except IOError:
- print " - Couldn't find file %s" % url
+ self.missing_files += 1
+ if self.v:
+ print " - Could not find file %s" % url
self.checked_hash[url] = file_hash
return file_hash

0 comments on commit bb460dc

Please sign in to comment.