def get_drivers_internal(**params): drivers = vault.get_vault()['drivers_map'] filtered_drivers = [] # when release_id is not set return only drivers from active releases if not params.get('release_id'): all_releases = vault.get_vault()['releases_map'] active_releases = ','.join(sorted( r['id'].lower() for r in all_releases.values() if r.get('active'))) params['release_id'] = active_releases for driver in drivers.values(): include = True for param, value in params.iteritems(): value = value.lower() if param == 'release_id' and value: query_releases = set(value.split(',')) found = False for release in driver['releases_info']: if release['release_id'] in query_releases: found = True break if not found: include = False break elif value and (driver.get(param) or '').lower() != value: include = False break if include: filtered_drivers.append(driver) return filtered_drivers
def summary(): selected_project_id = parameters.get_single_parameter({}, 'project_id') selected_vendor = parameters.get_single_parameter({}, 'vendor') selected_level_id = parameters.get_single_parameter({}, 'level_id') drivers = api.get_drivers_internal(project_id=selected_project_id, vendor=selected_vendor, level_id=selected_level_id) vendors = set() levels_id = set() projects_id = set() for driver in api.get_drivers_internal(project_id=selected_project_id, level_id=selected_level_id): vendors.add(driver['vendor']) for driver in api.get_drivers_internal(project_id=selected_project_id, vendor=selected_vendor): levels_id.add(driver['level_id']) for driver in api.get_drivers_internal(vendor=selected_vendor, level_id=selected_level_id): projects_id.add(driver['project_id']) projects_map = vault.get_vault()['projects_map'] projects = [{ 'project_id': project_id, 'project_name': projects_map[project_id]['name'] } for project_id in projects_id] levels_map = vault.get_vault()['levels_map'] levels = [{ 'level_id': level_id, 'level_name': levels_map[level_id]['level_name'] } for level_id in levels_id] if selected_project_id not in projects_map: selected_project_id = None if selected_vendor not in vendors: selected_vendor = None if selected_level_id not in levels_map: selected_level_id = None return { 'drivers': drivers, 'vendors': sorted(vendors), 'levels': sorted(levels, key=lambda x: x['level_name']), 'projects': sorted(projects, key=lambda x: x['project_name']), 'project_id': selected_project_id, 'vendor': selected_vendor, 'level_id': selected_level_id, }
def summary(): selected_project_id = parameters.get_single_parameter({}, 'project_id') selected_vendor = parameters.get_single_parameter({}, 'vendor') selected_level_id = parameters.get_single_parameter({}, 'level_id') drivers = api.get_drivers_internal(project_id=selected_project_id, vendor=selected_vendor, level_id=selected_level_id) vendors = set() levels_id = set() projects_id = set() for driver in api.get_drivers_internal(project_id=selected_project_id, level_id=selected_level_id): vendors.add(driver['vendor']) for driver in api.get_drivers_internal(project_id=selected_project_id, vendor=selected_vendor): levels_id.add(driver['level_id']) for driver in api.get_drivers_internal(vendor=selected_vendor, level_id=selected_level_id): projects_id.add(driver['project_id']) projects_map = vault.get_vault()['projects_map'] projects = [{'project_id': project_id, 'project_name': projects_map[project_id]['name']} for project_id in projects_id] levels_map = vault.get_vault()['levels_map'] levels = [{'level_id': level_id, 'level_name': levels_map[level_id]['level_name']} for level_id in levels_id] if selected_project_id not in projects_map: selected_project_id = None if selected_vendor not in vendors: selected_vendor = None if selected_level_id not in levels_map: selected_level_id = None return { 'drivers': drivers, 'vendors': sorted(vendors), 'levels': sorted(levels, key=lambda x: x['level_name']), 'projects': sorted(projects, key=lambda x: x['project_name']), 'project_id': selected_project_id, 'vendor': selected_vendor, 'level_id': selected_level_id, }
def details(): project_id = flask.request.args.get('project_id') or '' vendor = flask.request.args.get('vendor') or '' driver_name = flask.request.args.get('driver_name') or '' drivers_map = vault.get_vault()['drivers_map'] key = (urllib.unquote_plus(project_id).lower(), urllib.unquote_plus(vendor).lower(), urllib.unquote_plus(driver_name).lower()) if key not in drivers_map: flask.abort(404) driver = drivers_map[key] os_versions_list = [] for os_version, os_version_info in driver['os_versions_map'].iteritems(): os_version_info['os_version'] = os_version os_versions_list.append(os_version_info) sorted(os_versions_list, key=lambda x: x['os_version']) driver['os_versions'] = os_versions_list return { 'driver': driver, }
def get_drivers_internal(**params): drivers = vault.get_vault()['drivers_map'] filtered_drivers = [] for driver in drivers.values(): include = True for param, value in params.iteritems(): value = value.lower() if param == 'release_id' and value: found = False for release in driver['releases_info']: if release['release_id'] == value: found = True break if not found: include = False break elif value and (driver.get(param) or '').lower() != value: include = False break if include: filtered_drivers.append(driver) return filtered_drivers
def get_drivers_internal(**params): drivers = vault.get_vault()['drivers_map'] filtered_drivers = [] for driver in drivers.values(): include = True for param, value in params.iteritems(): if value and driver.get(param) != value: include = False break if include: filtered_drivers.append(driver) return filtered_drivers
def get_drivers_internal(**params): drivers = vault.get_vault()['drivers_map'] filtered_drivers = [] # when release_id is not set return only drivers from active releases if not params.get('release_id'): all_releases = vault.get_vault()['releases_map'] active_releases = ','.join( sorted(r['id'].lower() for r in all_releases.values() if r.get('active'))) params['release_id'] = active_releases for driver in drivers.values(): include = True for param, value in params.iteritems(): value = value.lower() if param == 'release_id' and value: query_releases = set(value.split(',')) found = False for release in driver['releases_info']: if release['release_id'] in query_releases: found = True break if not found: include = False break elif value and (driver.get(param) or '').lower() != value: include = False break if include: filtered_drivers.append(driver) return filtered_drivers
def get_project_ids(): selected_vendor = parameters.get_single_parameter({}, 'vendor') selected_release_id = parameters.get_single_parameter({}, 'release_id') query = (parameters.get_single_parameter({}, 'query') or '').lower() projects_map = vault.get_vault()['projects_map'] project_ids = set() for driver in get_drivers_internal(vendor=selected_vendor, release_id=selected_release_id): if projects_map[driver['project_id']]['name'].lower().find(query) >= 0: project_ids.add(driver['project_id']) projects = [{'id': project_id, 'text': projects_map[project_id]['name']} for project_id in project_ids] return sorted(projects, key=lambda x: x['text'])
def get_project_ids(): selected_vendor = parameters.get_single_parameter({}, 'vendor') selected_release_id = parameters.get_single_parameter({}, 'release_id') query = (parameters.get_single_parameter({}, 'query') or '').lower() projects_map = vault.get_vault()['projects_map'] project_ids = set() for driver in get_drivers_internal(vendor=selected_vendor, release_id=selected_release_id): if projects_map[driver['project_id']]['name'].lower().find(query) >= 0: project_ids.add(driver['project_id']) projects = [{ 'id': project_id, 'text': projects_map[project_id]['name'] } for project_id in project_ids] return sorted(projects, key=lambda x: x['text'])
def get_project_id(project_id): projects_map = vault.get_vault()['projects_map'] if project_id in projects_map: return {'id': project_id, 'text': projects_map[project_id]['name']} else: flask.abort(404)