
    h                     2    d dl mZ d dlmZ  G d de      Zy)    )BaseCommand)Imagec                       e Zd Zd Zy)Commandc           	      z   t         j                  j                         j                  dd      }t	        |      }t        |      D ]  \  }}d}	 t         j                  j                  |      }| j                  j                  dj                  |dz   ||             | j                  j                          |j                   |j                   ~ y# t        $ rW}| j                  j                  dj                  t        |                   | j                  j                          Y d}~_d}~ww xY w# ~w xY w)	z
        Generates image thumbnails

        NOTE: To keep memory consumption stable avoid iteration over the Image queryset
        idT)flatN)pkzProcessing image {0} / {1} {2}   z"Failed to generate thumbnails: {0})r   objectsallvalues_listlen	enumerategetstdoutwriteformatflush
thumbnailsiconsIOErrorstderrstr)	selfargsoptionspkstotalidxr
   imagees	            ]/home/dcms/DCMS/lib/python3.12/site-packages/filer/management/commands/generate_thumbnails.pyhandlezCommand.handle   s    mm!--d->C ~ 	GCE
))R)0!!"C"J"J3QR7TY[`"ab!!#  
 	  $!!"F"M"McRSf"UV!!##$ s,   BC	D4AD/*D7/D44D77D:N)__name__
__module____qualname__r$        r#   r   r      s    r)   r   N)django.core.management.baser   filer.models.imagemodelsr   r   r(   r)   r#   <module>r,      s    3 *k r)   