def __init__(self, old_stdout): import curses import curses.panel from curses.wrapper import wrapper self.old_stdout = old_stdout self.curses = curses self.helper_modules = CFG_BIBTASK_VALID_TASKS self.running = 1 self.footer_auto_mode = "Automatic Mode [A Manual] [1/2/3 Display] [H Help] [l/L Log] [O Opts] [E Edit motd] [Q Quit]" self.footer_manual_mode = "Manual Mode%s [A Automatic] [1/2/3 Display Type] [H help] [l/L Log] [O Opts] [E Edit motd] [Q Quit]" self.footer_waiting_item = "[R Run] [D Delete] [N Priority]" self.footer_running_item = "[S Sleep] [T Stop] [K Kill]" self.footer_stopped_item = "[I Initialise] [D Delete] [K Acknowledge]" self.footer_sleeping_item = "[W Wake Up] [T Stop] [K Kill]" self.item_status = "" self.rows = [] self.panel = None self.display = 2 self.first_visible_line = 0 self.auto_mode = 0 self.currentrow = None self.current_attr = 0 self.hostname = gethostname() self.allowed_task_types = CFG_BIBSCHED_NODE_TASKS.get( self.hostname, CFG_BIBTASK_VALID_TASKS) self.motd = "" self.header_lines = 2 self.read_motd() self.selected_line = self.header_lines wrapper(self.start)
def __init__(self, old_stdout): import curses import curses.panel from curses.wrapper import wrapper self.old_stdout = old_stdout self.curses = curses self.helper_modules = CFG_BIBTASK_VALID_TASKS self.running = 1 self.footer_auto_mode = "Automatic Mode [A Manual] [1/2/3 Display] [H Help] [l/L Log] [O Opts] [E Edit motd] [Q Quit]" self.footer_manual_mode = "Manual Mode%s [A Automatic] [1/2/3 Display Type] [H help] [l/L Log] [O Opts] [E Edit motd] [Q Quit]" self.footer_waiting_item = "[R Run] [D Delete] [N Priority]" self.footer_running_item = "[S Sleep] [T Stop] [K Kill]" self.footer_stopped_item = "[I Initialise] [D Delete] [K Acknowledge]" self.footer_sleeping_item = "[W Wake Up] [T Stop] [K Kill]" self.item_status = "" self.rows = [] self.panel = None self.display = 2 self.first_visible_line = 0 self.auto_mode = 0 self.currentrow = None self.current_attr = 0 self.hostname = gethostname() self.allowed_task_types = CFG_BIBSCHED_NODE_TASKS.get(self.hostname, CFG_BIBTASK_VALID_TASKS) self.motd = "" self.header_lines = 2 self.read_motd() self.selected_line = self.header_lines wrapper(self.start)
def run(self): while self.appmode != 'QUIT': if self.appmode == 'TUI': wrapper(self.run_tui) elif self.appmode == 'PYSHELL': self.run_pyshell() elif self.appmode == 'SHELL': self.run_shell()
def start_cli(self, file, url): """""" if cons.OS_WINDOWS: self.exit("No curses support.") else: from ui.console.no_ui import exception_hook from curses.wrapper import wrapper from ui.console.cli import Cli #exception hook sys.excepthook = exception_hook c = Cli(file, url) wrapper(c.run)
""" # Return empty quick when we are empty if len( statusDict ) == 0 : return "" # Build up the retStr to have all of our data retStr = "" for i in statusDict : # After the first retStr loop, add a comma before adding data! if len( retStr ) : retStr += ", " # Add name of status retStr += i # Add Brackets and lengh of status retStr += " [" retStr += str( statusDict[i] ) retStr += "]" # Return Results return retStr wrapper(Main) print curses.COLORS print "Fin"
if self._game.is_alive((x, y)): self._game.set_dead((x, y)) else: self._game.set_living((x, y)) elif action == 'tick': self._game.tick() elif action == 'toggle_play': self._playing = not self._playing elif action == 'increase_speed': self._speed -= 1 if self._speed < 1: self._speed = 1 curses.halfdelay(self._speed) elif action == 'decrease_speed': self._speed += 1 if self._speed > 255: self._speed = 255 curses.halfdelay(self._speed) except KeyError: if c == -1 and self._playing: self._game.tick() self._render() def main(stdscr): CursesScreen(stdscr).loop() if __name__ == '__main__': wrapper(main)
ed.move_cursor(row=ed.cursor.y-1,col=ed.cursor.x) update(stdscr,ed) elif event == curses.KEY_DOWN: ed.move_cursor(row=ed.cursor.y+1,col=ed.cursor.x) update(stdscr,ed) elif event == curses.KEY_LEFT: ed.move_cursor(row=ed.cursor.y,col=ed.cursor.x-1) update(stdscr,ed) elif event == curses.KEY_RIGHT: ed.move_cursor(row=ed.cursor.y,col=ed.cursor.x+1) update(stdscr,ed) elif event == 5: ed.move_window(ed.win.top+1) update(stdscr,ed) elif event == 25: ed.move_window(ed.win.top-1) update(stdscr,ed) stdscr.addstr(y-1,min(20,x-15),str(event)+" ") stdscr.chgat(ed.cursor.y-ed.win.top,ed.cursor.x,1,curses.A_STANDOUT) stdscr.refresh() event = stdscr.getch() wrapper(main)
elif key in (curses.KEY_RIGHT, ord('l'), ord('f')): items.set_volume(hl, items.get_volume(hl) + optz.adjust_step) elif key in (ord(' '), ord('m')): items.set_mute(hl, not items.get_mute(hl)) elif key < 255 and key > 0 and chr(key) == 'q': exit() elif key in (curses.KEY_RESIZE, ord('\f')): curses.endwin() stdscr.refresh() win = curses.newwin(*(win_size() + (border, border))) win.keypad(True) except PAUpdate: continue def reexec(): log.debug('Restarting the app due to some critical failure') try: os.kill(child_pid, signal.SIGKILL) # to prevent it sending USR1 to new process except OSError: pass try: os.execv(__file__, sys.argv) except OSError: os.execvp('python', ['python', __file__] + sys.argv[1:]) wrapper(interactive_cli, items=PAMenu(fail_hook=reexec), border=1) log.debug('Finished')
def setup(self): from curses.wrapper import wrapper def curses_started(screen): self.screen = screen self.callback(self) wrapper(curses_started)
self.stdscr.refresh() # Function to write a message at the bottom of the screen def message(self, msg): self.clear_message() posy, posx = self.stdscr.getyx() msg_break = self.wrapper.wrap(msg) for i, m in enumerate(msg_break): self.stdscr.addnstr(self.winy-1-len(msg_break)+i, 2, m, len(m)) self.stdscr.move(posy, posx) self.stdscr.refresh() # Function to clear the message at the bottom of the screen def clear_message(self): posy, posx = self.stdscr.getyx() for i in range(self.msg_top_line, self.winy-1): self.stdscr.addnstr(i, 1, ' '*(self.winx-2), self.winx-2) self.stdscr.move(posy, posx) self.stdscr.refresh() # Main function to drive the menus def runwindow(stdscr): menu = Menu(stdscr) # Run the function wrapper(runwindow)
try: key = win.getch() except curses.error: continue log.debug('Keypress event: {}'.format(key)) try: if key in (curses.KEY_DOWN, curses.KEY_UP): hl = (items.next_key if key == curses.KEY_DOWN else items.prev_key)(hl) elif key in (curses.KEY_LEFT, curses.KEY_RIGHT): adj = (1 if key == curses.KEY_RIGHT else -1) * optz.adjust_step items.set(hl, items.get(hl) + adj) elif key < 255 and key > 0 and chr(key) == 'q': exit() elif key == curses.KEY_RESIZE: win.resize(*win_size()) stdscr.erase() stdscr.refresh() except PAUpdate: continue def reexec(): log.debug('Restarting the app due to some critical failure') try: os.kill(child_pid, signal.SIGKILL) # to prevent it sending USR1 to new process except OSError: pass try: os.execv(__file__, sys.argv) except OSError: os.execvp('python', ['python', __file__] + sys.argv[1:]) wrapper(interactive_cli, items=PAMenu(fail_hook=reexec), border=1) log.debug('Finished')