#NEWLINE# def GetPlistValue( key , secure = False , plist = None ) : #NEWLINE# #INDENT# "Returns the value of a given plist key.\n\n  Args:\n    key: string key to get from the plist.\n    secure: boolean; True = munki secure plist, False = munki regular plist.\n    plist: optional, str plist path to use, instead of Munki plist.\n      Note, if plist is supplied, secure boolean is ignored.\n  Returns:\n    string value, or empty string if the key doesn't exist.\n  " #NEWLINE# if ( not plist ) : #NEWLINE# #INDENT# if secure : #NEWLINE# #INDENT# plist = DEFAULT_SECURE_MANAGED_INSTALLS_PLIST_PATH #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# plist = DEFAULT_MANAGED_INSTALLS_PLIST_PATH #NEWLINE# #UNINDENT# #UNINDENT# if OBJC_OK : #NEWLINE# #INDENT# pl = fpl . readPlist ( plist ) #NEWLINE# return pl . get ( key , '' ) #NEWLINE# #UNINDENT# ( exit_code , plist_xml , unused_err ) = Exec ( [ '/usr/bin/plutil' , '-convert' , 'xml1' , '-o' , '-' , plist ] ) #NEWLINE# if exit_code : #NEWLINE# #INDENT# logging . error ( 'Failed to convert plist to xml1: %s' , plist ) #NEWLINE# return '' #NEWLINE# #UNINDENT# plist_contents = plistlib . readPlistFromString ( plist_xml ) #NEWLINE# return plist_contents . get ( key , '' )