示例#1
0
 def _print_gui_header(self, msg):
     border = lmap(
         lambda x: ANSI.color_grayscale(1 - float(x) / self._max_x) + '-',
         irange(self._max_x))
     self._show_line(str.join('', border) + ANSI.reset)
     self._show_line(msg + self._header.rjust(self._max_x - len(msg)))
     self._show_line(str.join('', border) + ANSI.reset)
示例#2
0
 def redraw(self):  # redraw and go to waiting position
     self._element.redraw()
     self._stream.write(
         ANSI.move(self._element.get_height() or self._console_dim_fn()[0],
                   0))
     sys.stdout.flush()
     sys.stderr.flush()
示例#3
0
	def redraw(self):
		height = self.get_height()
		if (height is not None) and (height != self._layout_height) and self._on_height_change:
			self._on_height_change()
		if self._is_dirty():
			self._stream.write(ANSI.move(self._layout_pos))
			self._draw()
			self._dirty_next = time.time() + self._dirty_interval
示例#4
0
	def _update_buffer(self):
		erase_content(self._buffer)
		self._activity_monitor.write()
		self._buffer.flush()
		msg = ANSI.strip_cmd(self._buffer.getvalue()).strip()
		erase_content(self._buffer)
		self._height_last = 1 + msg.count('\n')
		self._buffer.write(msg)
示例#5
0
	def _pre_processing(self, output_iter):
		cur_time = time.time()
		old_lines = dict(self._old_lines)
		for line_idx, cur_line in enumerate(output_iter):
			(old_line_raw, old_line_age) = old_lines.pop(line_idx, (None, None))
			cur_line_raw = ANSI.strip_fmt(cur_line)
			if old_line_raw and not cur_line_raw:
				yield self._format_old_line(cur_time, line_idx, old_line_raw, old_line_age)
			else:
				yield cur_line
				self._old_lines[line_idx] = (cur_line_raw, cur_time)
		for old_line_idx in sorted(old_lines):
			yield self._format_old_line(cur_time, old_line_idx, *old_lines.pop(old_line_idx))
示例#6
0
 def _write(self, value):
     max_yx = Console.getmaxyx()
     max_x = min(max_yx[1], self._msg_len_max)
     value = value.replace('\n', ANSI.erase_line + '\n' + ANSI.erase_line)
     self._stream.write(value + '\n' + ANSI.wrap_off)
     activity_list = list(Activity.root.get_children())
     max_depth = int(max_yx[0] * self._fold)
     while len(activity_list) > int(max_yx[0] * self._fold):
         activity_list = lfilter(
             lambda activity: activity.depth - 1 < max_depth, activity_list)
         max_depth -= 1
     for activity in activity_list:
         msg = self._format_activity(max_x, activity.depth - 1, activity,
                                     activity_list)
         self._stream.write(ANSI.erase_line + msg + '\n')
     self._stream.write(ANSI.erase_down +
                        ANSI.move_up(len(activity_list) + 1) + ANSI.wrap_on)
     self._stream.flush()
示例#7
0
 def _format_activity(self, width, level, activity, activity_list):
     msg = activity.get_msg(truncate=width - 5 - 2 * level)
     return '  ' * level + ANSI.color_grayscale(1 - level /
                                                5.) + msg + ANSI.reset
示例#8
0
	def show_report(self, job_db, jobnum_list):
		max_x = self._max_x - len(self._header) - 3
		self._show_line('> %s ' % self._header + str.join('', lmap(
			lambda x: ANSI.color_grayscale(1 - float(x) / max_x) + '-',
			irange(max_x))) + ANSI.reset)
示例#9
0
	def _format_old_line(self, cur_time, line_idx, old_line_raw, old_line_age):
		line_brightness = max(0, 0.8 - (cur_time - old_line_age) / 4.)
		if (line_brightness == 0) or (line_idx > self._layout_height):
			self._old_lines.pop(line_idx)
		return ANSI.color_grayscale(line_brightness) + old_line_raw + ANSI.reset + ANSI.erase_line
示例#10
0
	def _trim_width(self, output_iter):
		for line in output_iter:
			line = line.rstrip()[:self._layout_width + len(line) - len(ANSI.strip_fmt(line))]
			yield line.rstrip(ANSI.esc) + ANSI.reset + ANSI.erase_line
示例#11
0
 def show_report(self, job_db, jobnum_list):
     max_x = self._max_x - len(self._header) - 3
     self._show_line('> %s ' % self._header + str.join(
         '',
         lmap(lambda x: ANSI.color_grayscale(1 - float(x) / max_x) + '-',
              irange(max_x))) + ANSI.reset)