<s> from twisted . internet import defer <EOL> import settings <EOL> def _healthcheck_process_image ( engine , image_path , width , height , mode , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> payload = { } <EOL> payload [ '<STR_LIT>' ] = image_path <EOL> payload [ '<STR_LIT:width>' ] = width <EOL> payload [ '<STR_LIT>' ] = height <EOL> payload [ '<STR_LIT>' ] = mode <EOL> if width == '<STR_LIT>' and height == '<STR_LIT>' : <EOL> payload [ '<STR_LIT>' ] = True <EOL> return engine . health_check_image ( payload , ** kwargs ) <EOL> def healthcheck ( request , engine ) : <EOL> """<STR_LIT>""" <EOL> def on_health_finish ( data , request ) : <EOL> """<STR_LIT>""" <EOL> for res in data : <EOL> if not res [ <NUM_LIT:0> ] : <EOL> request . setResponseCode ( <NUM_LIT> ) <EOL> request . finish ( ) <EOL> return <EOL> request . write ( '<STR_LIT:OK>' ) <EOL> request . setResponseCode ( <NUM_LIT:200> ) <EOL> request . finish ( ) <EOL> width = settings . HEALTH_CHECK_IMAGE_WIDTH <EOL> height = settings . HEALTH_CHECK_IMAGE_HEIGHT <EOL> image_path = settings . HEALTH_CHECK_IMAGE_PATH <EOL> modes = settings . ALLOWED_MODES <EOL> dfd = defer . DeferredList ( <EOL> [ _healthcheck_process_image ( engine , image_path , width , height , m , ** request . args ) <EOL> for m in modes ] <EOL> ) <EOL> dfd . addBoth ( on_health_finish , request ) </s>
