Пример #1
0
    def create(self, **kw):
	"""Create a new osfamily and save it to the database."""
	user = request.environ.get('repoze.who.identity')['user']
	name = kw['name']
	vendor = Vendor.by_vendor_name(kw['vendor'])
	comment = kw['comment']
	owner = User.by_user_name(kw['owner'])
	if comment == "":
		comment = name
	osfamily = OSFamily()
	osfamily.name = name
	osfamily.vendor = vendor
	osfamily.state.creator = user
	osfamily.state.owner = owner
	osfamily.comments.append(Comment(comment=comment))
	DBSession.add(osfamily)
	DBSession.flush()
	redirect("index")
Пример #2
0
    def default(self, *args):
	admin=False
	if predicates.not_anonymous():
		if predicates.has_permission('admin'):
			admin=True
	osfamily_name = args[0]
	osfamily = OSFamily.by_osfamily_name(osfamily_name)
	osreleases = osfamily.osreleases
	return dict(osfamily=osfamily, osreleases=osreleases,
		    admin=admin)
Пример #3
0
def get_driverDescs(system_vendor_name, system_product_name,
		    osfamily_name, osrelease_version,
		    kernel_name, arch_name,
		    components):

	system = None

	system_vendor = Vendor.by_vendor_name(system_vendor_name)
	if system_vendor:
		system = System.by_system_vendor_and_name(system_vendor,
							  system_product_name)

	# components are only optional if the system detail is supplied.
	if (not system) and (components==[]):
		return {}

	# FIXME: must parse modaliases specially if they are here
	# will add a special meta-tag to indicate the requirement.
	devices = []
	for component in components:
		devicealias = DeviceAlias.by_devicealias(component)
		if devicealias:
			devices.append(devicealias.device)

	osrelease = None
	osfamily = OSFamily.by_osfamily_name(osfamily_name)
	if osfamily:
		osrelease = OSRelease.by_osrelease_osfamily_and_version(
							  osfamily,
							  osrelease_version)

	# not going to return any devices unless an OSRelease is given
	if not osrelease:
		return {}

	arch = Arch.by_arch_name(arch_name)
	# not going to return any devices unless an Arch is given
	if not arch:
		return {}

	kernel = Kernel.by_kernel_osrelease_arch_and_name(osrelease,
							  arch,
							  kernel_name)
	# not going to return any devices unless a Kernel is given
	if not kernel:
		return {}

	results = {}
	for device in system.devices:
		# ignore the device if it wasn't asked about or none were
		if (not components==[]) and (not device in devices):
			continue

		for driver in device.drivers:
			if kernel in driver.kernels:
				driver_type=driver.drivertype.name
				driver_meta={}
				for meta in driver.drivermeta:
					driver_meta[meta.tag] = meta.value
				free=driver.license.free
				license=driver.license.name

				prefix=driver.drivertype.prefix
				for alias in device.devicealiases:
					devalias = prefix + alias.alias

					for build in driver.driverbuilds:
						driver_vendor=build.vendor.name
						build_meta={}
						for meta in build.driverbuildmeta:
							build_meta[meta.tag] = meta.value
						description={}
						for desc in build.descriptions:
							description[desc.locale] = desc.description
						
						result = {
							'driver_type': driver_type,
							'driver_vendor': driver_vendor,
							'description': description,
							'free': free,
							'license': license}
						result.update(driver_meta)
						result.update(build_meta)

						if results.has_key(devalias):
							results[devalias].append(result)
						else:
							results[devalias] = [result]

	return results