def show_dialog(self, dialog): if not self.dialog: self.dialog = dialog self.original_widget = urwid.Overlay( urwid.LineBox(dialog), self.original_widget, align=getattr(dialog, 'align', 'center'), width=getattr(dialog, 'width', ('relative', 99)), valign=getattr(dialog, 'valign', 'middle'), height=getattr(dialog, 'height', 'pack'), ) app.draw_screen()
def popup_failure(e, self): self.close_dialog() e.trap(docker.errors.APIError) e = e.value self.show_dialog( MessageBox( e.explanation, title="HTTP Error: " + str(e.response.status_code), ) ) app.draw_screen()
def set_containers(self, containers, force=False): # save the current position _, current_focus = self.listing.get_focus() if containers == self.container_data and not force: return self.listing.clear() self.old_containers = self.containers self.containers = {} running = [c for c in containers if 'Exited' not in c['status']] stopped = [c for c in containers if 'Exited' in c['status']] filter = self.filter.lower() def remove_highlight(row): highlighter.remove(row) for container in running: in_names = any(filter in name.lower() for name in container['names']) in_id = filter in container['id'].lower() in_status = filter in container['status'].lower() in_image = filter in container['image'].lower() row = self.make_container_row(container) if any((in_names, in_id, in_status, in_image)): self.listing.walker.append(row) if self.old_containers and row.container not in self.old_containers: highlighter.apply(row, 'created', 'created') reactor.callLater(1, highlighter.remove, row) for container in stopped: in_names = any(filter in name.lower() for name in container['names']) in_id = filter in container['id'].lower() in_status = filter in container['status'].lower() in_image = filter in container['image'].lower() row = self.make_container_row(container) if any((in_names, in_id, in_status, in_image)): self.listing.walker.append(row) if self.old_containers and row.container not in self.old_containers: highlighter.apply(row, 'created', 'created') reactor.callLater(1, highlighter.remove, row) self.container_data = containers self.listing.set_focus(current_focus) self.listing.fix_focus() app.draw_screen()
def set_images(self, images, force=False): # save the current position _, current_focus = self.listing.get_focus() if images == self.image_data and not force: return self.listing.clear() self.old_images = self.images self.images = {} untagged = [i for i in images if i['tag'] == '<none>:<none>'] tagged = [i for i in images if i['tag'] != '<none>:<none>'] filter = self.filter.lower() def remove_highlight(row): highlighter.remove(row) for image in tagged: in_tag = filter in image['tag'].lower() in_id = filter in image['id'].lower() row = self.make_image_row(image) if in_tag or in_id: self.listing.walker.append(row) if self.old_images and row.tag not in self.old_images: highlighter.apply(row, 'created', 'created') reactor.callLater(1, highlighter.remove, row) for image in untagged: in_tag = filter in image['tag'].lower() in_id = filter in image['id'].lower() row = self.make_image_row(image) if in_tag or in_id: self.listing.walker.append(row) if self.old_images and row.tag not in self.old_images: highlighter.apply(row, 'created', 'created') reactor.callLater(1, highlighter.remove, row) self.image_data = images self.listing.set_focus(current_focus) self.listing.fix_focus() app.draw_screen()
def set_images(self, images, force=False): # save the current position _, current_focus = self.listing.get_focus() if images == self.image_data and not force: return self.listing.clear() self.old_images = self.images self.images = {} untagged = [i for i in images if i["tag"] == "<none>:<none>"] tagged = [i for i in images if i["tag"] != "<none>:<none>"] filter = self.filter.lower() def remove_highlight(row): highlighter.remove(row) for image in tagged: in_tag = filter in image["tag"].lower() in_id = filter in image["id"].lower() row = self.make_image_row(image) if in_tag or in_id: self.listing.walker.append(row) if self.old_images and row.tag not in self.old_images: highlighter.apply(row, "created", "created") reactor.callLater(1, highlighter.remove, row) for image in untagged: in_tag = filter in image["tag"].lower() in_id = filter in image["id"].lower() row = self.make_image_row(image) if in_tag or in_id: self.listing.walker.append(row) if self.old_images and row.tag not in self.old_images: highlighter.apply(row, "created", "created") reactor.callLater(1, highlighter.remove, row) self.image_data = images self.listing.set_focus(current_focus) self.listing.fix_focus() app.draw_screen()
def close_dialog(self): if self.dialog: self.original_widget = self.widget self.dialog = None app.draw_screen()
def on_history(self): widget, idx = self.listing.get_focus() d = threads.deferToThread(app.client.history, widget.image) d.addCallback(self._show_history, widget.image) d.addCallback(lambda r: app.draw_screen()) return d
def on_top(self): widget, idx = self.listing.get_focus() d = threads.deferToThread(app.client.top, widget.container) d.addCallback(self._show_top, widget.container) d.addCallback(lambda r: app.draw_screen()) return d