From 0ac71a034a22c4f49cefa63ea5c73734a82b40c8 Mon Sep 17 00:00:00 2001 From: Zack T Date: Fri, 13 Nov 2020 01:05:53 -0700 Subject: [PATCH] v1.3.1 = Fixed likely regression + Fixed a regression that would likely be present in older OS Versions - Remove the Python3 imports as this script isn't compatible with Python3 at this time --- .../jamf_ea_LastOSUpdateInstalled.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Jamf Pro/Extension Attributes/jamf_ea_LastOSUpdateInstalled.py b/Jamf Pro/Extension Attributes/jamf_ea_LastOSUpdateInstalled.py index 0c8ef33..ea5efb8 100644 --- a/Jamf Pro/Extension Attributes/jamf_ea_LastOSUpdateInstalled.py +++ b/Jamf Pro/Extension Attributes/jamf_ea_LastOSUpdateInstalled.py @@ -2,7 +2,7 @@ """ Script Name: jamf_ea_LastOSUpdateInstalled.py By: Zack Thompson / Created: 8/23/2019 -Version: 1.3.0 / Updated: 11/12/2020 / By: ZT +Version: 1.3.1 / Updated: 11/13/2020 / By: ZT Description: A Jamf Pro Extension Attribute to pull the last operating system update installed. """ @@ -11,13 +11,7 @@ import os import re from datetime import datetime from dateutil import tz - -try: - from plistlib import dump as custom_plist_Writer # For Python 3 - from plistlib import load as custom_plist_Reader # For Python 3 -except ImportError: - from plistlib import writePlist as custom_plist_Writer # For Python 2 - from plistlib import readPlist as custom_plist_Reader # For Python 2 +import plistlib def main(): @@ -36,25 +30,33 @@ def main(): if os.path.exists(install_history): # Load the InstallHistory.plist - plist_Contents = custom_plist_Reader(install_history) + plist_Contents = plistlib.readPlist(install_history) # Loop through the history... for update in reversed(plist_Contents): if patternProcessNames.search(update["processName"]): if patternDisplayName.search(update["displayName"]): - # for package in update["packageIdentifiers"]: - # if patternPackageIdentifiers.search(package): - # continue + + try: + for package in update["packageIdentifiers"]: + if patternPackageIdentifiers.search(package): + continue + + except: + pass lastUpdate = '' lastUpdate = lastUpdate + str(update["displayName"]).lstrip('Install ') + if update["displayVersion"] and update["displayVersion"] != " ": lastUpdate = lastUpdate + ' ' + update["displayVersion"] + if update["date"]: timeStamp = update["date"] timeStamp = timeStamp.replace(tzinfo=from_zone) timeStamp = timeStamp.astimezone(to_zone) lastUpdate = lastUpdate + ' @ ' + str(timeStamp) + break if lastUpdate: