0

I am using python pretty table to print the status of each record on CLI. How to display the status updates on the CLI in the same table.

Example:

+--------------+---------+
| Jobs         |  Status |
+--------------+---------+
|  job1        |  FAILED |
|  job2        | SUCCESS |
+--------------+---------+

The jobs status will be updated by a thread. I want to display the updated status in the same table in CLI console.

Gova
  • 235
  • 2
  • 3
  • 12
  • Can you add some code? What have you tried? Maybe add an example of the output you want, so we can understand what you want better – DorElias Sep 20 '15 at 09:18
  • 1
    You'll need to use some sort of terminal control library like [`curses`](https://docs.python.org/3/howto/curses.html), or a higher-level console UI framework like [`urwid`](http://urwid.org/). – Lukas Graf Sep 20 '15 at 10:06
  • I need to display this table just like the way the display for progress bar – Gova Sep 21 '15 at 11:55

1 Answers1

0

I found ascii code to move the cursor to the previous line. And I am using the below logic to achieve the purpose

number_of_records = len(records)  # number of jobs in a tables
total_lines = number_of_records + 3 + 1 # number of records + Borders + Header

if prev_lines != 0:
   for i in range(prev_lines):
      sys.stdout.write('\033[F')

prev_lines = total_lines

print status_table

Thanks :)

Gova
  • 235
  • 2
  • 3
  • 12