Mercurial > public > sg101
comparison core/management/commands/ssl_images.py @ 895:e7c549e4dbf7
Add counter and timer.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 19 Feb 2015 21:02:21 -0600 |
parents | 101728976f9c |
children | 0054a4a88c1c |
comparison
equal
deleted
inserted
replaced
894:101728976f9c | 895:e7c549e4dbf7 |
---|---|
5 /something. | 5 /something. |
6 - Non SG101 images that use http: are downloaded, resized, and uploaded to | 6 - Non SG101 images that use http: are downloaded, resized, and uploaded to |
7 an S3 bucket. The src attribute is replaced with the new S3 URL. | 7 an S3 bucket. The src attribute is replaced with the new S3 URL. |
8 """ | 8 """ |
9 import base64 | 9 import base64 |
10 import datetime | |
10 import httplib | 11 import httplib |
11 import logging | 12 import logging |
12 from optparse import make_option | 13 from optparse import make_option |
13 import os | 14 import os |
14 import re | 15 import re |
310 type='int', | 311 type='int', |
311 help="optional second slice index; the j in [i:j]"), | 312 help="optional second slice index; the j in [i:j]"), |
312 ) | 313 ) |
313 | 314 |
314 def handle_noargs(self, **options): | 315 def handle_noargs(self, **options): |
316 time_started = datetime.datetime.now() | |
315 _setup_logging() | 317 _setup_logging() |
316 logger.info("Starting; arguments received: %s", options) | 318 logger.info("Starting; arguments received: %s", options) |
317 | 319 |
318 if options['model'] not in MODEL_CHOICES: | 320 if options['model'] not in MODEL_CHOICES: |
319 raise CommandError('Please choose a --model option') | 321 raise CommandError('Please choose a --model option') |
361 bucket_name=PHOTO_BUCKET_NAME) | 363 bucket_name=PHOTO_BUCKET_NAME) |
362 | 364 |
363 if i is None: | 365 if i is None: |
364 i = 0 | 366 i = 0 |
365 | 367 |
368 count = 0 | |
366 for n, model in enumerate(qs.iterator()): | 369 for n, model in enumerate(qs.iterator()): |
367 if quit_flag: | 370 if quit_flag: |
368 logger.warning("SIGINT received, exiting") | 371 logger.warning("SIGINT received, exiting") |
369 break | 372 break |
370 logger.info("Processing %s #%d (pk = %d)", model_name, n + i, model.pk) | 373 logger.info("Processing %s #%d (pk = %d)", model_name, n + i, model.pk) |
382 # Check for content generated with older smiley code that used | 385 # Check for content generated with older smiley code that used |
383 # absolute URLs for the smiley images. If True, then just save | 386 # absolute URLs for the smiley images. If True, then just save |
384 # the model again to force updated HTML to be created. | 387 # the model again to force updated HTML to be created. |
385 logger.info("Older Smiley HTML detected, forcing a save") | 388 logger.info("Older Smiley HTML detected, forcing a save") |
386 model.save() | 389 model.save() |
387 | 390 count += 1 |
388 logger.info("ssl_images exiting") | 391 |
392 time_finished = datetime.datetime.now() | |
393 elapsed = time_finished - time_started | |
394 logger.info("ssl_images exiting; number of objects: %d; elapsed: %s", | |
395 count, elapsed) |