Ejemplo n.º 1
0
    def _download_done(
        self, fileinfo: FileInfo, statusw: urwid.WidgetPlaceholder, task: asyncio.Task
    ) -> None:
        del self._dl_in_progress[fileinfo.name]

        if task.cancelled():
            statusw.original_widget = urwid.Text(("error message", " Cancelled "))
            return
        exc = task.exception()
        if exc is not None:
            statusw.original_widget = urwid.Text(("error banner", " Failed "))
            return

        statusw.original_widget = urwid.Text(("success banner", " Done "))
Ejemplo n.º 2
0
    def __init__(self, name, named_grid_elements: list, callback: Callable):
        self.name = name
        self.named_widgets = {}
        unnamed_grid_elements = []
        for row in named_grid_elements:
            self.named_widgets.update(row)
            unnamed_grid_elements.append(list(row.values()))

        confirm = Button("Confirm", "confirm_button", self.__confirm)
        abort = Button("Abort", "abort_button", self.__quit)
        unnamed_grid_elements.append([confirm, abort])

        super().__init__(unnamed_grid_elements)
        self.keybind["f1"] = self.keybind["ctrl x"] = self.__confirm
        self.keybind["f5"] = self.keybind["ctrl g"] = self.__quit

        self.on_submit = callback

        bottom = Filler(self, valign="top")
        popup = AttrWrap(
            Filler(Text("Work in progress...\n\nPlease wait.", "center")),
            "popup")
        self.overlay = Overlay(popup, bottom, "center", 30, "middle", 5)

        self.root = WidgetPlaceholder(bottom)
    def __init__(self, parent, device, ip_version):
        self.parent = parent
        self.device = device
        self.ip_version = ip_version

        self.method_form = NetworkMethodForm()
        self.method_form.method.caption = _(
            "IPv{v} Method: ").format(v=ip_version)
        manual_initial = {}
        cur_addresses = []
        for addr in device.config.get('addresses', []):
            if addr_version(addr) == ip_version:
                cur_addresses.append(addr)
        if cur_addresses:
            method = 'manual'
            addr = ipaddress.ip_interface(cur_addresses[0])
            ns = device.config.get('nameservers', {})
            manual_initial = {
                'subnet': str(addr.network),
                'address': str(addr.ip),
                'nameservers': ', '.join(ns.get('addresses', [])),
                'searchdomains': ', '.join(ns.get('search', [])),
            }
            gw = device.config.get('gateway{v}'.format(v=ip_version))
            if gw:
                manual_initial['gateway'] = str(gw)
        elif self.device.config.get('dhcp{v}'.format(v=ip_version)):
            method = 'dhcp'
        else:
            method = 'disable'

        self.method_form.method.value = method

        connect_signal(
            self.method_form.method.widget, 'select', self._select_method)

        log.debug("manual_initial %s", manual_initial)
        self.manual_form = NetworkConfigForm(ip_version, manual_initial)

        connect_signal(self.method_form, 'submit', self.done)
        connect_signal(self.manual_form, 'submit', self.done)
        connect_signal(self.method_form, 'cancel', self.cancel)
        connect_signal(self.manual_form, 'cancel', self.cancel)

        self.form_pile = Pile(self.method_form.as_rows())

        self.bp = WidgetPlaceholder(self.method_form.buttons)

        self._select_method(None, method)

        widgets = [self.form_pile, Text(""), self.bp]
        super().__init__(
            "Edit {device} IPv{v} configuration".format(
                device=device.name, v=ip_version),
            widgets,
            0, 0)
Ejemplo n.º 4
0
def mount_node_refactored(node):
    node.ui = WidgetPlaceholder(SolidFill())
    node.opts = render_opts(node)
    logic = extract_logic(node.impl.get('html'))
    attach_logic_to_node(logic, node, node.opts)
    node.document.children('script').remove()
    identify_document(node.document)
    node.expressions = parse_document_expressions(
        node.document.children().eq(0))
    update_node_refactored(node)
    node.trigger('mount')
Ejemplo n.º 5
0
    def __init__(self, parent, dev_info, ip_version):
        self.parent = parent
        self.dev_info = dev_info
        self.ip_version = ip_version

        self.method_form = NetworkMethodForm()
        self.method_form.method.caption = _(
            "IPv{v} Method: ").format(v=ip_version)
        manual_initial = {}
        dhcp_status = getattr(dev_info, 'dhcp' + str(ip_version))
        static_config = getattr(dev_info, 'static' + str(ip_version))
        if static_config.addresses:
            method = 'manual'
            addr = ipaddress.ip_interface(static_config.addresses[0])
            manual_initial = {
                'subnet': str(addr.network),
                'address': str(addr.ip),
                'nameservers': ', '.join(static_config.nameservers),
                'searchdomains': ', '.join(static_config.searchdomains),
            }
            if static_config.gateway:
                manual_initial['gateway'] = static_config.gateway
        elif dhcp_status.enabled:
            method = 'dhcp'
        else:
            method = 'disable'

        self.method_form.method.value = method

        connect_signal(
            self.method_form.method.widget, 'select', self._select_method)

        log.debug("manual_initial %s", manual_initial)
        self.manual_form = NetworkConfigForm(ip_version, manual_initial)

        connect_signal(self.method_form, 'submit', self.done)
        connect_signal(self.manual_form, 'submit', self.done)
        connect_signal(self.method_form, 'cancel', self.cancel)
        connect_signal(self.manual_form, 'cancel', self.cancel)

        self.form_pile = Pile(self.method_form.as_rows())

        self.bp = WidgetPlaceholder(self.method_form.buttons)

        self._select_method(None, method)

        widgets = [self.form_pile, Text(""), self.bp]
        super().__init__(
            "Edit {device} IPv{v} configuration".format(
                device=dev_info.name, v=ip_version),
            widgets,
            0, 0)
Ejemplo n.º 6
0
    def __init__(self, **props):
        """
        Note: All of parent's __init__ is replaced here.
        WidgetPlaceholder.__init__ is called directly.
        """
        try:
            self.store = props['store']
        except KeyError:
            raise Exception('store not found in props')

        self.prop_types = extend({'store': dict}, self.prop_types)
        self.ensure_props_are_valid(props)

        self.own_props = props
        self._cached_props = self.combine_props()
        self._unsubscribe = self.store['subscribe'](self.on_state_change)

        self.component_will_mount(self._cached_props)

        WidgetPlaceholder.__init__(self,
            self.render_component(self._cached_props)
        )
    def __init__(self, parent, device, ip_version):
        self.parent = parent
        self.device = device
        self.ip_version = ip_version

        self.method_form = NetworkMethodForm()
        self.method_form.method.caption = _("IPv{ip_version} Method: ").format(
            ip_version=ip_version)
        manual_initial = {}
        if len(device.configured_ip_addresses_for_version(ip_version)) > 0:
            method = 'manual'
            addr = ipaddress.ip_interface(
                device.configured_ip_addresses_for_version(ip_version)[0])
            manual_initial = {
                'subnet': str(addr.network),
                'address': str(addr.ip),
                'nameservers': ', '.join(device.configured_nameservers),
                'searchdomains': ', '.join(device.configured_searchdomains),
            }
            gw = device.configured_gateway_for_version(ip_version)
            if gw:
                manual_initial['gateway'] = str(gw)
        elif self.device.dhcp_for_version(ip_version):
            method = 'dhcp'
        else:
            method = 'disable'

        self.method_form.method.value = method

        connect_signal(self.method_form.method.widget, 'select',
                       self._select_method)

        log.debug("manual_initial %s", manual_initial)
        self.manual_form = NetworkConfigForm(ip_version, manual_initial)

        connect_signal(self.method_form, 'submit', self.done)
        connect_signal(self.manual_form, 'submit', self.done)
        connect_signal(self.method_form, 'cancel', self.cancel)
        connect_signal(self.manual_form, 'cancel', self.cancel)

        self.form_pile = Pile(self.method_form.as_rows())

        self.bp = WidgetPlaceholder(self.method_form.buttons)

        self._select_method(None, method)

        widgets = [self.form_pile, Text(""), self.bp]
        super().__init__(
            "Edit {device} IPv{ip_version} configuration".format(
                device=device.name, ip_version=ip_version), widgets, 0, 0)
Ejemplo n.º 8
0
    def _file_clicked(self, fileinfo: FileInfo,
                      statusw: urwid.WidgetPlaceholder,
                      w: urwid.Widget) -> None:
        if fileinfo.name in self._dl_in_progress:
            # Already in progress, ignore
            return
        self._dl_in_progress[fileinfo.name] = statusw

        pb = urwid.ProgressBar("pg normal", "pg complete")
        statusw.original_widget = pb
        progress = ProgressBarState(pb)

        coro = self.downloader.download(fileinfo, progress)
        task = self.shell.screen.spawn_task(self, coro)
        task.add_done_callback(
            functools.partial(self._download_done, fileinfo, statusw))
Ejemplo n.º 9
0
    def __init__(self):
        self._body = WidgetPlaceholder(
            Pile([
                Filler(
                    Text(
                        'Coral Dashboard Initialized\n'
                        'Waiting for agent ...',
                        align='center',
                    ), ),
            ]))
        self._wrapper = LineBox(
            self._body,
            title=self.DEFAULT_TITLE.format(version=__version__),
        )

        self.palette = ()
        self.topmost = MessageShower(
            self._wrapper,
            width=self.DEFAULT_MESSAGE_WIDTH,
            height=self.DEFAULT_MESSAGE_HEIGHT,
        )
        self.tree = OrderedDict()
Ejemplo n.º 10
0
 def __init__(self, title):
     WidgetPlaceholder.__init__(self, None)
     self.title = title
Ejemplo n.º 11
0
				game.mazeclass.find_way(start_x=game.col, start_y=game.row)
				for r, c in game.mazeclass.walk:
					game.maze[r, c] = game.mazeclass.objects["way_out"]
			'''

            if game.chalk > 0:
                if key == "ctrl up":
                    mark("up")
                elif key == "ctrl down":
                    mark("down")
                elif key == "ctrl left":
                    mark("left")
                elif key == "ctrl right":
                    mark("right")


button_power.overlay = 0  # проверка на то, что карта или тетрать отображаются

# элементы основного экрана
minimap = create_minimap()
location_text = create_location_text()
description = create_descriprion()
# создали разметку с этими элементами
interface = create_interface()
box = LineBox(interface)
main_widget = WidgetPlaceholder(box)
# запуск
main_loop = MainLoop(main_widget, palette, unhandled_input=button_power)
main_loop.run()