def __init__(self, screen, tui): self.screen = screen self.tui = tui size = snack._snack.size() #get the virtualization uuid and set it to other. (virt_uuid, virt_type) = rhnreg.get_virt_info() if not virt_uuid is None: self.tui.other['virt_uuid'] = virt_uuid self.tui.other['virt_type'] = virt_type # read all hardware in tui.hardware = hardware.Hardware() toplevel = snack.GridForm(screen, HARDWARE_WINDOW.encode('utf-8'), 1, 7) text = snack.TextboxReflowed(70, HARDWARE_WINDOW_DESC1.encode('utf-8')) toplevel.add(text, 0, 0, anchorLeft=1) grid = snack.Grid(2, 2) label = snack.Label(_("Profile name:").encode('utf-8')) grid.setField(label, 0, 0, padding=(0, 0, 1, 0), anchorRight=1) self.profileEntry = snack.Entry(40) grid.setField(self.profileEntry, 1, 0, anchorLeft=1) toplevel.add(grid, 0, 1, anchorLeft=1) if tui.includeHardware: self.hardwareButton = snack.Checkbox( HARDWARE_WINDOW_CHECKBOX.encode('utf-8'), isOn=1) else: self.hardwareButton = snack.Checkbox( HARDWARE_WINDOW_CHECKBOX.encode('utf-8')) toplevel.add(self.hardwareButton, 0, 2, padding=(0, 1, 0, 0), anchorLeft=1) label = snack.Label(DESELECT.encode('utf-8')) toplevel.add(label, 0, 3, anchorLeft=1, padding=(0, 0, 0, 1)) grid = snack.Grid(4, 3) hardware_text = '' hardware_text += _("Version: ") + up2dateUtils.getVersion() + " " self.versionLabel = snack.Label(_("Version: ").encode('utf-8')) grid.setField(self.versionLabel, 0, 0, padding=(0, 0, 1, 0), anchorLeft=1) self.versionLabel2 = snack.Label(up2dateUtils.getVersion()) grid.setField(self.versionLabel2, 1, 0, anchorLeft=1) hardware_text += _("CPU model: ") for hw in tui.hardware: if hw['class'] == 'CPU': hardware_text += hw['model'] + "\n" hardware_text += _("Hostname: ") for hw in tui.hardware: if hw['class'] == 'NETINFO': unicode_hostname = idn_pune_to_unicode(hw['hostname']) hardware_text += unicode_hostname + "\n" if tui.profileName != "": self.profileEntry.set(tui.profileName) else: self.profileEntry.set(unicode_hostname.encode('utf-8')) hardware_text += _("CPU speed: ") for hw in tui.hardware: if hw['class'] == 'CPU': hardware_text += _("%d MHz") % hw['speed'] + " " hardware_text += _("IP Address: ") for hw in tui.hardware: if hw['class'] == 'NETINFO': if hw['ipaddr']: hardware_text += hw['ipaddr'] + " " elif hw['ip6addr']: hardware_text += hw['ip6addr'] + " " hardware_text += _("Memory: ") for hw in tui.hardware: if hw['class'] == 'MEMORY': hardware_text += _("%s megabytes") % hw['ram'] tb = snack.TextboxReflowed(80, hardware_text.encode('utf-8')) toplevel.add(tb, 0, 4) self.additionalHWLabel = snack.TextboxReflowed( size[0] - 10, HARDWARE_WINDOW_DESC2.encode('utf-8')) toplevel.add(self.additionalHWLabel, 0, 5, padding=(0, 1, 0, 0), anchorLeft=1) # BUTTON BAR self.bb = snack.ButtonBar(screen, [(NEXT.encode('utf-8'), "next"), (BACK.encode('utf-8'), "back"), (CANCEL.encode('utf-8'), "cancel")]) toplevel.add(self.bb, 0, 6, padding=(0, 1, 0, 0), growx=1) self.g = toplevel
def __init__(self, screen, tui): self.screen = screen self.tui = tui size = snack._snack.size() #get the virtualization uuid and set it to other. (virt_uuid, virt_type) = rhnreg.get_virt_info() if not virt_uuid is None: self.tui.other['virt_uuid'] = virt_uuid self.tui.other['virt_type'] = virt_type # read all hardware in tui.hardware = hardware.Hardware() toplevel = snack.GridForm(screen, HARDWARE_WINDOW.encode('utf-8'), 1, 7) text = snack.TextboxReflowed(70, HARDWARE_WINDOW_DESC1.encode('utf-8')) toplevel.add(text, 0, 0, anchorLeft = 1) grid = snack.Grid(2, 2) label = snack.Label(_("Profile name:").encode('utf-8')) grid.setField(label, 0, 0, padding = (0, 0, 1, 0), anchorRight = 1) self.profileEntry = snack.Entry(40) grid.setField(self.profileEntry, 1, 0, anchorLeft = 1) toplevel.add(grid, 0, 1, anchorLeft = 1) if tui.includeHardware: self.hardwareButton = snack.Checkbox(HARDWARE_WINDOW_CHECKBOX.encode('utf-8'), isOn = 1) else: self.hardwareButton = snack.Checkbox(HARDWARE_WINDOW_CHECKBOX.encode('utf-8')) toplevel.add(self.hardwareButton, 0, 2, padding = (0, 1, 0, 0), anchorLeft = 1) label = snack.Label(DESELECT.encode('utf-8')) toplevel.add(label, 0, 3, anchorLeft = 1, padding = (0, 0, 0, 1)) grid = snack.Grid(4, 3) hardware_text = '' hardware_text += _("Version: ") + up2dateUtils.getVersion() + " " self.versionLabel = snack.Label(_("Version: ").encode('utf-8')) grid.setField(self.versionLabel, 0, 0, padding = (0, 0, 1, 0), anchorLeft = 1) self.versionLabel2 = snack.Label(up2dateUtils.getVersion()) grid.setField(self.versionLabel2, 1, 0, anchorLeft = 1) hardware_text += _("CPU model: ") for hw in tui.hardware: if hw['class'] == 'CPU': hardware_text += hw['model'] +"\n" hardware_text += _("Hostname: ") for hw in tui.hardware: if hw['class'] == 'NETINFO': unicode_hostname = idn_puny_to_unicode(hw['hostname']) hardware_text += unicode_hostname + "\n" if tui.profileName != "": self.profileEntry.set(tui.profileName) else: self.profileEntry.set(unicode_hostname.encode('utf-8')) hardware_text += _("CPU speed: ") for hw in tui.hardware: if hw['class'] == 'CPU': hardware_text += _("%d MHz") % hw['speed'] + " " hardware_text += _("IP Address: ") for hw in tui.hardware: if hw['class'] == 'NETINFO': if hw['ipaddr']: hardware_text += hw['ipaddr'] + " " elif hw['ip6addr']: hardware_text += hw['ip6addr'] + " " hardware_text += _("Memory: ") for hw in tui.hardware: if hw['class'] == 'MEMORY': hardware_text += _("%s megabytes") % hw['ram'] tb = snack.TextboxReflowed(80, hardware_text.encode('utf-8')) toplevel.add(tb, 0, 4) self.additionalHWLabel = snack.TextboxReflowed(size[0]-10, HARDWARE_WINDOW_DESC2.encode('utf-8')) toplevel.add(self.additionalHWLabel, 0, 5, padding = (0, 1, 0, 0), anchorLeft = 1) # BUTTON BAR self.bb = snack.ButtonBar(screen, [(NEXT.encode('utf-8'), "next"), (BACK.encode('utf-8'), "back"), (CANCEL.encode('utf-8'), "cancel")]) toplevel.add(self.bb, 0, 6, padding = (0, 1, 0, 0), growx = 1) self.g = toplevel