#NEWLINE# def get( self ) : #NEWLINE# #INDENT# key = self . request . get ( 'key' ) #NEWLINE# if ( not API_INFO_KEY ) : #NEWLINE# #INDENT# logging . warning ( 'API_INFO_KEY is unset; blocking all API info requests.' ) #NEWLINE# self . response . set_status ( 401 ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key != API_INFO_KEY ) : #NEWLINE# #INDENT# self . response . set_status ( 401 ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# output = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for package in models . PackageInfo . all ( ) : #NEWLINE# #INDENT# output [ package . filename ] = { #NEWLINE# #INDENT# 'name' : package . name , #NEWLINE# 'catalogs' : package . catalogs , #NEWLINE# 'created' : package . created . isoformat ( ) , #NEWLINE# 'install_types' : package . install_types , #NEWLINE# 'manifests' : package . manifests , #NEWLINE# 'munki_name' : package . munki_name , #NEWLINE# 'mtime' : package . mtime . isoformat ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# for ( key , default ) in PKGINFO_PLIST_KEYS_AND_DEFAULTS : #NEWLINE# #INDENT# output [ package . filename ] [ key ] = package . plist . get ( key , default ) #NEWLINE# #UNINDENT# #UNINDENT# self . response . headers [ 'Content-Type' ] = 'application/json' #NEWLINE# self . response . out . write ( json . dumps ( output ) )