Python traceback.print_last() Examples

The following are 10 code examples of traceback.print_last(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module traceback , or try the search function .
Example #1
Source File: dbg.py    From r2lldb with MIT License 6 votes vote down vote up
def system_ls(path):
	ret = ""
	print ("LS("+path+")")
	try:
		ptr = runCode('(void*)opendir((char*)"'+path+'");')
		if int(ptr,16) == 0:
			return "Cannot find directory"
		print("opendir("+ptr+")")
		while True:
			de = runCode('(void*)readdir((void*)'+ptr+');');
			#print ("readdir()="+de)
			if int(de,16) == 0:
				break
			row = cmd('x/1s '+de+'+0x15')
			print (row.strip())
			ret = ret + row
		runCode('(int)closedir((void*)'+ptr+')')
	except:
		traceback.print_last()
		ret = ret + "ERR\n";
	return ret 
Example #2
Source File: dbg.py    From r2lldb with MIT License 6 votes vote down vote up
def system_ls(path):
	ret = ""
	print ("LS("+path+")")
	try:
		ptr = runCode('(void*)opendir((char*)"'+path+'");')
		if int(ptr,16) == 0:
			return "Cannot find directory"
		print "opendir("+ptr+")"
		while True:
			de = runCode('(void*)readdir((void*)'+ptr+');');
			#print ("readdir()="+de)
			if int(de,16) == 0:
				break
			row = cmd('x/1s '+de+'+0x15')
			print (row.strip())
			ret = ret + row
		runCode('(int)closedir((void*)'+ptr+')')
	except:
		traceback.print_last()
		ret = ret + "ERR\n";
	return ret 
Example #3
Source File: app.py    From core with MIT License 5 votes vote down vote up
def show(root=None, debug=False, parent=None):
    """Display Scene Inventory GUI

    Arguments:
        debug (bool, optional): Run in debug-mode,
            defaults to False
        parent (QtCore.QObject, optional): When provided parent the interface
            to this QObject.

    """

    try:
        module.window.close()
        del module.window
    except (RuntimeError, AttributeError):
        pass

    if debug:
        import traceback
        sys.excepthook = lambda typ, val, tb: traceback.print_last()

    with tools_lib.application():
        window = Window(parent)
        window.show()
        window.setStyleSheet(style.load_stylesheet())
        window.refresh()

        module.window = window

        # Pull window to the front.
        module.window.raise_()
        module.window.activateWindow() 
Example #4
Source File: breakpoint.py    From PyDev.Debugger with Eclipse Public License 1.0 5 votes vote down vote up
def __clear_break(self, pid, address):
        """
        Used by L{dont_break_at} and L{dont_stalk_at}.

        @type  pid: int
        @param pid: Process global ID.

        @type  address: int or str
        @param address:
            Memory address of code instruction to break at. It can be an
            integer value for the actual address or a string with a label
            to be resolved.
        """
        if type(address) not in (int, long):
            unknown = True
            label = address
            try:
                deferred = self.__deferredBP[pid]
                del deferred[label]
                unknown = False
            except KeyError:
##                traceback.print_last()      # XXX DEBUG
                pass
            aProcess = self.system.get_process(pid)
            try:
                address = aProcess.resolve_label(label)
                if not address:
                    raise Exception()
            except Exception:
##                traceback.print_last()      # XXX DEBUG
                if unknown:
                    msg = ("Can't clear unknown code breakpoint"
                           " at %s in process ID %d")
                    msg = msg % (label, pid)
                    warnings.warn(msg, BreakpointWarning)
                return
        if self.has_code_breakpoint(pid, address):
            self.erase_code_breakpoint(pid, address) 
Example #5
Source File: dbg.py    From r2lldb with MIT License 5 votes vote down vote up
def system_cat(path, head=False):
	ret = ""
	try:
		fd = runCode('(void*)open((char*)"'+path+'",0);')
		print ("FD "+fd)
		if int(fd,16) == 4294967295:
			return "Cannot open file"
		buf = runCode('(void*)malloc((int)10240)')
		print("open("+buf+")")
		i = 0
		while True:
			de = runCode('(int)read((int)'+str(fd)+',(void*)'+str(buf)+',(int)1024);');
			count = int (de, 16)
			print ("read("+str(i)+")="+str(count))
			try:
				data = read(int(buf,16), count)
				ret = ret + str(data)
			except:
				traceback.print_last()
				ret = ret + ".\n"
			if count != 1024 and count != 0x1024:
				break
			if head:
				break
			i = i + 1
	except:
		traceback.print_last()
		ret = ret + "ERR\n";
	cmd('e (void)free((void*)'+buf+')')
	cmd('e (int)close((int)'+fd+')')
	return ret 
Example #6
Source File: dbg.py    From r2lldb with MIT License 5 votes vote down vote up
def system_cat(path, head=False):
	ret = ""
	try:
		fd = runCode('(void*)open((char*)"'+path+'",0);')
		print ("FD "+fd)
		if int(fd,16) == 4294967295:
			return "Cannot open file"
		buf = runCode('(void*)malloc((int)10240)')
		print "open("+buf+")"
		i = 0
		while True:
			de = runCode('(int)read((int)'+str(fd)+',(void*)'+str(buf)+',(int)1024);');
			count = int (de, 16)
			print ("read("+str(i)+")="+str(count))
			try:
				data = read(int(buf,16), count)
				ret = ret + str(data)
			except:
				traceback.print_last()
				ret = ret + ".\n"
			if count != 1024 and count != 0x1024:
				break
			if head:
				break
			i = i + 1
	except:
		traceback.print_last()
		ret = ret + "ERR\n";
	cmd('e (void)free((void*)'+buf+')')
	cmd('e (int)close((int)'+fd+')')
	return ret 
Example #7
Source File: breakpoint.py    From OpenXMolar with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __clear_break(self, pid, address):
        """
        Used by L{dont_break_at} and L{dont_stalk_at}.

        @type  pid: int
        @param pid: Process global ID.

        @type  address: int or str
        @param address:
            Memory address of code instruction to break at. It can be an
            integer value for the actual address or a string with a label
            to be resolved.
        """
        if type(address) not in (int, long):
            unknown = True
            label = address
            try:
                deferred = self.__deferredBP[pid]
                del deferred[label]
                unknown = False
            except KeyError:
##                traceback.print_last()      # XXX DEBUG
                pass
            aProcess = self.system.get_process(pid)
            try:
                address = aProcess.resolve_label(label)
                if not address:
                    raise Exception()
            except Exception:
##                traceback.print_last()      # XXX DEBUG
                if unknown:
                    msg = ("Can't clear unknown code breakpoint"
                           " at %s in process ID %d")
                    msg = msg % (label, pid)
                    warnings.warn(msg, BreakpointWarning)
                return
        if self.has_code_breakpoint(pid, address):
            self.erase_code_breakpoint(pid, address) 
Example #8
Source File: breakpoint.py    From filmkodi with Apache License 2.0 5 votes vote down vote up
def __clear_break(self, pid, address):
        """
        Used by L{dont_break_at} and L{dont_stalk_at}.

        @type  pid: int
        @param pid: Process global ID.

        @type  address: int or str
        @param address:
            Memory address of code instruction to break at. It can be an
            integer value for the actual address or a string with a label
            to be resolved.
        """
        if type(address) not in (int, long):
            unknown = True
            label = address
            try:
                deferred = self.__deferredBP[pid]
                del deferred[label]
                unknown = False
            except KeyError:
##                traceback.print_last()      # XXX DEBUG
                pass
            aProcess = self.system.get_process(pid)
            try:
                address = aProcess.resolve_label(label)
                if not address:
                    raise Exception()
            except Exception:
##                traceback.print_last()      # XXX DEBUG
                if unknown:
                    msg = ("Can't clear unknown code breakpoint"
                           " at %s in process ID %d")
                    msg = msg % (label, pid)
                    warnings.warn(msg, BreakpointWarning)
                return
        if self.has_code_breakpoint(pid, address):
            self.erase_code_breakpoint(pid, address) 
Example #9
Source File: app.py    From core with MIT License 4 votes vote down vote up
def show(debug=False, parent=None, use_context=False):
    """Display Loader GUI

    Arguments:
        debug (bool, optional): Run loader in debug-mode,
            defaults to False
        parent (QtCore.QObject, optional): The Qt object to parent to.
        use_context (bool): Whether to apply the current context upon launch

    """

    # Remember window
    if module.window is not None:
        try:
            module.window.show()

            # If the window is minimized then unminimize it.
            if module.window.windowState() & QtCore.Qt.WindowMinimized:
                module.window.setWindowState(QtCore.Qt.WindowActive)

            # Raise and activate the window
            module.window.raise_()             # for MacOS
            module.window.activateWindow()     # for Windows
            module.window.refresh()
            return
        except RuntimeError as exc:
            if not str(exc).rstrip().endswith("already deleted."):
                raise

            # Garbage collected
            module.window = None

    if debug:
        import traceback
        sys.excepthook = lambda typ, val, tb: traceback.print_last()

    with lib.application():

        # TODO: Global state, remove these
        lib.refresh_family_config_cache()
        lib.refresh_group_config_cache()

        window = Window(parent)
        window.show()
        window.setStyleSheet(style.load_stylesheet())

        if use_context:
            context = {"asset": api.Session["AVALON_ASSET"]}
            window.set_context(context, refresh=True)
        else:
            window.refresh()

        module.window = window

        # Pull window to the front.
        module.window.raise_()
        module.window.activateWindow() 
Example #10
Source File: app.py    From core with MIT License 4 votes vote down vote up
def show(debug=False, parent=None):
    """Display asset creator GUI

    Arguments:
        debug (bool, optional): Run loader in debug-mode,
            defaults to False
        parent (QtCore.QObject, optional): When provided parent the interface
            to this QObject.

    """

    if module.window:
        module.window.close()
        del(module.window)

    if debug:
        from avalon import mock
        for creator in mock.creators:
            api.register_plugin(api.Creator, creator)

        import traceback
        sys.excepthook = lambda typ, val, tb: traceback.print_last()

        io.install()

        any_project = next(
            project for project in io.projects()
            if project.get("active", True) is not False
        )

        api.Session["AVALON_PROJECT"] = any_project["name"]
        module.project = any_project["name"]

    with lib.application():
        window = Window(parent)
        window.refresh()
        window.show()
        window.setStyleSheet(style.load_stylesheet())

        module.window = window

        # Pull window to the front.
        module.window.raise_()
        module.window.activateWindow()