Add logs/edit
This commit is contained in:
parent
7bafd5376c
commit
6be42383f2
65
kls
65
kls
|
@ -3,6 +3,11 @@ import curses
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
stdscr = curses.initscr()
|
stdscr = curses.initscr()
|
||||||
|
stdscr.refresh()
|
||||||
|
curses.noecho()
|
||||||
|
curses.cbreak()
|
||||||
|
stdscr.keypad(True)
|
||||||
|
curses.curs_set(0)
|
||||||
|
|
||||||
|
|
||||||
class Menu:
|
class Menu:
|
||||||
|
@ -46,13 +51,53 @@ def main(stdscr):
|
||||||
current_menu = 0
|
current_menu = 0
|
||||||
menus[current_menu].win.addstr(1, 2, menus[current_menu].name, curses.A_REVERSE | curses.A_ITALIC)
|
menus[current_menu].win.addstr(1, 2, menus[current_menu].name, curses.A_REVERSE | curses.A_ITALIC)
|
||||||
for menu in menus:
|
for menu in menus:
|
||||||
menu.win.addstr(3, 2, menu.rows[0], curses.A_REVERSE | curses.A_ITALIC)
|
menu.win.addstr(3, 2, menu.rows[menu.row], curses.A_REVERSE | curses.A_ITALIC)
|
||||||
while running:
|
while running:
|
||||||
[menu.win.refresh() for menu in menus] # refresh all menus
|
[menu.win.refresh() for menu in menus] # refresh all menus
|
||||||
the_user_presses_the_key_et_voila = stdscr.getkey()
|
key_pressed = stdscr.getkey()
|
||||||
match the_user_presses_the_key_et_voila:
|
match key_pressed:
|
||||||
case 'q':
|
case 'q':
|
||||||
running = False
|
running = False
|
||||||
|
case 'l':
|
||||||
|
if current_menu == 2 and not menus[2].rows[menus[2].row].startswith("No resources") and menus[1].rows[menus[1].row] == "pods":
|
||||||
|
namespace = menus[0].rows[menus[0].row]
|
||||||
|
api_resource = menus[1].rows[menus[1].row]
|
||||||
|
resource = menus[2].rows[menus[2].row]
|
||||||
|
process = subprocess.call(f"kubectl -n {namespace} logs {resource} | less", shell=True)
|
||||||
|
stdscr = curses.initscr()
|
||||||
|
stdscr.refresh()
|
||||||
|
curses.noecho()
|
||||||
|
curses.cbreak()
|
||||||
|
stdscr.keypad(True)
|
||||||
|
curses.curs_set(0)
|
||||||
|
for menu in menus:
|
||||||
|
menu.win.clear()
|
||||||
|
menu.win.box()
|
||||||
|
menu.win.addstr(1, 2, menu.name)
|
||||||
|
for index, row in enumerate(menu.rows):
|
||||||
|
menu.win.addstr(index + 3, 2, row)
|
||||||
|
menu.win.addstr(3, 2, menu.rows[menu.row], curses.A_REVERSE | curses.A_ITALIC)
|
||||||
|
menus[current_menu].win.addstr(1, 2, menus[current_menu].name, curses.A_REVERSE | curses.A_ITALIC)
|
||||||
|
case 'e':
|
||||||
|
if current_menu == 2 and not menus[2].rows[menus[2].row].startswith("No resources"):
|
||||||
|
namespace = menus[0].rows[menus[0].row]
|
||||||
|
api_resource = menus[1].rows[menus[1].row]
|
||||||
|
resource = menus[2].rows[menus[2].row]
|
||||||
|
process = subprocess.call(f"kubectl edit {api_resource} -n {namespace} {resource}", shell=True)
|
||||||
|
stdscr = curses.initscr()
|
||||||
|
stdscr.refresh()
|
||||||
|
curses.noecho()
|
||||||
|
curses.cbreak()
|
||||||
|
stdscr.keypad(True)
|
||||||
|
curses.curs_set(0)
|
||||||
|
for menu in menus:
|
||||||
|
menu.win.clear()
|
||||||
|
menu.win.box()
|
||||||
|
menu.win.addstr(1, 2, menu.name)
|
||||||
|
for index, row in enumerate(menu.rows):
|
||||||
|
menu.win.addstr(index + 3, 2, row)
|
||||||
|
menu.win.addstr(3, 2, menu.rows[menu.row], curses.A_REVERSE | curses.A_ITALIC)
|
||||||
|
menus[current_menu].win.addstr(1, 2, menus[current_menu].name, curses.A_REVERSE | curses.A_ITALIC)
|
||||||
case '\t' | "KEY_RIGHT":
|
case '\t' | "KEY_RIGHT":
|
||||||
menus[current_menu].win.addstr(1, 2, menus[current_menu].name)
|
menus[current_menu].win.addstr(1, 2, menus[current_menu].name)
|
||||||
current_menu = (current_menu + 1) % 3
|
current_menu = (current_menu + 1) % 3
|
||||||
|
@ -112,9 +157,13 @@ def main(stdscr):
|
||||||
else:
|
else:
|
||||||
menus[2].win.addstr(index + 3, 2, row)
|
menus[2].win.addstr(index + 3, 2, row)
|
||||||
|
|
||||||
curses.wrapper(main)
|
main(stdscr)
|
||||||
|
|
||||||
|
curses.nocbreak()
|
||||||
|
stdscr.keypad(False)
|
||||||
|
curses.echo()
|
||||||
|
curses.endwin()
|
||||||
|
subprocess.call(["clear"])
|
||||||
|
|
||||||
|
#curses.wrapper(main)
|
||||||
|
|
||||||
#curses.nocbreak()
|
|
||||||
#stdscr.keypad(False)
|
|
||||||
#curses.echo()
|
|
||||||
#curses.endwin()
|
|
||||||
|
|
Loading…
Reference in New Issue