def updateAvailableLicenseSeats(installinfo):
    '''Records # of available seats for each optional install'''
    license_info_url = munkicommon.pref('LicenseInfoURL')
    if not license_info_url:
        # nothing to do!
        return
    if not installinfo.get('optional_installs'):
        # nothing to do!
        return

    license_info = {}
    items_to_check = [item['name']
                      for item in installinfo['optional_installs']
                      if item.get('licensed_seat_info_available')
                      and not item['installed']]

    # complicated logic here to 'batch' process our GET requests but
    # keep them under 256 characters each
    start_index = 0
    # Use ampersand when the license_info_url contains a ?
    q_char = "?"
    if "?" in license_info_url:
        q_char = "&"
    while start_index < len(items_to_check):
        end_index = len(items_to_check)
        while True:
            query_items = ['name=' + quote_plus(item)
                           for item in items_to_check[start_index:end_index]]
            querystring = q_char + '&'.join(query_items)
            url = license_info_url + querystring
            if len(url) < 256:
                break
            # drop an item and see if we're under 256 characters
            end_index = end_index - 1

        munkicommon.display_debug1('Fetching licensed seat data from %s', url)
        try:
            license_data = getDataFromURL(url)
            munkicommon.display_debug1('Got: %s', license_data)
            license_dict = FoundationPlist.readPlistFromString(
                license_data)
        except (fetch.MunkiDownloadError, fetch.GurlDownloadError), err:
            # problem fetching from URL
            munkicommon.display_error('Error from %s: %s', url, err)
        except FoundationPlist.FoundationPlistException:
            # no data or bad data from URL
            munkicommon.display_error(
                'Bad license data from %s: %s', url, license_data)
        else:
            # merge data from license_dict into license_info
            license_info.update(license_dict)
        start_index = end_index

    # use license_info to update our remaining seats
    for item in installinfo['optional_installs']:
        if item['name'] in items_to_check:
            munkicommon.display_debug2(
                'Looking for license info for %s', item['name'])
            # record available seats for this item
            seats_available = False
            seat_info = license_info.get(item['name'], 0)
            try:
                seats_available = int(seat_info) > 0
                munkicommon.display_debug1(
                    'Recording available seats for %s: %s',
                    item['name'], seats_available)
            except __HOLE__:
                munkicommon.display_warning(
                    'Bad license data for %s: %s', item['name'], seat_info)

            item['licensed_seats_available'] = seats_available
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/updateAvailableLicenseSeats