<s> """<STR_LIT>""" <EOL> from google . appengine . api import users <EOL> from simian import settings <EOL> from simian . mac import admin <EOL> from simian . mac . common import mail <EOL> from simian . mac . munki import common <EOL> class AdminPanic ( admin . AdminHandler ) : <EOL> """<STR_LIT>""" <EOL> def get ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . IsAdminUser ( ) : <EOL> return <EOL> modes = [ ] <EOL> for mode in common . PANIC_MODES : <EOL> d = { <EOL> '<STR_LIT:name>' : mode , <EOL> '<STR_LIT>' : common . IsPanicMode ( mode ) , <EOL> } <EOL> modes . append ( d ) <EOL> self . Render ( <EOL> '<STR_LIT>' , { '<STR_LIT>' : modes , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def post ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . IsAdminUser ( ) : <EOL> return <EOL> mode = self . request . get ( '<STR_LIT>' ) <EOL> enabled = self . request . get ( '<STR_LIT>' ) <EOL> verify = self . request . get ( '<STR_LIT>' ) <EOL> if not verify : <EOL> self . Render ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : { '<STR_LIT:name>' : mode , '<STR_LIT>' : enabled } , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> else : <EOL> if enabled == '<STR_LIT>' : <EOL> enabled = False <EOL> elif enabled == '<STR_LIT>' : <EOL> enabled = True <EOL> else : <EOL> enabled = None <EOL> if enabled is None : <EOL> self . error ( <NUM_LIT> ) <EOL> else : <EOL> try : <EOL> common . SetPanicMode ( mode , enabled ) <EOL> if mail : <EOL> user = users . get_current_user ( ) <EOL> subject = '<STR_LIT>' % user <EOL> body = '<STR_LIT>' % ( user , enabled ) <EOL> mail . SendMail ( settings . EMAIL_ADMIN_LIST , subject , body ) <EOL> self . redirect ( '<STR_LIT>' ) <EOL> except ValueError : <EOL> self . error ( <NUM_LIT> ) </s>
