def generate_pngs_from_installer_pkg(install_item, repo_path): icon_paths = [] mountpoint = None pkg_path = None item_path = os.path.join( repo_path, u'pkgs', install_item['installer_item_location']) if munkicommon.hasValidDiskImageExt(item_path): dmg_path = item_path mountpoints = munkicommon.mountdmg(dmg_path) if mountpoints: mountpoint = mountpoints[0] if install_item.get('package_path'): pkg_path = os.path.join( mountpoint, install_item['package_path']) else: # find first item that appears to be a pkg at the root for fileitem in munkicommon.listdir(mountpoints[0]): if munkicommon.hasValidPackageExt(fileitem): pkg_path = os.path.join(mountpoint, fileitem) break elif munkicommon.hasValidPackageExt(item_path): pkg_path = item_path if pkg_path: if os.path.isdir(pkg_path): icon_paths = iconutils.extractAppIconsFromBundlePkg(pkg_path) else: icon_paths = iconutils.extractAppIconsFromFlatPkg(pkg_path) if mountpoint: munkicommon.unmountdmg(mountpoint) if len(icon_paths) == 1: png_path = os.path.join( repo_path, u'icons', install_item['name'] + u'.png') result = iconutils.convertIconToPNG(icon_paths[0], png_path) if result: print_utf8(u'\tWrote: %s' % png_path) elif len(icon_paths) > 1: index = 1 for icon_path in icon_paths: png_path = os.path.join( repo_path, u'icons', install_item['name'] + '_' + str(index) + u'.png') result = iconutils.convertIconToPNG(icon_path, png_path) if result: print_utf8(u'\tWrote: %s' % png_path) index += 1 else: print_utf8(u'\tNo application icons found.')
def generate_pngs_from_installer_pkg(install_item, repo_path): icon_paths = [] mountpoint = None pkg_path = None item_path = os.path.join(repo_path, u'pkgs', install_item['installer_item_location']) if munkicommon.hasValidDiskImageExt(item_path): dmg_path = item_path mountpoints = munkicommon.mountdmg(dmg_path) if mountpoints: mountpoint = mountpoints[0] if install_item.get('package_path'): pkg_path = os.path.join(mountpoint, install_item['package_path']) else: # find first item that appears to be a pkg at the root for fileitem in munkicommon.listdir(mountpoints[0]): if munkicommon.hasValidPackageExt(fileitem): pkg_path = os.path.join(mountpoint, fileitem) break elif munkicommon.hasValidPackageExt(item_path): pkg_path = item_path if pkg_path: if os.path.isdir(pkg_path): icon_paths = iconutils.extractAppIconsFromBundlePkg(pkg_path) else: icon_paths = iconutils.extractAppIconsFromFlatPkg(pkg_path) if mountpoint: munkicommon.unmountdmg(mountpoint) if len(icon_paths) == 1: png_path = os.path.join(repo_path, u'icons', install_item['name'] + u'.png') result = iconutils.convertIconToPNG(icon_paths[0], png_path) if result: print_utf8(u'\tWrote: %s' % png_path) elif len(icon_paths) > 1: index = 1 for icon_path in icon_paths: png_path = os.path.join( repo_path, u'icons', install_item['name'] + '_' + str(index) + u'.png') result = iconutils.convertIconToPNG(icon_path, png_path) if result: print_utf8(u'\tWrote: %s' % png_path) index += 1 else: print_utf8(u'\tNo application icons found.')
def generate_png_from_copy_from_dmg_item(install_item, repo_path): dmgpath = os.path.join(repo_path, 'pkgs', install_item['installer_item_location']) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: mountpoint = mountpoints[0] apps = [ item for item in install_item.get('items_to_copy', []) if item.get('source_item', '').endswith('.app') ] if len(apps): app_path = os.path.join(mountpoint, apps[0]['source_item']) icon_path = iconutils.findIconForApp(app_path) if icon_path: png_path = os.path.join(repo_path, u'icons', install_item['name'] + u'.png') result = iconutils.convertIconToPNG(icon_path, png_path) if result: print_utf8(u'\tWrote: %s' % png_path) else: print_err_utf8(u'\tError converting %s to png.' % icon_path) else: print_utf8(u'\tNo application icons found.') else: print_utf8(u'\tNo application icons found.') munkicommon.unmountdmg(mountpoint)
def generate_png_from_copy_from_dmg_item(install_item, repo_path): dmgpath = os.path.join( repo_path, 'pkgs', install_item['installer_item_location']) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: mountpoint = mountpoints[0] apps = [item for item in install_item.get('items_to_copy', []) if item.get('source_item', '').endswith('.app')] if len(apps): app_path = os.path.join(mountpoint, apps[0]['source_item']) icon_path = iconutils.findIconForApp(app_path) if icon_path: png_path = os.path.join( repo_path, u'icons', install_item['name'] + u'.png') result = iconutils.convertIconToPNG(icon_path, png_path) if result: print_utf8(u'\tWrote: %s' % png_path) else: print_err_utf8(u'\tError converting %s to png.' % icon_path) else: print_utf8(u'\tNo application icons found.') else: print_utf8(u'\tNo application icons found.') munkicommon.unmountdmg(mountpoint)