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


Python sys.exc_type方法代码示例

本文整理汇总了Python中sys.exc_type方法的典型用法代码示例。如果您正苦于以下问题:Python sys.exc_type方法的具体用法?Python sys.exc_type怎么用?Python sys.exc_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


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

示例1: ScheduleCategoryUpdate

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def ScheduleCategoryUpdate(result_parent_key):
  """Add a task to update a category's statistics.

  The task is handled by base.admin.UpdateCategory which then
  calls UpdateCategory below.
  """
  # Give the task a name to ensure only one task for each ResultParent.
  result_parent = ResultParent.get(result_parent_key)
  category = result_parent.category
  name = 'categoryupdate-%s' % str(result_parent_key).replace('_', '-under-')
  url = '/_ah/queue/update-category/%s/%s' % (category, result_parent_key)

  task = taskqueue.Task(url=url, name=name, params={
      'category': category,
      'user_agent_key': result_parent.user_agent.key(),
      })
  attempt = 0
  while attempt < 3:
    try:
      task.add(queue_name='update-category')
      break
    except:
      attempt += 1
      logging.info('Cannot add task(attempt %s): %s:%s' %
                   (attempt, sys.exc_type, sys.exc_value)) 
开发者ID:elsigh,项目名称:browserscope,代码行数:27,代码来源:manage_dirty.py

示例2: test_set

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def test_set(self):
        side1 = [ None, set(), set('a'), set('abc'), set('bde')]
        for x in side1:
            for y in side1:
                for func in funclist2:
                    try:
                        printwith("case", case_repr(x, y, func));
                        res = func(x, y)
                        printwith("case", res)
                        
                        if isinstance(res, set):
                            for c in 'abcde':
                                printwith("same", c in res)
                        else:
                            printwith("same", res)                        
                    except:
                        printwith("same", sys.exc_type) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:sbs_typeop.py

示例3: test_reload_sys

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def test_reload_sys(self):
        import sys
        
        (old_copyright, old_byteorder) = (sys.copyright, sys.byteorder)
        (sys.copyright, sys.byteorder) = ("foo", "foo")
        
        (old_argv, old_exc_type) = (sys.argv, sys.exc_type)
        (sys.argv, sys.exc_type) = ("foo", "foo")
        
        reloaded_sys = reload(sys)
        
        # Most attributes get reset
        self.assertEqual((old_copyright, old_byteorder), (reloaded_sys.copyright, reloaded_sys.byteorder))
        # Some attributes are not reset
        self.assertEqual((reloaded_sys.argv, reloaded_sys.exc_type), ("foo", "foo"))
        # Put back the original values
        (sys.copyright, sys.byteorder) = (old_copyright, old_byteorder)
        (sys.argv, sys.exc_type) = (old_argv, old_exc_type) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_isinstance.py

示例4: test_str2

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def test_str2(self):
        # verify we can assign to sys.exc_*
        sys.exc_traceback = None
        sys.exc_value = None
        sys.exc_type = None

        self.assertEqual(str(Exception()), '')


        @skipUnlessIronPython()
        def test_array(self):
            import System
            try:
                a = System.Array()
            except Exception, e:
                self.assertEqual(e.__class__, TypeError)
            else: 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_exceptions.py

示例5: traceback_get_exception

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def traceback_get_exception(num = -1):

    # build error message
    exception_string = ''.join(traceback.format_exception_only(sys.exc_type, hasattr(sys, 'exc_value') and sys.exc_value or 'Unknown'))

    # extract error location from traceback
    if hasattr(sys, 'exc_traceback'):
        (filename, line_number, function_name, text) = traceback.extract_tb(sys.exc_traceback)[num]
    else:
        (filename, line_number, function_name, text) = ('-', '-', '-', '-')

    error = {
        'message': exception_string,
        'location': {
            'filename': filename,
            'line_number': line_number,
            'function_name': function_name,
            'text': text,
            }
    }

    return error 
开发者ID:daq-tools,项目名称:kotori,代码行数:24,代码来源:errors.py

示例6: run_campaign

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def run_campaign(test_campaign, get_interactive_session, verb=2):
    passed=failed=0
    if test_campaign.preexec:
        test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0]
    for testset in test_campaign:
        for t in testset:
            t.output,res = get_interactive_session(t.test.strip())
            the_res = False
            try:
                if res is None or res:
                    the_res= True
            except Exception,msg:
                t.output+="UTscapy: Error during result interpretation:\n"
                t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,))
            if the_res:
                t.res = True
                res = "passed"
                passed += 1
            else:
                t.res = False
                res = "failed"
                failed += 1
            t.result = res
            if verb > 1:
                print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t 
开发者ID:medbenali,项目名称:CyberScan,代码行数:27,代码来源:UTscapy.py

示例7: test_0

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def test_0(self):
        b = "sys.exc_type"
        a = "sys.exc_info()[0]"
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_fixers.py

示例8: test_3

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def test_3(self):
        b = "sys.exc_type # Foo"
        a = "sys.exc_info()[0] # Foo"
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_fixers.py

示例9: test_4

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def test_4(self):
        b = "sys.  exc_type"
        a = "sys.  exc_info()[0]"
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_fixers.py

示例10: test_5

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def test_5(self):
        b = "sys  .exc_type"
        a = "sys  .exc_info()[0]"
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_fixers.py

示例11: FormatException

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def FormatException(message):
  """Adds more information to the exception."""
  message = ('Exception Type: %s\n'
             'Details: %s\n'
             'Message: %s\n') % (sys.exc_type, traceback.format_exc(), message)
  return message 
开发者ID:DSPN,项目名称:google-compute-engine-dse,代码行数:8,代码来源:common.py

示例12: ScheduleRecentTestsUpdate

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def ScheduleRecentTestsUpdate():
    attempt = 0
    while attempt < 3:
        try:
            taskqueue.Task(method='GET').add(queue_name='recent-tests')
            break
        except:
            attempt += 1
            logging.info('Cannot add task (attempt %s): %s:%s' %
                         (attempt, sys.exc_type, sys.exc_value)) 
开发者ID:elsigh,项目名称:browserscope,代码行数:12,代码来源:util.py

示例13: UpdateDirty

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def UpdateDirty(request):
  """Updates any dirty tests, adding its score to the appropriate ranker."""
  logging.debug('UpdateDirty start.')

  task_name_prefix = request.REQUEST.get('task_name_prefix', '')
  result_time_key = request.REQUEST.get('result_time_key')
  category = request.REQUEST.get('category')
  count = int(request.REQUEST.get('count', 0))
  if result_time_key:
    result_time = ResultTime.get(result_time_key)
    try:
      ResultTime.UpdateStats(result_time)
    except:
      logging.info('UpdateStats: %s:%s' % (sys.exc_type, sys.exc_value))
    result_parent_key = result_time.parent_key()
  else:
    result_parent_key = request.REQUEST.get('result_parent_key')
    if result_parent_key:
      result_parent_key = db.Key(result_parent_key)
    else:
      UpdateOldDirty()
      return http.HttpResponse('Done scheduling old results.')

  # Create a task for the next dirty ResultTime to update.
  dirty_query = ResultTime.all(keys_only=True)
  dirty_query.filter('dirty =', True)
  dirty_query.ancestor(result_parent_key)
  next_result_time_key = dirty_query.get()
  if next_result_time_key:
    logging.debug('Schedule next ResultTime: %s', next_result_time_key)
    ResultParent.ScheduleUpdateDirty(
        next_result_time_key, category, count+1, task_name_prefix)
  else:
    logging.debug('Done with result_parent: %s', result_parent_key)
    ScheduleCategoryUpdate(result_parent_key)
    shardedcounter.increment(category)
  return http.HttpResponse('Done.') 
开发者ID:elsigh,项目名称:browserscope,代码行数:39,代码来源:manage_dirty.py

示例14: ScheduleUpdateDirty

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def ScheduleUpdateDirty(cls, result_time_key, category=None, count=0,
                          task_name_prefix=''):
    """Schedule UpdateStats for a given ResultTime.

    This gets handled by base.manage_dirty.UpdateDirty which
    then calls ResultTime.UpdateStats().

    Args:
      result_time_key: a dirty ResultTime key
      category: the category string
      count: index of ResultTime for logging purposes
      task_name_prefix: change a task name to retry tombstoned tasks
    """
    result_parent_key = result_time_key.parent()
    if not category:
      category = cls.get(result_parent_key).category
    task = taskqueue.Task(
        url='/admin/update_dirty/%s/%s/%d/%s' % (
            category, result_parent_key, count, result_time_key),
        name='%supdatedirty-%s' % (
            task_name_prefix, str(result_time_key).replace('_', '-under-')),
        params={'result_time_key': result_time_key, 'category': category,
                'count': count})

    attempt = 0
    while attempt < 3:
      try:
        task.add(queue_name='update-dirty')
        break
      except:
        attempt += 1

    if attempt == 3:
      logging.info('Cannot add task: %s:%s' % (sys.exc_type, sys.exc_value))
      return False
    return True 
开发者ID:elsigh,项目名称:browserscope,代码行数:38,代码来源:result.py

示例15: print_exc

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_type [as 别名]
def print_exc(limit=None, file=None):
    """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
    (In fact, it uses sys.exc_info() to retrieve the same information
    in a thread-safe way.)"""
    if file is None:
        file = sys.stderr
    try:
        etype, value, tb = sys.exc_info()
        print_exception(etype, value, tb, limit, file)
    finally:
        etype = value = tb = None 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:traceback.py


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