python类print_tb()的实例源码

awsqueryrequest.py 文件源码 项目:Chromium_DepotTools 作者: p07r0457 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def boto_except_hook(debugger_flag, debug_flag):
    def excepthook(typ, value, tb):
        if typ is bdb.BdbQuit:
            sys.exit(1)
        sys.excepthook = sys.__excepthook__

        if debugger_flag and sys.stdout.isatty() and sys.stdin.isatty():
            if debugger.__name__ == 'epdb':
                debugger.post_mortem(tb, typ, value)
            else:
                debugger.post_mortem(tb)
        elif debug_flag:
            print traceback.print_tb(tb)
            sys.exit(1)
        else:
            print value
            sys.exit(1)

    return excepthook
svg.py 文件源码 项目:vPiP 作者: brianinnes 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def createDrawingCoords(self):
        if self.drawingCoords is None:
            self.drawingCoords = []
            self.pathIterator = self._tokenize_path(self.d)
            while True:
                try:
                    command = next(self.pathIterator)
                    if not command in self.COMMANDS:
                        self.additionalParameter = float(command)
                        coord = self.svgAdditionalCoords.get(self.currentCommand)()
                    else:
                        coord = self.svgPathSegmentCommands.get(command.strip(), self.unknownCommand)()
                        self.currentCommand = command.strip()
                    if coord is not None:
                        self.drawingCoords.append(coord)
                except StopIteration:
                    break
                except:
                    exc_type, exc_value, exc_traceback = sys.exc_info()
                    print("test1 main thread exception : %s" % exc_type)
                    traceback.print_tb(exc_traceback, limit=2, file=sys.stdout)
        return self.drawingCoords
svg.py 文件源码 项目:vPiP 作者: brianinnes 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def createDrawingCoords(self):
        if self.drawingCoords is None:
            self.drawingCoords = []
            tokens = self._tokenize_path(self.points)
            x = float(next(tokens))
            y = float(next(tokens))
            self.drawingCoords.append(Coordinate.fromCoords(x, y, True))
            while True:
                try:
                    self.drawingCoords.append(Coordinate.fromCoords(float(next(tokens)), float(next(tokens)), False))
                except StopIteration:
                    break
                except:
                    exc_type, exc_value, exc_traceback = sys.exc_info()
                    print("test1 main thread exception : %s" % exc_type)
                    traceback.print_tb(exc_traceback, limit=2, file=sys.stdout)
        return self.drawingCoords
svg.py 文件源码 项目:vPiP 作者: brianinnes 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def createDrawingCoords(self):
        if self.drawingCoords is None:
            self.drawingCoords = []
            tokens = self._tokenize_path(self.points)
            x = float(next(tokens))
            y = float(next(tokens))
            startX, startY = x, y
            self.drawingCoords.append(Coordinate.fromCoords(x, y, True))
            while True:
                try:
                    self.drawingCoords.append(Coordinate.fromCoords(float(next(tokens)), float(next(tokens)), False))
                except StopIteration:
                    break
                except:
                    exc_type, exc_value, exc_traceback = sys.exc_info()
                    print("test1 main thread exception : %s" % exc_type)
                    traceback.print_tb(exc_traceback, limit=2, file=sys.stdout)
            self.drawingCoords.append(Coordinate.fromCoords(startX, startY, False))

        return self.drawingCoords
runner.py 文件源码 项目:prbuilds 作者: guardian 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __exit__(self, type, value, traceback):

        """ stop the running app and clean up """

        conf = self.get_config()

        playbook = os.path.join(directories.workspace, conf["teardown"]["ansible"])

        self.subprocess.call([
            "ansible-playbook", playbook
        ])

        if traceback:
            logging.error("PR Build failed")
            logging.error(str(traceback))
            logging.error(str(value))
            tb.print_tb(traceback)
awsqueryrequest.py 文件源码 项目:node-gn 作者: Shouqun 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def boto_except_hook(debugger_flag, debug_flag):
    def excepthook(typ, value, tb):
        if typ is bdb.BdbQuit:
            sys.exit(1)
        sys.excepthook = sys.__excepthook__

        if debugger_flag and sys.stdout.isatty() and sys.stdin.isatty():
            if debugger.__name__ == 'epdb':
                debugger.post_mortem(tb, typ, value)
            else:
                debugger.post_mortem(tb)
        elif debug_flag:
            print traceback.print_tb(tb)
            sys.exit(1)
        else:
            print value
            sys.exit(1)

    return excepthook
vminute.py 文件源码 项目:5minute 作者: SatelliteQE 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def die(message, excode=1, exception=None):
    """
    Print error message into srdErr
    :param message: message
    :param excode: exitcode
    :param exception: exception for debugging mode
    """
    global PROGRESS
    if PROGRESS is not None:
        if sys.stderr.isatty():
            progress(result="\x1b[31;01mFAIL\x1b[39;49;00m")
        else:
            progress(result="FAIL")
    global DEBUG
    if exception and DEBUG:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        sys.stderr.write("\n\x1b[92;01m")
        traceback.print_tb(exc_traceback)
        sys.stderr.write("\x1b[39;49;00m\n")
    if sys.stderr.isatty():
        sys.stderr.write("\n\x1b[31;01m%s\x1b[39;49;00m\n\n" % message)
    else:
        sys.stderr.write("\n%s\n\n" % message)
    sys.exit(excode)
engine.py 文件源码 项目:blues 作者: MobleyLab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def runEngine(self, context):
        """Selects a random Move object based on its
        assigned probability and and performs its move() function
        on a context.
        Parameters
        ----------
        context : openmm.context object
        OpenMM context whose positions should be moved.
        """
        try:
            new_context = self.moves[self.selected_move].move(context)
        except Exception as e:
            #In case the move isn't properly implemented, print out useful info
            print('Error: move not implemented correctly, printing traceback:')
            ex_type, ex, tb = sys.exc_info()
            traceback.print_tb(tb)
            print(e)
            raise SystemExit

        return new_context
awsqueryrequest.py 文件源码 项目:alfred-ec2 作者: SoMuchToGrok 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def boto_except_hook(debugger_flag, debug_flag):
    def excepthook(typ, value, tb):
        if typ is bdb.BdbQuit:
            sys.exit(1)
        sys.excepthook = sys.__excepthook__

        if debugger_flag and sys.stdout.isatty() and sys.stdin.isatty():
            if debugger.__name__ == 'epdb':
                debugger.post_mortem(tb, typ, value)
            else:
                debugger.post_mortem(tb)
        elif debug_flag:
            print(traceback.print_tb(tb))
            sys.exit(1)
        else:
            print(value)
            sys.exit(1)

    return excepthook
base.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def load_wsgi(self):
        try:
            self.wsgi = self.app.wsgi()
        except SyntaxError as e:
            if self.cfg.reload == 'off':
                raise

            self.log.exception(e)

            # fix from PR #1228
            # storing the traceback into exc_tb will create a circular reference.
            # per https://docs.python.org/2/library/sys.html#sys.exc_info warning,
            # delete the traceback after use.
            try:
                exc_type, exc_val, exc_tb = sys.exc_info()
                self.reloader.add_extra_file(exc_val.filename)

                tb_string = six.StringIO()
                traceback.print_tb(exc_tb, file=tb_string)
                self.wsgi = util.make_fail_app(tb_string.getvalue())
            finally:
                del exc_tb
start_server.py 文件源码 项目:doubao_service 作者: roboyun 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def initLog(log_path):
    '''
    ??????????????
    '''
    try:
        if os.path.exists(log_path)==False:
            os.makedirs(log_path)
    except:
        etype, evalue, tracebackObj = sys.exc_info()[:3]
        print("Type: " , etype)
        print("Value: " , evalue)
        traceback.print_tb(tracebackObj)

    track_log = log_path+'/track.log'    

    logging.basicConfig(level=logging.DEBUG,
                format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                datefmt='%a, %d %b %Y %H:%M:%S',
                filename=track_log,
                filemode='a')
bot.py 文件源码 项目:demo.slackbot 作者: SynapseFI 项目源码 文件源码 阅读 135 收藏 0 点赞 0 评论 0
def execute_command(self, command, slack_id, params, channel):
        """Attempt to run the command with the parameters provided."""
        self.acknowledge_command(channel)
        synapse_user = self.synapse_user_from_slack_user_id(slack_id)
        response = self.registration_prompt(slack_id)

        if synapse_user:
            try:
                response = command(slack_id, synapse_user, params)
            except SynapsePayError as e:
                response = (
                    'An HTTP error occurred while trying to communicate with '
                    'the Synapse API:\n{0}'.format(e.message)
                )
            except Exception as e:
                traceback.print_tb(e.__traceback__)
                response = 'An error occurred:\n{0}: {1}'.format(
                    sys.exc_info()[0],sys.exc_info()[1]
                )
        return response
awsqueryrequest.py 文件源码 项目:depot_tools 作者: webrtc-uwp 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def boto_except_hook(debugger_flag, debug_flag):
    def excepthook(typ, value, tb):
        if typ is bdb.BdbQuit:
            sys.exit(1)
        sys.excepthook = sys.__excepthook__

        if debugger_flag and sys.stdout.isatty() and sys.stdin.isatty():
            if debugger.__name__ == 'epdb':
                debugger.post_mortem(tb, typ, value)
            else:
                debugger.post_mortem(tb)
        elif debug_flag:
            print traceback.print_tb(tb)
            sys.exit(1)
        else:
            print value
            sys.exit(1)

    return excepthook
test_interactivshell.py 文件源码 项目:blender 作者: gastrodia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def mock_input(testfunc):
    """Decorator for tests of the main interact loop.

    Write the test as a generator, yield-ing the input strings, which IPython
    will see as if they were typed in at the prompt.
    """
    def test_method(self):
        testgen = testfunc(self)
        with mock_input_helper(testgen) as mih:
            mih.ip.interact()

        if mih.exception is not None:
            # Re-raise captured exception
            etype, value, tb = mih.exception
            import traceback
            traceback.print_tb(tb, file=sys.stdout)
            del tb  # Avoid reference loop
            raise value

    return test_method

# Test classes -----------------------------------------------------------------
scraper.py 文件源码 项目:GWork 作者: shunk031 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def scrap(self):
        """
        scrap target url page
        """

        # get list of detail article url
        article_detail_url_list = self.get_article_detail_urls()

        article_detail_info = []
        for article_url in article_detail_url_list:
            try:
                article_dict = self.get_article_detail_info_dict(article_url)
                article_detail_info.append(article_dict)

            except AttributeError as err:
                print("[ Exception ] Exception occured in GScraper#scrap: {}".format(err))
                traceback.print_tb(err.__traceback__)

        self.save_article_detail_info_list_to_csv(article_detail_info)
test_interactivshell.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 130 收藏 0 点赞 0 评论 0
def mock_input(testfunc):
    """Decorator for tests of the main interact loop.

    Write the test as a generator, yield-ing the input strings, which IPython
    will see as if they were typed in at the prompt.
    """
    def test_method(self):
        testgen = testfunc(self)
        with mock_input_helper(testgen) as mih:
            mih.ip.interact()

        if mih.exception is not None:
            # Re-raise captured exception
            etype, value, tb = mih.exception
            import traceback
            traceback.print_tb(tb, file=sys.stdout)
            del tb  # Avoid reference loop
            raise value

    return test_method

# Test classes -----------------------------------------------------------------
wssclient.py 文件源码 项目:python-wss 作者: tripzero 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _connect_once(self):
        try:
            yield from self._connect()

        except ConnectionRefusedError:
            self.print_debug("connection refused ({})".format(self.address))

        except OSError:
            self.print_debug("connection failed ({})".format(self.address))

        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
            traceback.print_exception(exc_type, exc_value, exc_traceback,
                    file=sys.stdout)
            self.print_debug("connection failed ({})".format(self.address))
wssclient.py 文件源码 项目:python-wss 作者: tripzero 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def onMessage(self, payload, isBinary):
        if isBinary:
            try:
                self.binaryHandler(payload)
            except KeyboardInterrupt:
                raise KeyboardInterrupt()

            except:
                exc_type, exc_value, exc_traceback = sys.exc_info()
                traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
                traceback.print_exception(exc_type, exc_value, exc_traceback,
                        limit=6, file=sys.stdout)
        else:
            try:
                if self.textHandler:
                    self.textHandler(payload)
            except KeyboardInterrupt:
                raise KeyboardInterrupt()
            except:
                exc_type, exc_value, exc_traceback = sys.exc_info()
                traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
                traceback.print_exception(exc_type, exc_value, exc_traceback,
                        limit=6, file=sys.stdout)
wssserver.py 文件源码 项目:python-wss 作者: tripzero 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def broadcast(self, msg, isBinary = False):
        try:
            if self.throttle:
                self.broadcastMsg = msg
            else:
                if self.encodeMsg:
                    msg = base64.b64encode(self.msg)
                for c in self.clients:
                    if isBinary:
                        c.sendBinaryMsg(msg)
                    else:
                        c.sendTextMsg(msg)
        except:
            self.print_debug("exception while broadcast()")
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
            traceback.print_exception(exc_type, exc_value, exc_traceback,
                          limit=6, file=sys.stdout)
information.py 文件源码 项目:FB-chatbot 作者: LinYunWen 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def get_info(msg, info_type):
    global is_match
    get = {
        InputType.TRACK: _get_track,
        InputType.ALBUM: _get_album,
        InputType.PLAYLIST: _get_playlist,
        InputType.ARTIST: _get_artist,
    }
    is_match = False

    try:
        info = get[info_type](msg)
    except:
        tb = sys.exc_info()
        print(tb[1])
        print(traceback.print_tb(tb[2]))
        return {'mode':ErrorType.SOMETHING_WRONG}
    return info


问题


面经


文章

微信
公众号

扫码关注公众号