Ejemplo n.º 1
0
    def _compose_query_common_layout(self):
        divider_layout = Layout([1])
        self.add_layout(divider_layout)
        divider_layout.add_widget(Divider())
        divider_layout.add_widget(DynamicLabel(name="proto_status"))

        self._compose_created_time_layout()

        common_layout = Layout([5, 13])
        self.add_layout(common_layout)
        common_layout.add_widget(Label("Creator account id"), 0)
        common_layout.add_widget(
            Text(
                name=".payload.meta.creator_account_id", validator=account_id_validator
            ),
            1,
        )
        common_layout.add_widget(Label("Query counter"), 0)
        common_layout.add_widget(
            Text(name=".payload.meta.query_counter", validator=uint32_validator), 1
        )

        common_layout.add_widget(Label("Query type"), 0)
        common_layout.add_widget(
            DropdownList(
                options=self._model.query_type_options,
                on_change=self._on_query_type_change,
                name="query_type",
            ),
            1,
        )

        self._compose_signature_layout()
Ejemplo n.º 2
0
    def __init__(self, screen, footer=dict(), scene_keybinds=None):
        super(GraphFrame, self).__init__(screen,
                                         screen.height,
                                         screen.width,
                                         has_border=False,
                                         name="My Form")

        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        self.__scene_keybinds = scene_keybinds
        self._graph = TextBox(25, name='graph', as_string=True)
        self._graph.disabled = True

        self._graph.custom_colour = 'label'

        self._list = DropdownList(dropdown_options,
                                  label='Pick a graph',
                                  name='dropdown')
        self._graph.value = str(graph_list[self._list.value])

        self._list._on_change = self.on_change

        footers = ['[{}] {}'.format(key, text) for key, text in footer.items()]
        default_footer_text = '[q] Quit'
        self.__footer = Label(' '.join(footers) + ' ' + default_footer_text)

        layout.add_widget(self._list)
        layout.add_widget(self._graph)
        layout.add_widget(self.__footer)

        self.set_theme('monochrome')

        self.fix()
Ejemplo n.º 3
0
 def _create_compilation_modes_menu(self, layout):
     layout.add_widget(Label("Compilation Mode:"), 1)
     layout.add_widget(
         DropdownList(
             [
                 ("Fastbuild (Build as quickly as possible)", "fastbuild"),
                 ("Debug (Build with symbols and no optimization)", "dbg"),
                 ("Optimized (Build with full code optimization)", "opt"),
             ],
             name="compilation_mode",
             on_change=self._on_data_field_change,
         ),
         2,
     )
Ejemplo n.º 4
0
    def __init__(self, screen, model, ui: UIController):
        super().__init__(screen,
                         height=screen.height // 2,
                         width=screen.width // 2,
                         can_scroll=False,
                         title="Add Host",
                         hover_focus=True)

        self._model: ModelInterface = model
        self._ui: UIController = ui
        self._theme = None
        self.set_theme(ui.theme)

        # Initialize Widgets
        self._confirm_button = Button("Confirm", self._confirm)
        self._cancel_button = Button("Cancel", self._cancel)
        self._ip_input = Text("IP Address: ", name="ip")
        self._hostname_input = Text("Hostname (optional):", name="hostname")
        self._beacon_type = DropdownList([("DNS", "DNS"), ("HTTP", "HTTP"),
                                          ("ICMP", "ICMP")],
                                         label="Beacon Type: ",
                                         name="beacon")

        # Create and Generate Layouts
        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._ip_input)
        layout.add_widget(self._hostname_input)
        layout.add_widget(self._beacon_type)
        layout.add_widget(TextBox(Widget.FILL_FRAME, disabled=True))
        layout.add_widget(Divider())
        button_layout = Layout([1, 1])
        self.add_layout(button_layout)
        button_layout.add_widget(self._confirm_button, 0)
        button_layout.add_widget(self._cancel_button, 1)

        # Save Layouts
        self.fix()
Ejemplo n.º 5
0
    def __init__(self, name, screen, inputs, data):
        super(InputFrame, self).__init__(
            screen,
            int(len(inputs) * 2 + 8),
            int(screen.width * 4 // 5),
            has_shadow=True,
            data=data,
            name=name,
        )
        layout = Layout([1, len(inputs), 1])
        self.add_layout(layout)
        layout.add_widget(
            Label("Inputs for the input task '{}'".format(name), height=2), 1
        )
        for singleinput in inputs:
            if (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.TEXT
            ):
                layout.add_widget(
                    Text(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.DATE
            ):
                layout.add_widget(
                    DatePicker(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        year_range=range(1899, 2300),
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.TIME
            ):
                layout.add_widget(
                    TimePicker(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        seconds=True,
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT) in [
                SINGLE_INPUT.TYPE.SELECT,
                SINGLE_INPUT.TYPE.SELECTMULTIPLE,
            ]:
                layout.add_widget(
                    DropdownList(
                        [(option, option) for option in singleinput.get("options")],
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.PASSWORD
            ):
                layout.add_widget(
                    Text(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        hide_char="*",
                        on_change=self._on_change,
                    ),
                    1,
                )

        layout.add_widget(Divider(height=3), 1)
        layout2 = Layout([1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Submit", self._submit), 1)
        self.fix()
Ejemplo n.º 6
0
 def __init__(self, screen):
     super(DemoFrame, self).__init__(screen,
                                     int(screen.height * 2 // 3),
                                     int(screen.width * 2 // 3),
                                     data=form_data,
                                     has_shadow=True,
                                     name="My Form")
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     self._reset_button = Button("Reset", self._reset)
     layout.add_widget(Label("Group 1:"), 1)
     layout.add_widget(
         TextBox(5,
                 label="My First Box:",
                 name="TA",
                 parser=AsciimaticsParser(),
                 line_wrap=True,
                 on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Alpha:",
              name="TB",
              on_change=self._on_change,
              validator="^[a-zA-Z]*$"), 1)
     layout.add_widget(
         Text(label="Number:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$",
              max_length=4), 1)
     layout.add_widget(
         Text(label="Email:",
              name="TD",
              on_change=self._on_change,
              validator=self._check_email), 1)
     layout.add_widget(Text(label="Readonly:", name="RO", readonly=True), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(
         RadioButtons([("Option 1", 1), ("Option 2", 2), ("Option 3", 3)],
                      label="A Longer Selection:",
                      name="Things",
                      on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 1",
                  label="A very silly long name for fields:",
                  name="CA",
                  on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(
         DatePicker("Date",
                    name="DATE",
                    year_range=range(1999, 2100),
                    on_change=self._on_change), 1)
     layout.add_widget(
         TimePicker("Time",
                    name="TIME",
                    on_change=self._on_change,
                    seconds=True), 1)
     layout.add_widget(
         Text("Password",
              name="PWD",
              on_change=self._on_change,
              hide_char="*"), 1)
     layout.add_widget(
         DropdownList([
             ("Item 1", 1),
             ("Item 2", 2),
             ("Item 3", 3),
             ("Item 3", 4),
             ("Item 3", 5),
             ("Item 3", 6),
             ("Item 3", 7),
             ("Item 3", 8),
             ("Item 3", 9),
             ("Item 3", 10),
             ("Item 3", 11),
             ("Item 3", 12),
             ("Item 3", 13),
             ("Item 3", 14),
             ("Item 3", 15),
             ("Item 3", 16),
             ("Item 4", 17),
             ("Item 5", 18),
         ],
                      label="Dropdown",
                      name="DD",
                      on_change=self._on_change), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
Ejemplo n.º 7
0
    def __init__(self, screen, frame_type, frame_data):
        super(EditFrame, self).__init__(screen, frame_type, frame_data)

        self._layout.add_widget(Divider(height=1, draw_line=False), 1)
        self._vm_name_edit = Text(label="VM name:", name="vm_name")
        self._vm_name_edit.disabled = not frame_data.multi_vm
        self._layout.add_widget(self._vm_name_edit, 1)

        self._layout.add_widget(
            DropdownList(VAGRANT_BOX_NAMES, label="Box name:",
                         name="box_name"), 1)

        self._layout.add_widget(Divider(height=1, draw_line=False), 1)
        self._layout.add_widget(
            Text(label="CPU count:",
                 name="cpu_count",
                 max_length=2,
                 validator="^[0-9]*$"), 1)
        self._layout.add_widget(
            Text(label="Memory (GiB):",
                 name="memory",
                 max_length=3,
                 validator="^[0-9]*$"), 1)

        self._enable_vbguest_checkbox = CheckBox("'vbguest' auto-update",
                                                 name="enable_vbguest")
        self._layout.add_widget(self._enable_vbguest_checkbox, 1)
        self._enable_vbguest_checkbox.disabled = not frame_data.vbguest_plugin_is_present

        self._layout.add_widget(
            CheckBox("Add inline shell provision",
                     name="inline_shell_provision"), 1)
        self._layout.add_widget(
            CheckBox("Add shell provision script", name="shell_provisioner"),
            1)
        self._layout.add_widget(
            CheckBox("Add Ansible provision playbook",
                     name="ansible_provisioner"), 1)
        self._layout.add_widget(
            CheckBox("Disable /vagrant shared folder",
                     name="disable_vagrant_share"), 1)
        self._layout.add_widget(
            CheckBox("Add port mapping 8080:80", name="port_mapping"), 1)
        self._disable_autostart_checkbox = CheckBox("Disable autostart",
                                                    name="disable_autostart")
        self._layout.add_widget(self._disable_autostart_checkbox, 1)
        self._disable_autostart_checkbox.disabled = not frame_data.multi_vm

        self._layout.add_widget(Divider(height=1, draw_line=False), 1)
        self._add_extra_drive_checkbox = CheckBox(
            "Add extra virtual HDD",
            name="add_extra_hdd",
            on_change=self._on_add_extra_drive_change)
        self._layout.add_widget(self._add_extra_drive_checkbox, 1)
        self._extra_drive_name_edit = Text(label="File name:",
                                           name="extra_drive_file_name")
        self._layout.add_widget(self._extra_drive_name_edit, 1)
        self._extra_drive_size_edit = Text(label="Size (GiB):",
                                           name="extra_drive_size",
                                           validator="^[0-9]*$")
        self._layout.add_widget(self._extra_drive_size_edit, 1)

        self._layout.add_widget(Divider(height=1, draw_line=False), 1)
        self._ip_address_edit = Text(label="IP address:", name="ip_address")
        self._layout.add_widget(self._ip_address_edit, 1)
        self._ip_address_edit.disabled = not frame_data.intnet_is_present

        self.data = frame_data.controls_data
        self.fix()
Ejemplo n.º 8
0
    def __init__(self, screen, parsed_args):
        super(RestView, self).__init__(screen,
                                       screen.height,
                                       screen.width,
                                       on_load=self._populate,
                                       hover_focus=True,
                                       can_scroll=False,
                                       title="Respyte")

        self.set_theme(parsed_args.color_scheme)
        url_layout = Layout([10, 1, 100])
        self.add_layout(url_layout)
        self.method = DropdownList([("GET", "GET"), ("POST", "POST"),
                                    ("PUT", "PUT"), ("PATCH", "PATCH"),
                                    ("DELETE", "DELETE")],
                                   name="method")
        url_layout.add_widget(self.method, 0)
        url_layout.add_widget(VerticalDivider(), 1)
        self.url = Text(label="Url: ", validator=validate, name="url")
        url_layout.add_widget(self.url, 2)

        url_layout.add_widget(Divider())
        url_layout.add_widget(Divider(), 1)
        url_layout.add_widget(Divider(), 2)
        req_layout = Layout([20, 1, 50], fill_frame=True)
        self.add_layout(req_layout)
        self.request = TextBox(screen.height // 4 * 3 - 7,
                               label="Body Params",
                               name="req_params",
                               line_wrap=True,
                               as_string=True)
        self.req_headers = TextBox(screen.height // 4,
                                   label="Headers",
                                   name="req_headers",
                                   line_wrap=True,
                                   as_string=True)
        req_layout.add_widget(self.req_headers, 0)
        req_layout.add_widget(Divider(), 0)
        req_layout.add_widget(self.request, 0)

        req_layout.add_widget(VerticalDivider(), 1)
        self.resp_headers = TextBox(
            screen.height // 4,
            label="Response Headers",
            name="resp_headers",
            line_wrap=True,
            as_string=True,
            readonly=True,
            tab_stop=False,
        )
        req_layout.add_widget(self.resp_headers, 2)
        req_layout.add_widget(Divider(), 2)
        self.response = Pager(
            screen.height // 4 * 3 - 7,
            label="Response body",
            name="response",
            line_wrap=True,
            as_string=True,
        )
        req_layout.add_widget(self.response, 2)

        button_layout = Layout([1, 2, 2, 1, 1])
        self.add_layout(button_layout)
        button_layout.add_widget(Divider())
        button_layout.add_widget(Divider(), 1)
        button_layout.add_widget(Divider(), 2)
        button_layout.add_widget(Divider(), 3)
        button_layout.add_widget(Divider(), 4)
        button_layout.add_widget(
            Button("[Send it <F3>]", self._send, add_box=False), 1)
        button_layout.add_widget(
            Button("[History <F2>]", self._history, add_box=False), 2)
        button_layout.add_widget(
            Button("[Quit <ESC>]", self._quit, add_box=False), 3)
        self._populate()
        self.fix()
Ejemplo n.º 9
0
    def __init__(self, screen, model: ModelController,
                 logger: LoggingController, ui: UIController):
        super().__init__(screen,
                         height=screen.height // 2,
                         width=screen.width // 2,
                         can_scroll=False,
                         title="Settings",
                         hover_focus=True)

        # Controllers that access different aspects of provenance
        self._logger: LoggingController = logger
        self._model: ModelController = model
        self._ui: UIController = ui
        self._theme = None
        self.set_theme(ui.theme)

        # Initialize Widgets
        self._confirm_button = Button("Confirm", self._confirm)
        self._cancel_button = Button("Cancel", self._cancel)
        self._discovery = CheckBox(
            "All hosts that connect are regarded as clients",
            label="Discovery: ",
            name="discovery")
        self._display_logs = CheckBox("Display logs on the main menu",
                                      label="Display Logs: ",
                                      name="logs")
        self._log_level_widget = DropdownList([("Debug", logging.DEBUG),
                                               ("Info", logging.INFO),
                                               ("Warning", logging.WARNING),
                                               ("Error", logging.ERROR),
                                               ("Critical", logging.CRITICAL)],
                                              label="Logging Level: ",
                                              name="loglevel")
        self._theme_widget = DropdownList([(t, t)
                                           for t in asciimatics_themes.keys()],
                                          label="Theme: ",
                                          name="theme")
        self._refreshrate = Text(label="Refresh Rate (s):", name="refresh")
        # Set default values
        self._refreshrate.value = str(2)
        self._log_level_widget.value = self._logger.log_level
        self._discovery.value = True
        self._display_logs.value = True
        self._theme_widget.value = ui.theme

        # Create and Generate Layouts
        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._discovery)
        layout.add_widget(self._display_logs)
        layout.add_widget(self._refreshrate)
        layout.add_widget(self._log_level_widget)
        layout.add_widget(self._theme_widget)

        button_layout = Layout([1, 1])
        self.add_layout(button_layout)
        button_layout.add_widget(self._confirm_button, 0)
        button_layout.add_widget(self._cancel_button, 1)

        # Save Layouts
        self.fix()
Ejemplo n.º 10
0
    def __init__(self, screen, model: ModelController, ui: UIController):
        super(FilterMenu, self).__init__(screen,
                                         height=screen.height * 3 // 4,
                                         width=screen.width * 1 // 4 + 1,
                                         hover_focus=True,
                                         can_scroll=False,
                                         on_load=None,
                                         title="Filter",
                                         x=screen.width * 3 // 4,
                                         y=0)
        self._model: ModelController = model
        self._ui: UIController = ui

        # Initialize Widgets
        self._clear_button = Button("Clear",
                                    on_click=self._clear_filters,
                                    add_box=True)
        self._apply_button = Button("Apply",
                                    on_click=self._apply,
                                    add_box=True)
        self._beacon_header = Text(disabled=True)
        self._beacon_header.value = "Beacon Type: "
        self._beacon_type = DropdownList([("All", None), ("DNS", "DNS"),
                                          ("HTTP", "HTTP"), ("ICMP", "ICMP")],
                                         name="beacon")

        self._active_header = Text(disabled=True)
        self._active_header.value = "Last Active (in minutes): "
        self._active_field = Text(name="active")

        self._ip_header = Text(disabled=True)
        self._ip_header.value = "IPs and/or subnet(s): "
        self._ip_input = Text(name="ips")

        self._hostname_header = Text(disabled=True)
        self._hostname_header.value = "Hostname: "
        self._hostname_input = Text(name="hostname")

        self._os_header = Text(disabled=True)
        self._os_header.value = "OS: "
        self._os_input = DropdownList([("All", None), ("Linux", "linux"),
                                       ("Windows", "windows")],
                                      name="os")

        self._filler = TextBox(Widget.FILL_FRAME, disabled=True)
        # Default values
        self._active_field.value = None
        self._ip_input.value = None

        # Add Widgets to Frame
        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._beacon_header)
        layout.add_widget(self._beacon_type)
        layout.add_widget(self._os_header)
        layout.add_widget(self._os_input)
        layout.add_widget(self._active_header)
        layout.add_widget(self._active_field)
        layout.add_widget(self._ip_header)
        layout.add_widget(self._ip_input)
        layout.add_widget(self._hostname_header)
        layout.add_widget(self._hostname_input)

        layout.add_widget(self._filler)
        layout.add_widget(Divider())

        buttons = Layout([1, 1])
        self.add_layout(buttons)
        buttons.add_widget(self._apply_button, 0)
        buttons.add_widget(self._clear_button, 1)

        # Fix all widgets to Frame
        self.fix()
Ejemplo n.º 11
0
    def __init__(self, screen, model):
        super().__init__(screen,
                         screen.height,
                         screen.width,
                         title="Radio Settings",
                         can_scroll=True,
                         reduce_cpu=True)
        self._stngs_model = model

        # Layout the settings widgets
        layout1 = Layout([1, 2, 1], fill_frame=True)
        self.add_layout(layout1)
        layout1.add_widget(
            DropdownList([("LoRa", 1)],
                         label="Radio Mode:",
                         name="radio_mode",
                         disabled=True), 1)
        layout1.add_widget(
            Text(label="RF Freq [KHz]:",
                 name="rf_freq",
                 on_change=self._on_change,
                 validator=self._is_valid_freq), 1)
        layout1.add_widget(
            DropdownList([
                ("4:5", SX127xSettings.STNG_LORA_CR_4TO5),
                ("4:6", SX127xSettings.STNG_LORA_CR_4TO6),
                ("4:7", SX127xSettings.STNG_LORA_CR_4TO7),
                ("4:8", SX127xSettings.STNG_LORA_CR_4TO8),
            ],
                         label="Code Rate:",
                         name="code_rate"), 1)
        layout1.add_widget(
            DropdownList([
                (" 7.8  KHz", SX127xSettings.STNG_LORA_BW_7K8),
                ("10.4  KHz", SX127xSettings.STNG_LORA_BW_10K4),
                ("15.6  KHz", SX127xSettings.STNG_LORA_BW_15K6),
                ("20.8  KHz", SX127xSettings.STNG_LORA_BW_20K8),
                ("31.25 KHz", SX127xSettings.STNG_LORA_BW_31K25),
                ("41.7  KHz", SX127xSettings.STNG_LORA_BW_41K7),
                ("62.5  KHz", SX127xSettings.STNG_LORA_BW_62K5),
                ("125   KHz", SX127xSettings.STNG_LORA_BW_125K),
                ("250   KHz", SX127xSettings.STNG_LORA_BW_250K),
                ("500   KHz", SX127xSettings.STNG_LORA_BW_500K),
            ],
                         label="Bandwidth:",
                         name="bandwidth"), 1)
        layout1.add_widget(
            DropdownList([
                ("  64 cps", SX127xSettings.STNG_LORA_SF_64_CPS),
                (" 128 cps", SX127xSettings.STNG_LORA_SF_128_CPS),
                (" 256 cps", SX127xSettings.STNG_LORA_SF_256_CPS),
                (" 512 cps", SX127xSettings.STNG_LORA_SF_512_CPS),
                ("1024 cps", SX127xSettings.STNG_LORA_SF_1024_CPS),
                ("2048 cps", SX127xSettings.STNG_LORA_SF_2048_CPS),
                ("4096 cps", SX127xSettings.STNG_LORA_SF_4096_CPS),
            ],
                         label="Spread Factor:",
                         name="spread_factor"), 1)

        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Apply", on_click=self._on_click_apply), 1)
        layout2.add_widget(Button("Cancel", self._on_click_cancel), 2)

        self.fix()