@task
@write
def calc_checksum(theme_id, **kw):
 lfs = LocalFileStorage()
 theme = Persona.objects.get(id=theme_id)
 header = theme.header_path
 footer = theme.footer_path
 try:
  Image.open(header)
  Image.open(footer)
 except IOError:
  log.info(('Deleting invalid theme [%s] (header: %s) (footer: %s)' % (theme.addon.id, header, footer)))
  theme.addon.delete()
  theme.delete()
  rm_stored_dir(header.replace('header.png', ''), storage=lfs)
  return
 try:
  theme.checksum = make_checksum(header, footer)
  theme.save()
 except IOError as e:
  log.error(str(e))

@ task @ write def calc_checksum ( theme_id , ** kw ) : lfs = LocalFileStorage ( ) theme = Persona . objects . get ( id = theme_id ) header = theme . header_path footer = theme . footer_path try : Image . open ( header ) Image . open ( footer ) except IOError : log . info ( ( 'Deleting invalid theme [%s] (header: %s) (footer: %s)' % ( theme . addon . id , header , footer ) ) ) theme . addon . delete ( ) theme . delete ( ) rm_stored_dir ( header . replace ( 'header.png' , '' ) , storage = lfs ) return try : theme . checksum = make_checksum ( header , footer ) theme . save ( ) except IOError as e : log . error ( str ( e ) )
for migration 596 .