How to use the sen.tui.widgets.util.get_map function in sen

To help you get started, we’ve selected a few sen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TomasTomecek / sen / sen / tui / chunks / container.py View on Github external
def get_detailed_container_row(docker_container):
    row = []
    container_id = SelectableText(docker_container.short_id)
    row.append(container_id)

    commands = docker_container.command.split("\n")
    command_str = commands[0]
    if len(commands) > 0:
        command_str += "..."
    command = SelectableText(command_str, get_map(defult="main_list_ddg"))
    row.append(command)

    image = SelectableText(docker_container.image_name())
    row.append(image)

    row.append(ContainerStatusWidget(docker_container))

    name = SelectableText(docker_container.short_name)
    row.append(name)

    return row
github TomasTomecek / sen / sen / tui / views / image_info.py View on Github external
def _labels(self):
        if not self.docker_image.labels:
            return []
        data = []
        self.walker.append(RowWidget([SelectableText("")]))
        self.walker.append(RowWidget([SelectableText("Labels", maps=get_map("main_list_white"))]))
        for label_key, label_value in self.docker_image.labels.items():
            data.append([SelectableText(label_key, maps=get_map("main_list_green")), SelectableText(label_value)])
        self.walker.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / chunks / container.py View on Github external
def get_container_status_markup(docker_container, nice_status=True):
    if docker_container.running:
        attr_map = get_map("main_list_green")
    elif docker_container.status_created:
        attr_map = get_map("main_list_yellow")
    elif docker_container.exited_well:
        attr_map = get_map("main_list_orange")
    else:
        attr_map = get_map("main_list_red")
    if nice_status:
        return docker_container.nice_status, attr_map
    else:
        return docker_container.simple_status_cap, attr_map
github TomasTomecek / sen / sen / tui / views / image_info.py View on Github external
def _layers(self):
        self.walker.append(RowWidget([SelectableText("")]))
        self.walker.append(RowWidget([SelectableText("Layers", maps=get_map("main_list_white"))]))

        i = self.docker_image
        parent = i.parent_image
        layers = self.docker_image.layers
        index = 0

        if isinstance(parent, RootImage) and len(layers) > 0:  # pulled image, docker 1.10+
            for image in layers:
                self.walker.append(
                    RowWidget([LayerWidget(self.ui, image, index=index)])
                )
                index += 1
        else:
            self.walker.append(RowWidget([LayerWidget(self.ui, self.docker_image, index=index)]))
            while True:
                index += 1
github TomasTomecek / sen / sen / tui / chunks / container.py View on Github external
def get_container_status_markup(docker_container, nice_status=True):
    if docker_container.running:
        attr_map = get_map("main_list_green")
    elif docker_container.status_created:
        attr_map = get_map("main_list_yellow")
    elif docker_container.exited_well:
        attr_map = get_map("main_list_orange")
    else:
        attr_map = get_map("main_list_red")
    if nice_status:
        return docker_container.nice_status, attr_map
    else:
        return docker_container.simple_status_cap, attr_map
github TomasTomecek / sen / sen / tui / views / container_info.py View on Github external
def _process_tree(self):
        top = self.docker_container.top().response
        logger.debug(top)
        if top:
            self.view_widgets.append(RowWidget([SelectableText("")]))
            self.view_widgets.append(RowWidget([SelectableText("Process Tree",
                                                         maps=get_map("main_list_white"))]))
            self.view_widgets.append(BoxAdapter(ProcessTree(top), len(top)))
github TomasTomecek / sen / sen / tui / views / image_info.py View on Github external
SelectableText(self.docker_image.image_id)],
            [SelectableText("Created", maps=get_map("main_list_green")),
             SelectableText("{0}, {1}".format(self.docker_image.display_formal_time_created(),
                                              self.docker_image.display_time_created()))],
            [SelectableText("Size", maps=get_map("main_list_green")),
             SelectableText(humanize_bytes(self.docker_image.total_size))],
        ]
        if self.docker_image.unique_size:
            data.append(
                [SelectableText("Unique Size", maps=get_map("main_list_green")),
                 SelectableText(humanize_bytes(self.docker_image.unique_size))])
        if self.docker_image.shared_size:
            data.append(
                [SelectableText("Shared Size", maps=get_map("main_list_green")),
                 SelectableText(humanize_bytes(self.docker_image.shared_size))])
        data.append([SelectableText("Command", maps=get_map("main_list_green")),
                     SelectableText(self.docker_image.container_command)])
        self.walker.extend(assemble_rows(data, ignore_columns=[1]))
github TomasTomecek / sen / sen / tui / widgets / list / util.py View on Github external
def get_time_attr_map(t):
    """
                                                       now -> |
                            hour ago -> |
        day ago -> |
    |--------------|--------------------|---------------------|
    """
    now = datetime.datetime.now()
    if t + datetime.timedelta(hours=3) > now:
        return get_map("main_list_white")
    if t + datetime.timedelta(days=3) > now:
        return get_map("main_list_lg")
    else:
        return get_map("main_list_dg")
github TomasTomecek / sen / sen / tui / chunks / container.py View on Github external
def get_container_status_markup(docker_container, nice_status=True):
    if docker_container.running:
        attr_map = get_map("main_list_green")
    elif docker_container.status_created:
        attr_map = get_map("main_list_yellow")
    elif docker_container.exited_well:
        attr_map = get_map("main_list_orange")
    else:
        attr_map = get_map("main_list_red")
    if nice_status:
        return docker_container.nice_status, attr_map
    else:
        return docker_container.simple_status_cap, attr_map