def default(self, *args): admin=False if predicates.not_anonymous(): if predicates.has_permission('admin'): admin=True kernel_name = args[0] kernel = Kernel.by_kernel_name(kernel_name) return dict(kernel=kernel, admin=admin)
def create(self, **kw): """Create a new kernel and save it to the database.""" user = request.environ.get('repoze.who.identity')['user'] name = kw['name'] arch = Arch.by_arch_name(kw['arch']) osrelease = OSRelease.by_osrelease_name(kw['osrelease']) vendor = Vendor.by_vendor_name(kw['vendor']) comment = kw['comment'] owner = User.by_user_name(kw['owner']) if comment == "": comment = name kernel = Kernel() kernel.name = name kernel.arch = arch kernel.osrelease = osrelease kernel.vendor = vendor kernel.state.creator = user kernel.state.owner = owner kernel.comments.append(Comment(comment=comment)) DBSession.add(kernel) DBSession.flush() redirect("index")
def create(self, **kw): """Create a new driverbuild and save it to the database.""" user = request.environ.get('repoze.who.identity')['user'] driver = Driver.by_driver_id(kw['driver_id']) kernel = Kernel.by_kernel_name(kw['kernel']) vendor = Vendor.by_vendor_name(kw['vendor']) version = kw['version'] comment = kw['comment'] owner = User.by_user_name(kw['owner']) if comment == "": comment = name driverbuild = DriverBuild() driverbuild.driver = driver driverbuild.kernel = kernel driverbuild.vendor = vendor driverbuild.version = version driverbuild.state.creator = user driverbuild.state.owner = owner driverbuild.comments.append(Comment(comment=comment)) DBSession.add(driverbuild) DBSession.flush() redirect("/drivers/"+driver.name)
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