Posted on 02-26-2015 06:35 AM
We are looking at starting to use Autopkg in our environment, but we currently use Flash ESR for deployment and would like to see if we could make that work in Autopkg. I see on the autopkg github site that Anthony Reimer has posted a new recipe, where the direct URL for the flash ESR link can be copy and pasted, but would like if there was a more automated way to check if one is on the current version or not.
I, unfortunately, before this Monday have had no experience with Python, to see if this would be possible. I have over the last few days given it my best shot to rewrite the existing AdobeFlashURLProvider.py file, learning Python as I go, but I think I've hit a wall as to the current level of Python knowledge I have at this point. I was wondering if there's anyone else out there who would like to use the Adobe Flash ESR for Autopkg and perhaps has some experience with Python to see where I've gone wrong in the code. I will copy the current version of the AdobeFlashURLProvider.py I have created to the bottom of this discussion.
Also I'm aware there are probably a number of unneeded references in the current code, and that is mainly due to the fact that since I wasn't quite sure exactly what all the current code was doing, I pretty much just replaced the sections that parsed the Adobe XML with my new code that parses the HTML from the Adobe distribution page.
I'm also going to paste in a second bit of code that is just the HTML parsing code on its own that I wrote, which I am trying to inject and replace the XML code in the original autopkg AdobeFlashURLProvider.py file.
Thanks,
Lee Weisbecker
HTML Parsing Code
#!/usr/bin/python2.7
import urllib2
from HTMLParser import HTMLParser
import re
UPDATE_HTML_URL = "http://adobe.com/products/flashplayer/fp_distribution3.html"
DOWNLOAD_TEMPLATE_URL = "http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_%s_osx.dmg"
FlashHTMLURL = urllib2.Request(UPDATE_HTML_URL)
FlashURL = urllib2.urlopen(FlashHTMLURL)
FlashHTML = FlashURL.read()
class AdobeFlashHTML(HTMLParser):
container = ""
def handle_data(self, data): if data.find("Extended Support Release -") != -1: self.container += data return self.container
Flash = AdobeFlashHTML()
Flash.feed(FlashHTML)
print Flash.container
FlashVersionList = re.findall(r'd+.d+.d+.d+', Flash.container)
FlashVersionStr = FlashVersionList[0]
print (FlashVersionStr)
FlashVersion = FlashVersionStr[0:2]
print FlashVersion
print DOWNLOAD_TEMPLATE_URL % FlashVersion
Edited AdobeFlashURLProvider.py File
#!/usr/bin/python2.7
#
#
#
#
#
#
#
#
"""See docstring for AdobeFlashURLProvider class"""
import urllib2
from HTMLParser import HTMLParser
import re
from autopkglib import Processor, ProcessorError
all = ["AdobeFlashURLProvider"]
UPDATE_HTML_URL = "http://adobe.com/products/flashplayer/fp_distribution3.html"
DOWNLOAD_TEMPLATE_URL = "http://fpdownload.macromedia.com/get/flashplayer/current/licensing/mac/install_flash_player_%s_osx.dmg"
class AdobeFlashHTML(HTMLParser):
container = ""
def handle_data(self, data): if data.find("Extended Support Release -") != -1: self.container += data return self.container
class AdobeFlashURLProvider(Processor): """Provides URL to the latest Adobe Flash Player release.""" description = doc input_variables = { "url": { "required": False, "description": ("Override URL. If provided, this processor " "just returns without doing anything."), }, "version": { "required": False, "description": ("Specific version to download. If not defined, " "defaults to latest version.") }, } output_variables = { "url": { "description": "URL to the latest Adobe Flash Player release.", }, }
def get_adobe_flash_dmg_url(self): '''Return the URL for the Adobe Flash DMG''' version = self.env.get("version") if not version: # Read update HTML try: FlashHTMLURL = urllib2.Request(UPDATE_HTML_URL) FlashURL = urllib2.urlopen(FlashHTMLURL) FlashHTML = FlashURL.read() except: raise ProcessorError( "Can't download %s" % (UPDATE_HTML_URL))
# Parse HTML data try: Flash = AdobeFlashHTML() FlashVersionList = re.findall(r'd+.d+.d+.d+', Flash.container) FlashVersionStr = FlashVersionList[0] except: raise Exception ("Can't read %s" % (FlashHTML))
# Extract version number from the HTML version = None if Len(FlashVersionStr) == 10: version = FlashVersionStr
if not version: raise ProcessorError("Update HTML in unexpected format.") else: self.output("Using provided version %s" % version)
# Use version number to build a download URL version = FlashVersionStr[0:2] return DOWNLOAD_TEMPLATE_URL % version
def main(self): '''Return a download URL for latest Mac Flash Player''' if "url" in self.env: self.output("Using input URL %s" % self.env["url"]) return self.env["url"] = self.get_adobeflash_dmg_url() self.output("Found URL %s" % self.env["url"])
if name == 'main': PROCESSOR = AdobeFlashURLProvider() PROCESSOR.execute_shell()
Posted on 02-26-2015 07:26 AM
Have you looked at AutoPkgr? GUI interface for AutoPkg and can send notifications on updates.
http://www.lindegroup.com/autopkgr
Posted on 02-26-2015 07:49 AM
pblake -
Thanks for the response, I had not looked into autopkgr, and it does look quite helpful, but unfortunately does not solve the problem of still having to manually update a link when versions change for the ESR version of Flash. I'm hoping someone out there might have some insight on how to properly replace the xml parsing currently found in the AdobeFlashURLProvider.py file with HTML parsing to correctly find the current version of ESR flash and then download and package it.
Thanks,
Lee