<s> try : <EOL> from httplib import BAD_REQUEST , LOCKED , FORBIDDEN , NOT_FOUND , INTERNAL_SERVER_ERROR , OK , ACCEPTED <EOL> except : <EOL> from http . client import BAD_REQUEST , LOCKED , FORBIDDEN , NOT_FOUND , INTERNAL_SERVER_ERROR , OK , ACCEPTED <EOL> from routes import route <EOL> from api import APIBaseHandler <EOL> import time <EOL> import logging <EOL> @ route ( r"<STR_LIT>" ) <EOL> class BroadcastHandler ( APIBaseHandler ) : <EOL> def post ( self ) : <EOL> if not self . can ( '<STR_LIT>' ) : <EOL> self . send_response ( FORBIDDEN , dict ( error = "<STR_LIT>" ) ) <EOL> return <EOL> data = self . json_decode ( self . request . body ) <EOL> channel = data . get ( '<STR_LIT>' , '<STR_LIT:default>' ) <EOL> device = data . get ( '<STR_LIT>' , None ) <EOL> alert = '<STR_LIT>' . join ( data . get ( '<STR_LIT>' , '<STR_LIT>' ) . splitlines ( ) ) <EOL> sound = data . get ( '<STR_LIT>' , None ) <EOL> badge = data . get ( '<STR_LIT>' , None ) <EOL> self . add_to_log ( '<STR_LIT>' % self . appname , alert , "<STR_LIT>" ) <EOL> self . application . send_broadcast ( self . appname , self . db , <EOL> channel = channel , <EOL> alert = alert , <EOL> sound = sound , <EOL> badge = badge , <EOL> device = device , <EOL> gcm = data . get ( '<STR_LIT>' , { } ) , <EOL> mpns = data . get ( '<STR_LIT>' , { } ) , <EOL> wns = data . get ( '<STR_LIT>' , { } ) , <EOL> sms = data . get ( '<STR_LIT>' , { } ) , <EOL> apns = data . get ( '<STR_LIT>' , { } ) , <EOL> ) <EOL> delta_t = time . time ( ) - self . _time_start <EOL> logging . info ( "<STR_LIT>" % ( delta_t * <NUM_LIT:1000> ) ) <EOL> self . send_response ( ACCEPTED ) </s>
