Last active
March 18, 2016 22:58
-
-
Save opragel/50c47c7c9c9100e3b1dd to your computer and use it in GitHub Desktop.
ea_adobe_acrobat_dc_versioncheck.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
This script checks whether the installed version of Adobe Acrobat DC is | |
equal, less, or more than the target version defined by APP_TARGET_VERSION | |
and reports the result in Casper Suite extension attribute style. | |
T = Local app version is equal to provided target version | |
N = Local app version is newer than provided target version | |
F = Local app version is less than provided target version | |
N/A = Local app plist was not found or accesible at specified path | |
""" | |
import os.path | |
import plistlib | |
from pkg_resources import parse_version | |
APP_PATH = "/Applications/Adobe Acrobat DC/Adobe Acrobat.app" | |
APP_VERSION_KEY = "CFBundleShortVersionString" | |
APP_TARGET_VERSION = "15.010.20059" | |
def get_version_check_result(app_path, app_version_key, app_target_version): | |
""" | |
Reports T if the local app version is equal to target version, F if the | |
local app version is less than target version, N if the local app | |
version is greater than target version, and N/A if the plist is not found. | |
""" | |
app_plist_path = app_path + "/Contents/Info.plist" | |
if not os.path.isfile(app_plist_path): | |
version_check_result = "N/A" | |
else: | |
app_info_plist = plistlib.readPlist(app_plist_path) | |
app_version = app_info_plist[app_version_key] | |
if parse_version(app_target_version) == parse_version(app_version): | |
version_check_result = "T" | |
elif parse_version(app_target_version) < parse_version(app_version): | |
version_check_result = "N" | |
else: | |
version_check_result = "F" | |
return version_check_result | |
def main(): | |
""" Executes script functions. """ | |
result = get_version_check_result(APP_PATH, | |
APP_VERSION_KEY, | |
APP_TARGET_VERSION) | |
print '<result>%s</result>' % result | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my way around this issue:
homebysix/auto-update-magic#22