def __init__(self, model, controller, opts, loop): self.model = model self.controller = controller self.opts = opts self.loop = loop self.items = [] self.email = EmailEditor() self.error = Text("", align="center") self.progress = Text("", align="center") body = [ ('pack', Text("")), ListBox([ self._build_model_inputs(), Padding.line_break(""), Padding.center_79( Color.info_minor( Text("If you do not have an account, visit " "https://login.ubuntu.com to create one."))), Padding.line_break(""), Padding.center_90(Color.info_error(self.error)), Padding.center_90(self.progress), ]), ('pack', Pile([ ('pack', Text("")), button_pile(self._build_buttons()), ('pack', Text("")), ])), ] super().__init__(Pile(body))
def __init__(self, model, controller, name): self.model = model self.controller = controller self.dev = self.model.get_netdev_by_name(name) self.form = WLANForm() connect_signal(self.form, 'submit', self.done) connect_signal(self.form, 'cancel', self.cancel) if self.dev.configured_ssid is not None: self.form.ssid.value = self.dev.configured_ssid if self.dev.configured_wifi_psk is not None: self.form.psk.value = self.dev.configured_wifi_psk self.ssid_row = self.form.ssid.as_row(self, self.form.longest_caption) self.psk_row = self.form.psk.as_row(self, self.form.longest_caption) self.inputs = Pile(self._build_iface_inputs()) self.error = Text("") self.body = [ Padding.center_79(self.inputs), Padding.line_break(""), Padding.center_79(Color.info_error(self.error)), Padding.line_break(""), Padding.fixed_10(Pile([self.form.done_btn, self.form.cancel_btn])), ] self.orig_w = None super().__init__(ListBox(self.body))
def __init__(self, model, signal, iface): self.model = model self.signal = signal self.ifname = iface self.iface = self.model.get_interface(self.ifname) self.is_gateway = False self.gateway_input = StringEditor(caption="") # FIXME: ipaddr_editor self.address_input = StringEditor(caption="") # FIXME: ipaddr_editor self.subnet_input = StringEditor(caption="") # FIXME: ipaddr_editor self.error = Text("", align='center') self.nameserver_input = \ StringEditor(caption="") # FIXME: ipaddr_editor self.searchdomains_input = \ StringEditor(caption="") # FIXME: ipaddr_editor self.set_as_default_gw_button = Pile( self._build_set_as_default_gw_button()) body = [ Padding.center_79(self._build_iface_inputs()), Padding.line_break(""), Padding.center_79(self.set_as_default_gw_button), Padding.line_break(""), Padding.center_90(Color.info_error(self.error)), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, signal, selected_disk): log.debug('AddPartitionView: selected_disk=[{}]'.format(selected_disk)) self.model = model self.signal = signal self.selected_disk = selected_disk self.disk_obj = self.model.get_disk(selected_disk) self.partnum = IntegerEditor(caption="", default=self.disk_obj.lastpartnumber + 1) self.size_str = _humanize_size(self.disk_obj.freespace) self.size = StringEditor(caption="".format(self.size_str)) self.mountpoint = MountEditor(caption="", edit_text="/") self.fstype = Selector(opts=self.model.supported_filesystems) body = [ Columns([ ("weight", 0.2, Text("Adding partition to {}".format(self.disk_obj.devpath), align="right")), ("weight", 0.3, Text("")) ]), Padding.line_break(""), self._container(), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] partition_box = Padding.center_50(ListBox(body)) super().__init__(partition_box)
def __init__(self, signal): self.signal = signal self.body = [ Padding.center_79(Text("This view is not yet implemented.")), Padding.line_break(""), Padding.center_79(Color.info_minor(Text("A place holder widget"))), Padding.line_break(""), Padding.center_79(self._build_buttons()) ] super().__init__(ListBox(self.body))
def __init__(self, signal, error_message): suggestion = "Check the installer log files for details and try again" self.signal = signal self.body = [ Padding.center_79(Text(error_message)), Padding.line_break(""), Padding.center_79(Color.info_minor(Text(suggestion))), Padding.line_break(""), Padding.line_break(""), Padding.center_79(self._build_buttons()) ] super().__init__(ListBox(self.body))
def __init__(self, model, signal): self.model = model self.signal = signal self.volgroup = UsernameEditor() self.selected_disks = [] body = [ Padding.center_50(self._build_disk_selection()), Padding.line_break(""), Padding.center_50(self._build_lvm_configuration()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, controller): self.model = model self.controller = controller self.bond_iface = None self.bond_mode = Selector(self.model.bonding_modes.values()) self.selected_ifaces = [] body = [ Padding.center_50(self._build_iface_selection()), Padding.line_break(""), Padding.center_50(self._build_bondmode_configuration()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, controller, ifaces): self.model = model self.controller = controller self.ifaces = ifaces self.items = [] self.body = [ Padding.line_break(""), Padding.line_break(""), Padding.line_break(""), Padding.center_79(self._build_model_inputs()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(self.body))
def __init__(self, model, family, controller): self.model = model self.family = family self.controller = controller self.default_gateway_w = None self.gateway_options = Pile(self._build_default_routes()) body = [ Padding.center_79(Text("Please set the default gateway:")), Padding.line_break(""), Padding.center_79(self.gateway_options), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, signal, selected_disk): self.model = model self.signal = signal self.selected_disk = selected_disk self.disk_obj = self.model.get_disk(self.selected_disk) self.body = [ Padding.center_79(self._build_model_inputs()), Padding.line_break(""), Padding.center_79(self._build_menu()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()), ] super().__init__(ListBox(self.body))
def __init__(self, model, signal): self.model = model self.signal = signal self.selected_disks = { 'CACHE': None, 'BACKING': None, } body = [ Padding.center_50(self._build_disk_selection(section='CACHE')), Padding.line_break(""), Padding.center_50(self._build_disk_selection(section='BACKING')), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, signal): self.model = model self.signal = signal self.raid_level = Selector(self.model.raid_levels) self.hot_spares = IntegerEditor() self.chunk_size = StringEditor(edit_text="4K") self.selected_disks = [] body = [ Padding.center_50(self._build_disk_selection()), Padding.line_break(""), Padding.center_50(self._build_raid_configuration()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def _build_used_disks(self): log.debug('FileSystemView: building used disks') pl = [] for disk in self.model.get_used_disk_names(): log.debug('used disk: {}'.format(disk)) disk_string = disk disk_tag = self.model.get_tag(disk) if len(disk_tag): disk_string += " {}".format(disk_tag) pl.append(Color.info_minor(Text(disk_string))) if len(pl): return Pile([Text("USED DISKS"), Padding.line_break("")] + pl + [Padding.line_break("")]) return Pile(pl)
def refresh_model_inputs(self): widgets = self._build_model_inputs() + [ Padding.center_79(self.additional_options), Padding.line_break(""), ] self.listbox.body[:] = widgets self.additional_options.contents = [ (obj, ('pack', None)) for obj in self._build_additional_options() ]
def __init__(self, opts, model, signal, user, ifaces): self.opts = opts self.model = model self.signal = signal self.user = user self.ifaces = ifaces self.items = [] self.body = [ Padding.line_break(""), Padding.line_break(""), Padding.line_break(""), Padding.center_79(self._build_model_inputs()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(self.body))
def __init__(self, model, signal, selected_disk): self.model = model self.signal = signal self.selected_disk = selected_disk self.disk_obj = self.model.get_disk(selected_disk) self.mountpoint = MountEditor(caption="", edit_text="/") self.fstype = Selector(opts=self.model.supported_filesystems) body = [ Padding.line_break(""), self._container(), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] format_box = Padding.center_50(ListBox(body)) super().__init__(format_box)
def __init__(self, model, controller, name): self.model = model self.controller = controller self.dev = self.model.get_netdev_by_name(name) self.is_gateway = False self.form = NetworkConfigForm(self.ip_version) connect_signal(self.form, 'submit', self.done) connect_signal(self.form, 'cancel', self.cancel) self.form.subnet.help = "CIDR e.g. %s"%(self.example_address,) configured_addresses = self.dev.configured_ip_addresses_for_version(self.ip_version) if configured_addresses: addr = ipaddress.ip_interface(configured_addresses[0]) self.form.subnet.value = str(addr.network) self.form.address.value = str(addr.ip) configured_gateway = self.dev.configured_gateway_for_version(self.ip_version) if configured_gateway: self.form.gateway.value = configured_gateway self.form.nameservers.value = ', '.join(self.dev.configured_nameservers) self.form.searchdomains.value = ', '.join(self.dev.configured_searchdomains) self.error = Text("", align='center') #self.set_as_default_gw_button = Pile(self._build_set_as_default_gw_button()) body = [ Padding.center_79(self.form.as_rows(self)), #Padding.line_break(""), #Padding.center_79(self.set_as_default_gw_button), Padding.line_break(""), Padding.fixed_10(self.form.buttons) ] super().__init__(ListBox(body))
def _build_model_inputs(self): user = self.model.user ips = [] for dev in self.netdevs: for addr in dev.actual_global_ip_addresses: ips.append(addr) if not user: sl = [] sl.append(Text("no owner")) return sl local_tpl = ( "This device is registered to {realname}.") remote_tpl = ( "\n\nRemote access was enabled via authentication with SSO user" " <{username}>.\nPublic SSH keys were added to the device " "for remote access.\n\n{realname} can connect remotely to this " "device via SSH:") sl = [] login_info = { 'realname': user.realname, 'username': user.username, } login_text = local_tpl.format(**login_info) login_text += remote_tpl.format(**login_info) sl += [Text(login_text), Padding.line_break("")] for ip in ips: ssh_iface = " ssh %s@%s" % (user.username, ip) sl.append(Text(ssh_iface)) return sl
def __init__(self, model, controller): self.model = model self.controller = controller self.items = [] self.error = Text("", align='center') self.model_inputs = Pile(self._build_model_inputs()) self.additional_options = Pile(self._build_additional_options()) self.body = [ self.model_inputs, Padding.center_79(self.additional_options), Padding.line_break(""), ] self.lb = Padding.center_90(ListBox(self.body)) self.footer = Pile([ Text(""), self._build_buttons(), Text(""), ]) self.error_showing = False self.frame = Pile([ ('pack', Text("")), self.lb, ('pack', self.footer)]) self.lb.original_widget._select_last_selectable() self.frame.focus_position = 2 super().__init__(self.frame)
def _build_iface_inputs(self): if len(self.dev.actual_ssids) > 0: networks_btn = menu_btn("Choose a visible network", on_press=self.show_ssid_list) else: networks_btn = Color.info_minor( Columns([('fixed', 1, Text("")), Text("No visible networks"), ('fixed', 1, Text(">"))], dividechars=1)) if not self.dev.scan_state: scan_btn = menu_btn("Scan for networks", on_press=self.start_scan) else: scan_btn = Color.info_minor( Columns([('fixed', 1, Text("")), Text("Scanning for networks"), ('fixed', 1, Text(">"))], dividechars=1)) col = [ Padding.center_79( Color.info_minor( Text( "Only open or WPA2/PSK networks are supported at this time." ))), Padding.line_break(""), self.ssid_row, Padding.fixed_30(networks_btn), Padding.fixed_30(scan_btn), self.psk_row, ] return col
def _build_model_inputs(self): local_tpl = ("This device is registered to {realname}.") remote_tpl = ( "\n\nRemote access was enabled via authentication with SSO user" " <{username}>.\nPublic SSH keys were added to the device " "for remote access.\n\n{realname} can connect remotely to this " "device via SSH:") sl = [] ssh = [] user = self.model.user login_info = { 'realname': user.realname, 'username': user.username, } login_text = local_tpl.format(**login_info) login_text += remote_tpl.format(**login_info) ips = [] for iface in self.ifaces: for addr in iface.dhcp4_addresses: try: ip = str(addr[0]).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for addr in iface.ipv4_addresses: try: ip = str(addr).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for addr in iface.dhcp6_addresses: try: ip = str(addr[0]).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for addr in iface.ipv6_addresses: try: ip = str(addr).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for ip in ips: ssh_iface = " ssh %s@%s" % (user.username, ip) ssh += [Padding.center_50(Text(ssh_iface))] sl += [Text(login_text), Padding.line_break("")] + ssh return Pile(sl)
def _build_body(self): body = [] if self.dev.type == 'wlan': body.extend([ self.wifi_info, self.wifi_method, Padding.line_break(""), ]) body.extend([ self.ipv4_info, self.ipv4_method, Padding.line_break(""), self.ipv6_info, self.ipv6_method, Padding.line_break(""), ]) return body
def _build_model_inputs(self): """ This device is registered to Ryan Harper. Ryan Harper added a user, raharper, to the device for local access on the console. Remote access was enabled via authentication with Launchpad as lp:raharper and public ssh keys were added to the system for remote access. Ryan Harper can remotely connect to this system via SSH: ssh [email protected] ssh [email protected] """ local_tpl = ( "This device is registered to {realname}. {realname} added a" " user, <{username}> to the device for access.") remote_tpl = ( "\n\nRemote access was enabled via authentication with {auth} user" " <{ssh_import_id}>.\nPublic SSH keys were added to the device " "for remote access.\n\n{realname} can connect remotely to this " "device via SSH:") sl = [] ssh = [] user = self.model.user login_info = { 'realname': user.realname, 'username': user.username, } login_text = local_tpl.format(**login_info) if user.ssh_import_id: login_info.update({ 'auth': self.auth_name(user.ssh_import_id), 'ssh_import_id': user.ssh_import_id.split(":")[-1] }) login_text += remote_tpl.format(**login_info) ips = [] for dev in self.ifaces: for addr in dev.actual_ip_addresses: ips.append(addr) for ip in ips: ssh_iface = " ssh %s@%s" % (user.username, ip) ssh += [Padding.center_50(Text(ssh_iface))] print(login_info) sl += [Text(login_text), Padding.line_break("")] + ssh return Pile(sl)
def __init__(self, model, signal): self.model = model self.signal = signal self.items = [] self.error = Text("", align='center') self.body = [ Padding.center_79(self._build_model_inputs()), Padding.line_break(""), Padding.center_79(self._build_additional_options()), Padding.line_break(""), Padding.center_79(Color.info_error(self.error)), Padding.line_break(""), Padding.fixed_10(self._build_buttons()), ] # FIXME determine which UX widget should have focus self.lb = ListBox(self.body) self.lb.set_focus(4) # _build_buttons super().__init__(self.lb)
def _build_body(self): body = [] if self.dev.type == 'wlan': body.extend([ Padding.center_79(self.wifi_info), Padding.center_79(self.wifi_method), Padding.line_break(""), ]) body.extend([ Padding.center_79(self.ipv4_info), Padding.center_79(self.ipv4_method), Padding.line_break(""), Padding.center_79(self.ipv6_info), Padding.center_79(self.ipv6_method), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ]) return body
def __init__(self, model, signal): self.model = model self.signal = signal self.iscsi_host = StringEditor() self.connect_anon = YesNo() self.connect_username = StringEditor() self.connect_password = PasswordEditor() self.server_auth = YesNo() self.server_username = StringEditor() self.server_password = PasswordEditor() body = [ Padding.center_50(self._build_model_inputs()), Padding.line_break(""), Padding.center_50(self._build_menu()), Padding.line_break(""), Padding.center_75(self._build_volume_mount_selector()) ] super().__init__(ListBox(body))
def __init__(self, model, signal): self.model = model self.signal = signal self.items = [] self.body = [ Padding.center_79(self._build_model_inputs()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()), ] super().__init__(ListBox(self.body))
def __init__(self, model, signal): log.debug('FileSystemView init start()') self.model = model self.signal = signal self.items = [] self.model.probe_storage() # probe before we complete self.body = [ Padding.center_79(Text("FILE SYSTEM")), Padding.center_79(self._build_partition_list()), Padding.line_break(""), Padding.center_79(Text("AVAILABLE DISKS")), Padding.center_79(self._build_model_inputs()), Padding.line_break(""), Padding.center_79(self._build_menu()), Padding.line_break(""), Padding.center_79(self._build_used_disks()), Padding.fixed_10(self._build_buttons()), ] super().__init__(ListBox(self.body)) log.debug('FileSystemView init complete()')
def __init__(self, message, current, complete): message_widget = Padding.center_79(Text(message)) progress_bar = Padding.center_60( StepsProgressBar(normal='progress_incomplete', complete='progress_complete', current=current, done=complete)) status = [ progress_bar, Padding.line_break(""), message_widget, ] super().__init__(Color.frame_footer(Pile(status)))