当前位置: 首页>>代码示例>>Python>>正文


Python traceback.print_exception函数代码示例

本文整理汇总了Python中traceback.print_exception函数的典型用法代码示例。如果您正苦于以下问题:Python print_exception函数的具体用法?Python print_exception怎么用?Python print_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了print_exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: formatResult

    def formatResult(self, seekable, le, data, sw, sm):
        if seekable:
            # when le = 0 then we want to have 0x9000. here we only have the
            # effective le, which is either MAX_EXTENDED_LE or MAX_SHORT_LE,
            # depending on the APDU. Note that the following distinguisher has
            # one false positive
            if le > len(data) and le != MAX_EXTENDED_LE and le != MAX_SHORT_LE:
                sw = SW["WARN_EOFBEFORENEREAD"]

        if le != None:
            result = data[:le]
        else:
            result = data[:0]
        if sm:
            try:
                sw, result = self.SAM.protect_result(sw, result)
            except SwError as e:
                logging.info(e.message)
                import traceback
                traceback.print_exception(*sys.exc_info())
                sw = e.sw
                result = ""
                answer = self.formatResult(False, 0, result, sw, False)

        return R_APDU(result, inttostring(sw)).render()
开发者ID:Jdi99y515,项目名称:vsmartcard,代码行数:25,代码来源:nPA.py

示例2: periodic_tasks

def periodic_tasks():
    '''run periodic checks'''
    if mpstate.status.setup_mode:
        return

    if mpstate.settings.heartbeat != 0:
        heartbeat_period.frequency = mpstate.settings.heartbeat

    if heartbeat_period.trigger() and mpstate.settings.heartbeat != 0:
        mpstate.status.counters['MasterOut'] += 1
        for master in mpstate.mav_master:
            send_heartbeat(master)

    if heartbeat_check_period.trigger():
        check_link_status()

    set_stream_rates()

    if battery_period.trigger():
        battery_report()

    # call optional module idle tasks. These are called at several hundred Hz
    for m in mpstate.modules:
        if hasattr(m, 'idle_task'):
            try:
                m.idle_task()
            except Exception, msg:
                if mpstate.settings.moddebug == 1:
                    print(msg)
                elif mpstate.settings.moddebug > 1:
                    import traceback
                    exc_type, exc_value, exc_traceback = sys.exc_info()
                    traceback.print_exception(exc_type, exc_value, exc_traceback,
                                              limit=2, file=sys.stdout)
开发者ID:geeksville,项目名称:MAVProxy,代码行数:34,代码来源:mavproxy.py

示例3: _handle_thread_exception

def _handle_thread_exception(request, exc_info):
    """Default exception handler callback function.

    This just prints the exception info via ``traceback.print_exception``.

    """
    traceback.print_exception(*exc_info)
开发者ID:NickDaniil,项目名称:structured,代码行数:7,代码来源:threadpool_dist.py

示例4: cleanMesh

def cleanMesh(mesh, connectivityFilter=False):
    try:
        t = time.clock()
        connect = vtk.vtkPolyDataConnectivityFilter()
        clean = vtk.vtkCleanPolyData()

        if (connectivityFilter):
            if vtk.vtkVersion.GetVTKMajorVersion() >= 6:
                connect.SetInputData( mesh )
            else:
                connect.SetInput( mesh )
            connect.SetExtractionModeToLargestRegion()
            clean.SetInputConnection( connect.GetOutputPort() )
        else:
            if vtk.vtkVersion.GetVTKMajorVersion() >= 6:
                clean.SetInputData( mesh )
            else:
                clean.SetInput( mesh )

        clean.Update()
        print ("Surface cleaned")
        m2 = clean.GetOutput()
        print "    ", m2.GetNumberOfPolys(), "polygons"
        elapsedTime(t)
        clean = None
        connect = None
        return m2
    except:
        print "Surface cleaning failed"
        exc_type, exc_value, exc_traceback = sys.exc_info()
        traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stdout)
    return None
开发者ID:541435721,项目名称:dicom2stl,代码行数:32,代码来源:vtkutils.py

示例5: __call__

 def __call__(self, environ, start_response):
     try:
         return self.app(environ, start_response)
     except:
         traceback.print_exception(*sys.exc_info())
         pdb.post_mortem(sys.exc_info()[2])
         raise
开发者ID:kilink,项目名称:bobo,代码行数:7,代码来源:boboserver.py

示例6: readCamera

	def readCamera(self):
		cap = cv2.VideoCapture(0)
		frame = None
		success = False

		if not cap.isOpened():
			print("Failed to open camera!")
			return

		while True:
			try: 
				success, frame = cap.read()

				if not success:
					print("cap.read() failed")
					yield trollius.From(trollius.sleep(1.0/self.fps))
					continue
				
				self.broadcast(frame)

				if self.hasFrame:
					self.hasFrame(frame)

			except KeyboardInterrupt:
				self.loop.stop()

			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=2, file=sys.stdout)

			yield trollius.From(trollius.sleep(1.0/self.fps))

		cap.release()
开发者ID:tripzero,项目名称:snetcam,代码行数:35,代码来源:cameraserver.py

示例7: process_feed_wrapper

    def process_feed_wrapper(self, feed):
        """ wrapper for ProcessFeed
        """
        start_time = datetime.datetime.now()
        try:
            pfeed = ProcessFeed(feed, self.options)
            ret_feed, ret_entries = pfeed.process()
            del pfeed
        except:
            (etype, eobj, etb) = sys.exc_info()
            print '[%d] ! -------------------------' % (feed.id,)
            print traceback.format_exception(etype, eobj, etb)
            traceback.print_exception(etype, eobj, etb)
            print '[%d] ! -------------------------' % (feed.id,)
            ret_feed = FEED_ERREXC
            ret_entries = {}

        delta = datetime.datetime.now() - start_time
        if delta.seconds > SLOWFEED_WARNING:
            comment = u' (SLOW FEED!)'
        else:
            comment = u''
        prints(u'[%d] Processed %s in %s [%s] [%s]%s' % (
            feed.id, feed.feed_url, unicode(delta),
            self.feed_trans[ret_feed],
            u' '.join(u'%s=%d' % (self.entry_trans[key],
                      ret_entries[key]) for key in self.entry_keys),
            comment))

        self.feed_stats[ret_feed] += 1
        for key, val in ret_entries.items():
            self.entry_stats[key] += val

        return ret_feed, ret_entries
开发者ID:teerytko,项目名称:nokiantorpedo-django,代码行数:34,代码来源:feedjack_update.py

示例8: _load_neo_file

    def _load_neo_file(cls, filename, lazy):
        """ Returns a NEO io object and a list of contained blocks for a
        file name. This function also caches all loaded blocks

        :param str filename:
            The full path of the file (relative or absolute).
        :param bool lazy:
            Determines if lazy mode is used for NEO io.
        """
        if os.path.isdir(filename):
            for io in neo.io.iolist:
                if io.mode == 'dir':
                    try:
                        n_io = io(filename)
                        block = n_io.read(lazy=lazy)
                        if io == neo.TdtIO and not block.segments:
                            # TdtIO can produce empty blocks for invalid dirs
                            continue

                        cls.block_indices[block] = 0
                        cls.loaded_blocks[filename] = [block]
                        return n_io, [block]
                    except Exception, e:
                        sys.stderr.write(
                            'Load error for directory "%s":\n' % filename)
                        tb = sys.exc_info()[2]
                        while not ('self' in tb.tb_frame.f_locals and
                                   tb.tb_frame.f_locals['self'] == n_io):
                            if tb.tb_next is not None:
                                tb = tb.tb_next
                            else:
                                break
                        traceback.print_exception(type(e), e, tb)
开发者ID:mczhu,项目名称:spykeutils,代码行数:33,代码来源:data_provider_neo.py

示例9: _greenlet_report_error

def _greenlet_report_error(self, exc_info):
    import sys
    import traceback

    exception = exc_info[1]
    if isinstance(exception, gevent.greenlet.GreenletExit):
        self._report_result(exception)
        return
    exc_handler = False
    for lnk in self._links:
        if isinstance(lnk, gevent.greenlet.FailureSpawnedLink):
            exc_handler = True
            break
    if not exc_handler:
        try:
            traceback.print_exception(*exc_info)
        except:
            pass
    self._exception = exception
    if self._links and self._notifier is None:
        self._notifier = self.parent.loop.run_callback(self._notify_links)
    ## Only print errors
    if not exc_handler:
        info = str(self) + ' failed with '
        try:
            info += self._exception.__class__.__name__
        except Exception:
            info += str(self._exception) or repr(self._exception)
        sys.stderr.write(info + '\n\n')
开发者ID:abhishekgahlot,项目名称:grequests,代码行数:29,代码来源:grequests.py

示例10: _info

def _info(type, value, tb):
	if not _exception_in_progress.acquire(False):
		# Exceptions have piled up, so we use the default exception
		# handler for such exceptions
		_excepthook_save(type, value, tb)
		return

	dialog = dialogs.HigDialog(None, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE, 
				_('A programming error has been detected'),
				_('It probably is not fatal, but should be reported '
				'to the developers nonetheless.'))
	
	#FIXME: add icon to this button
	RESPONSE_REPORT_BUG = 42
	dialog.add_buttons(gtk.STOCK_CLOSE, gtk.BUTTONS_CLOSE,
		_('_Report Bug'), RESPONSE_REPORT_BUG)
	dialog.set_default_response(RESPONSE_REPORT_BUG)
	report_button = dialog.action_area.get_children()[0] # right to left
	report_button.grab_focus()

	# Details
	textview = gtk.TextView()
	textview.set_editable(False)
	textview.modify_font(pango.FontDescription('Monospace'))
	sw = gtk.ScrolledWindow()
	sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	sw.add(textview)
	frame = gtk.Frame()
	frame.set_shadow_type(gtk.SHADOW_IN)
	frame.add(sw)
	frame.set_border_width(6)
	textbuffer = textview.get_buffer()
	trace = StringIO()
	traceback.print_exception(type, value, tb, None, trace)
	textbuffer.set_text(trace.getvalue())
	textview.set_size_request(
		gtk.gdk.screen_width() / 3,
		gtk.gdk.screen_height() / 4)
	expander = gtk.Expander(_('Details'))
	expander.add(frame)
	dialog.vbox.add(expander)

	dialog.set_resizable(True)
	# on expand the details the dialog remains centered on screen
	dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)

	dialog.show_all()

	close_clicked = False
	while not close_clicked:
		resp = dialog.run()
		if resp == RESPONSE_REPORT_BUG:
			url = 'http://trac.gajim.org/wiki/WikiStart#howto_report_ticket'
			helpers.launch_browser_mailer('url', url)
		else:
			close_clicked = True
	
	dialog.destroy()

	_exception_in_progress.release()
开发者ID:pacoqueen,项目名称:bbinn,代码行数:60,代码来源:gtkexcepthook.py

示例11: execute

def execute(meth, *args, **kwargs):
    """
    Execute *meth* in a Python thread, blocking the current coroutine/
    greenthread until the method completes.

    The primary use case for this is to wrap an object or module that is not
    amenable to monkeypatching or any of the other tricks that Eventlet uses
    to achieve cooperative yielding.  With tpool, you can force such objects to
    cooperate with green threads by sticking them in native threads, at the cost
    of some overhead.
    """
    setup()
    # if already in tpool, don't recurse into the tpool
    # also, call functions directly if we're inside an import lock, because
    # if meth does any importing (sadly common), it will hang
    my_thread = threading.currentThread()
    if my_thread in _threads or imp.lock_held() or _nthreads == 0:
        return meth(*args, **kwargs)

    e = event.Event()
    _reqq.put((e, meth, args, kwargs))

    rv = e.wait()
    if isinstance(rv, tuple) \
            and len(rv) == 3 \
            and isinstance(rv[1], EXC_CLASSES):
        (c, e, tb) = rv
        if not QUIET:
            traceback.print_exception(c, e, tb)
            traceback.print_stack()
        six.reraise(c, e, tb)
    return rv
开发者ID:Aayush-Kasurde,项目名称:eventlet,代码行数:32,代码来源:tpool.py

示例12: Start

def Start(filename):
    global state
    global g
    result=''
    # read data case line by line from file
    try:
        br=open(filename,'r')
        for re in br:
            print 'Processing '+re+'...'
            re=re.strip()
            calc_next(re)
            state=0
            nfa=parse(re,0,len(re)-1)
            #calculate closure
            calc_closure()
            #test 01 string of length up to 6
            for length in range(1,6+1):
                for num in range(0,(1<<length)):
                    if (test(closure[nfa[0]],nfa[1],0,length,num)):
                        for i in range(length):
                            if ((num&(1<<i))>0):
                                result=result+'1'
                            else:
                                result=result+'0'
                        result=result+"\n"
        # Close the input stream
        br.close()
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        print "*** print_exception:"
        traceback.print_exception(exc_type, exc_value, exc_traceback,limit=2, file=sys.stdout)
        result=result+'error'
    return result
开发者ID:siyuano,项目名称:Automata-theory,代码行数:33,代码来源:epsnfa.py

示例13: on_crash

 def on_crash(self, msg, *fmt, **kwargs):
     print(msg.format(*fmt), file=sys.stderr)
     exc_info = sys.exc_info()
     try:
         traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], None, sys.stderr)
     finally:
         del (exc_info)
开发者ID:shahjahanw,项目名称:celery,代码行数:7,代码来源:threads.py

示例14: DbgTry

def DbgTry(method, *values):
    try:
        return method(*values)
    except Exception as e:
        from . import breakpoint
        traceback.print_exception(*sys.exc_info())
        bp()
开发者ID:Magdno1,项目名称:Arianrhod,代码行数:7,代码来源:invoker.py

示例15: handle

    def handle(self, csvpath, *args, **options):
        
        
        loader = ContributionLoader(
            source=options.get('source'),
            description='load from denormalized CSVs',
            imported_by="loadcontributions.py (%s)" % os.getenv('LOGNAME', 'unknown'),
        )
        
        try:
            input_iterator = VerifiedCSVSource(open(os.path.abspath(csvpath)), FIELDNAMES, skiprows=1 + int(options['skip']))
            
            output_func = chain_filters(
                LoaderEmitter(loader),
                #Every(self.COMMIT_FREQUENCY, lambda i: transaction.commit()),
                Every(self.COMMIT_FREQUENCY, progress_tick))
            
            record_processor = self.get_record_processor(loader.import_session)

            load_data(input_iterator, record_processor, output_func)

            transaction.commit()
        except KeyboardInterrupt:
            traceback.print_exception(*sys.exc_info())
            transaction.rollback()
            raise
        except:
            traceback.print_exception(*sys.exc_info())
            transaction.rollback()
            raise
        finally:
            sys.stdout.flush()
            sys.stderr.flush()
开发者ID:lukerosiak,项目名称:datacommons,代码行数:33,代码来源:loadcontributions.py


注:本文中的traceback.print_exception函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。