1
"""This file contains the Device class."""
6
def __init__(self, device_name, parent_name, properties):
7
self.device_name = device_name
8
self.parent_name = parent_name
9
self.parent_device = None
10
self.properties = properties
13
def print_tree(self, indent):
15
print " "*indent + self.device_name
17
print " "*indent + "- " + self.device_name
18
for c in self.children:
19
c.print_tree(indent+4)
21
def populate_gtk_tree(self, tree_model, dont_show_virtual, representation):
22
# see if we should show virtual devices
25
if self.properties["info.virtual"]:
26
# do show all block devices, ide channels
27
if not self.properties["info.subsystem"] in ["block", "ide_host"]:
28
self.row = self.parent_device.row
29
# and recurse the childs
30
for c in self.children:
31
c.populate_gtk_tree(tree_model,
37
if self.parent_device==None:
40
self.row = tree_model.append(self.parent_device.row)
44
icon = representation.get_icon(self)
46
tree_model.set_value(self.row, Const.PIXBUF_COLUMN, icon)
48
title_name = self.properties["info.product"]
50
title_name = "Unknown Device"
52
title_name = "Unknown Device"
53
tree_model.set_value(self.row, Const.TITLE_COLUMN, title_name)
54
tree_model.set_value(self.row, Const.UDI_COLUMN, self.device_name)
56
for c in self.children:
57
c.populate_gtk_tree(tree_model,
61
def find_by_udi(self, device_udi):
62
if self.device_name==device_udi:
64
for c in self.children:
65
rc = c.find_by_udi(device_udi)