def addsystem(self, **kw): """Add a system to a device and save it to the database.""" user = request.environ.get('repoze.who.identity')['user'] device = Device.by_device_id(kw['device_id']) system = System.by_system_name(kw['system']) device.systems.append(system) DBSession.flush() redirect("/devices/"+device.name)
def default(self, *args): admin=False if predicates.not_anonymous(): if predicates.has_permission('admin'): admin=True system_name = args[0] system = System.by_system_name(system_name) devices = system.devices return dict(system=system, devices=devices, admin=admin)
def create(self, **kw): """Create a new device and save it to the database.""" user = request.environ.get('repoze.who.identity')['user'] name = kw['name'] vendor = Vendor.by_vendor_name(kw['vendor']) systemfamily = SystemFamily.by_systemfamily_name(kw['family']) version = kw['version'] comment = kw['comment'] owner = User.by_user_name(kw['owner']) if comment == "": comment = name system = System() system.name = name system.vendor = vendor system.systemfamily = systemfamily system.version = version system.state.creator = user system.state.owner = owner system.comments.append(Comment(comment=comment)) DBSession.add(system) DBSession.flush() redirect("index")
def index(self): """Handle the front-page.""" if predicates.is_anonymous(): admin=False logged_in=False else: logged_in=True user = request.environ.get('repoze.who.identity')['user'] if predicates.has_permission('admin'): admin=True else: admin=False systems = System.get_all_systems() return dict(page='index',systems=systems, logged_in=logged_in, admin=admin)
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