def runDebug(self, exc_info): if flags.can_touch_runtime_system("switch console") \ and self._intf_tty_num != 1: iutil.vtActivate(1) iutil.eintr_retry_call(os.open, "/dev/console", os.O_RDWR) # reclaim stdin iutil.eintr_ignore(os.dup2, 0, 1) # reclaim stdout iutil.eintr_ignore(os.dup2, 0, 2) # reclaim stderr # ^ # | # +------ dup2 is magic, I tells ya! # bring back the echo import termios si = sys.stdin.fileno() attr = termios.tcgetattr(si) attr[3] = attr[3] & termios.ECHO termios.tcsetattr(si, termios.TCSADRAIN, attr) print("\nEntering debugger...") print("Use 'continue' command to quit the debugger and get back to "\ "the main window") import pdb pdb.post_mortem(exc_info.stack) if flags.can_touch_runtime_system("switch console") \ and self._intf_tty_num != 1: iutil.vtActivate(self._intf_tty_num)
def runDebug(self, exc_info): if flags.can_touch_runtime_system("switch console") and self._intf_tty_num != 1: iutil.vtActivate(1) iutil.eintr_retry_call(os.open, "/dev/console", os.O_RDWR) # reclaim stdin iutil.eintr_ignore(os.dup2, 0, 1) # reclaim stdout iutil.eintr_ignore(os.dup2, 0, 2) # reclaim stderr # ^ # | # +------ dup2 is magic, I tells ya! # bring back the echo import termios si = sys.stdin.fileno() attr = termios.tcgetattr(si) attr[3] = attr[3] & termios.ECHO termios.tcsetattr(si, termios.TCSADRAIN, attr) print("\nEntering debugger...") print("Use 'continue' command to quit the debugger and get back to " "the main window") import pdb pdb.post_mortem(exc_info.stack) if flags.can_touch_runtime_system("switch console") and self._intf_tty_num != 1: iutil.vtActivate(self._intf_tty_num)
def vt_activate_test(self): """Test vtActivate.""" # pylint: disable-msg=E1101 def raise_os_error(*args, **kwargs): raise OSError # chvt does not exist on all platforms # and the function needs to correctly survie that iutil.vtActivate.func_globals['execWithRedirect'] = raise_os_error self.assertEqual(iutil.vtActivate(2), False)
def runDebug(self, exc_info): if flags.can_touch_runtime_system("switch console") \ and self._intf_tty_num != 1: iutil.vtActivate(1) pidfl = "/tmp/vncshell.pid" if os.path.exists(pidfl) and os.path.isfile(pidfl): pf = open(pidfl, "r") for pid in pf.readlines(): if not int(pid) == os.getpid(): os.kill(int(pid), signal.SIGKILL) pf.close() iutil.eintr_retry_call(os.open, "/dev/console", os.O_RDWR) # reclaim stdin iutil.eintr_retry_call(os.dup2, 0, 1) # reclaim stdout iutil.eintr_retry_call(os.dup2, 0, 2) # reclaim stderr # ^ # | # +------ dup2 is magic, I tells ya! # bring back the echo import termios si = sys.stdin.fileno() attr = termios.tcgetattr(si) attr[3] = attr[3] & termios.ECHO termios.tcsetattr(si, termios.TCSADRAIN, attr) print("\nEntering debugger...") print("Use 'continue' command to quit the debugger and get back to "\ "the main window") import pdb pdb.post_mortem(exc_info.stack) if flags.can_touch_runtime_system("switch console") \ and self._intf_tty_num != 1: iutil.vtActivate(self._intf_tty_num)
def runDebug(self, exc_info): if flags.can_touch_runtime_system("switch console") \ and self._intf_tty_num != 1: iutil.vtActivate(1) pidfl = "/tmp/vncshell.pid" if os.path.exists(pidfl) and os.path.isfile(pidfl): pf = open(pidfl, "r") for pid in pf.readlines(): if not int(pid) == os.getpid(): os.kill(int(pid), signal.SIGKILL) pf.close() os.open("/dev/console", os.O_RDWR) # reclaim stdin os.dup2(0, 1) # reclaim stdout os.dup2(0, 2) # reclaim stderr # ^ # | # +------ dup2 is magic, I tells ya! # bring back the echo import termios si = sys.stdin.fileno() attr = termios.tcgetattr(si) attr[3] = attr[3] & termios.ECHO termios.tcsetattr(si, termios.TCSADRAIN, attr) print("\nEntering debugger...") print("Use 'continue' command to quit the debugger and get back to "\ "the main window") import pdb pdb.post_mortem(exc_info.stack) if flags.can_touch_runtime_system("switch console") \ and self._intf_tty_num != 1: iutil.vtActivate(self._intf_tty_num)
def vt_activate_test(self): """Test vtActivate.""" # pylint: disable=no-member def raise_os_error(*args, **kwargs): raise OSError _execWithRedirect = iutil.vtActivate.__globals__['execWithRedirect'] try: # chvt does not exist on all platforms # and the function needs to correctly survie that iutil.vtActivate.__globals__['execWithRedirect'] = raise_os_error self.assertEqual(iutil.vtActivate(2), False) finally: iutil.vtActivate.__globals__['execWithRedirect'] = _execWithRedirect
def _earlyExceptionHandler(ty, value, traceback): iutil.ipmi_report(constants.IPMI_FAILED) iutil.vtActivate(1) return sys.__excepthook__(ty, value, traceback)