def getDeviceInfo(busId): if not os.path.exists(consts.config_file): return doc = piksemel.parse(consts.config_file) cardTag = None for tag in doc.tags("Card"): if tag.getAttribute("busId") == busId: cardTag = tag break if not cardTag: return device = VideoDevice(busId=busId) device.saved_vendor_id = cardTag.getTagData("VendorId") device.saved_product_id = cardTag.getTagData("ProductId") driver = cardTag.getTagData("Driver") activeConfigTag = cardTag.getTag("ActiveConfig") if driver: device.driver = driver elif activeConfigTag: driver = activeConfigTag.getTagData("Driver") if driver: device.driver = driver depth = cardTag.getTagData("Depth") if depth: device.depth = int(depth) def addMonitor(output, tag): mon = Monitor() mon.vendor = tag.getTagData("Vendor") or "" mon.model = tag.getTagData("Model") or "Unknown Monitor" mon.hsync = tag.getTagData("HorizSync") or mon.hsync mon.vref = tag.getTagData("VertRefresh") or mon.vref device.monitors[output] = mon # Get output info outputsTag = cardTag.getTag("Outputs") if outputsTag: for outputTag in outputsTag.tags("Output"): name = outputTag.getAttribute("name") output = Output(name) device.outputs[name] = output enabled = outputTag.getTagData("Enabled") if enabled: output.setEnabled(enabled == "true") ignored = outputTag.getTagData("Ignored") if ignored: output.setIgnored(ignored == "true") mode = outputTag.getTagData("Mode") or "" rate = outputTag.getTagData("RefreshRate") or "" output.setMode(mode, rate) rotation = outputTag.getTagData("Rotation") if rotation: output.setOrientation(rotation) rightOf = outputTag.getTagData("RightOf") below = outputTag.getTagData("Below") if rightOf: output.setPosition("RightOf", rightOf) elif below: output.setPosition("Below", below) monitorTag = outputTag.getTag("Monitor") if monitorTag: addMonitor(name, monitorTag) return device