#NEWLINE# def getPayloadInfo( dirpath ) : #NEWLINE# #INDENT# 'Parses Adobe payloads, pulling out info useful to munki.\n    .proxy.xml files are used if available, or for CC-era updates\n    which do not contain one, the Media_db.db file, which contains\n    identical XML, is instead used.\n\n    CS3/CS4:        contain only .proxy.xml\n    CS5/CS5.5/CS6:  contain both\n    CC:             contain only Media_db.db' #NEWLINE# payloadinfo = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if os . path . isdir ( dirpath ) : #NEWLINE# #INDENT# proxy_paths = glob ( os . path . join ( dirpath , '*.proxy.xml' ) ) #NEWLINE# if proxy_paths : #NEWLINE# #INDENT# xmlpath = proxy_paths [ 0 ] #NEWLINE# dom = minidom . parse ( xmlpath ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# db_path = os . path . join ( dirpath , 'Media_db.db' ) #NEWLINE# if os . path . exists ( db_path ) : #NEWLINE# #INDENT# conn = sqlite3 . connect ( db_path ) #NEWLINE# cur = conn . cursor ( ) #NEWLINE# cur . execute ( "SELECT value FROM PayloadData WHERE PayloadData.key = 'PayloadInfo'" ) #NEWLINE# result = cur . fetchone ( ) #NEWLINE# cur . close ( ) #NEWLINE# if result : #NEWLINE# #INDENT# info_xml = result [ 0 ] . encode ( 'UTF-8' ) #NEWLINE# dom = minidom . parseString ( info_xml ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return payloadinfo #NEWLINE# #UNINDENT# #UNINDENT# payload_info = dom . getElementsByTagName ( 'PayloadInfo' ) #NEWLINE# if payload_info : #NEWLINE# #INDENT# installer_properties = payload_info [ 0 ] . getElementsByTagName ( 'InstallerProperties' ) #NEWLINE# if installer_properties : #NEWLINE# #INDENT# properties = installer_properties [ 0 ] . getElementsByTagName ( 'Property' ) #NEWLINE# for prop in properties : #NEWLINE# #INDENT# if ( 'name' in prop . attributes . keys ( ) ) : #NEWLINE# #INDENT# propname = prop . attributes [ 'name' ] . value . encode ( 'UTF-8' ) #NEWLINE# propvalue = '' #NEWLINE# for node in prop . childNodes : #NEWLINE# #INDENT# propvalue += node . nodeValue #NEWLINE# #UNINDENT# if ( propname == 'AdobeCode' ) : #NEWLINE# #INDENT# payloadinfo [ 'AdobeCode' ] = propvalue #NEWLINE# #UNINDENT# if ( propname == 'ProductName' ) : #NEWLINE# #INDENT# payloadinfo [ 'display_name' ] = propvalue #NEWLINE# #UNINDENT# if ( propname == 'ProductVersion' ) : #NEWLINE# #INDENT# payloadinfo [ 'version' ] = propvalue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# installmetadata = payload_info [ 0 ] . getElementsByTagName ( 'InstallDestinationMetadata' ) #NEWLINE# if installmetadata : #NEWLINE# #INDENT# totalsizes = installmetadata [ 0 ] . getElementsByTagName ( 'TotalSize' ) #NEWLINE# if totalsizes : #NEWLINE# #INDENT# installsize = '' #NEWLINE# for node in totalsizes [ 0 ] . childNodes : #NEWLINE# #INDENT# installsize += node . nodeValue #NEWLINE# #UNINDENT# payloadinfo [ 'installed_size' ] = ( int ( installsize ) / 1024 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return payloadinfo