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


Python exceptions.SystemExit方法代码示例

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


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

示例1: handle_with_processors

# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import SystemExit [as 别名]
def handle_with_processors(self):
        def process(processors):
            try:
                if processors:
                    p, processors = processors[0], processors[1:]
                    return p(lambda: process(processors))
                else:
                    return self.handle()
            except web.HTTPError:
                raise
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                print >> web.debug, traceback.format_exc()
                raise self.internalerror()
        
        # processors must be applied in the resvere order. (??)
        return process(self.processors) 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:20,代码来源:application.py

示例2: get_argparse_error

# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import SystemExit [as 别名]
def get_argparse_error(args):
    """When argparse raises an error it writes to stderr and does a sys.exit"""
    with mock.patch('sys.stderr', io.StringIO()) as output:
        try:
            result = main([sys.argv[0], ] + args)
            raise Exception("Expected a fail")
        except exc.SystemExit:
            pass
    return output.getvalue() 
开发者ID:greenaddress,项目名称:garecovery,代码行数:11,代码来源:util.py

示例3: run_test_pkg

# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import SystemExit [as 别名]
def run_test_pkg(pkg_name, do_not_run=[]):
    log_info("--%s package----------------------------------------" % pkg_name)
    
    #Determine where the test package is and ensure it exists
    log_debug("The current working directory is " + __CWD)
    pkg_dir_name = os.path.join(__CWD, pkg_name.replace(".", os.sep))
    log_debug("The test package location is " + pkg_dir_name)
    if not file_exists(os.path.join(pkg_dir_name, "__init__.py")):
        err_msg = "No such test package: %s" % pkg_dir_name
        log_error(err_msg)
        raise Exception(err_msg)
    
    #Build up a list of all subpackages/modules contained in test package
    subpkg_list = [x for x in os.listdir(pkg_dir_name) if not x.endswith(".py") and file_exists(os.path.join(pkg_dir_name, x, "__init__.py"))]
    log_debug("Subpackages found: %s" % (str(subpkg_list)))
    module_list = [x for x in os.listdir(pkg_dir_name) if x.endswith(".py") and x!="__init__.py"]
    log_debug("Modules found: %s" % (str(module_list)))
    if len(module_list)==0:
        log_warn("No test modules found in the %s test package!" % pkg_name)
        print ""
    
    if options.GEN_TEST_PLAN:
        l.info("Generating test documentation for '%s' package..." % pkg_name)
        pydoc.writedoc(pkg_name)
    
    #Import all tests
    for test_module in module_list:
        test_module = pkg_name + "." + test_module.split(".py", 1)[0]
        
        if options.RUN_TESTS:
            if test_module in do_not_run:
                log_info("--Testing of %s has been disabled!" % test_module)
                continue
            log_info("--Testing %s..." % test_module)
            try:
                __import__(test_module)
            except SystemExit, e:
                if e.code!=0: 
                    raise Exception("Importing '%s' caused an unexpected exit code: %s" % (test_module, str(e.code)))
            print ""
        
        if options.GEN_TEST_PLAN:
            l.info("Generating test documentation for '%s' module..." % test_module)
            pydoc.writedoc(test_module)

    
    #Recursively import subpackages 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:49,代码来源:runner.py

示例4: run_test_pkg

# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import SystemExit [as 别名]
def run_test_pkg(pkg_name, do_not_run=[]):
    log_info("--%s package----------------------------------------" % pkg_name)
    
    #Determine where the test package is and ensure it exists
    log_debug("The current working directory is " + __CWD)
    pkg_dir_name = os.path.join(__CWD, pkg_name.replace(".", os.sep))
    log_debug("The test package location is " + pkg_dir_name)
    if not file_exists(os.path.join(pkg_dir_name, "__init__.py")):
        err_msg = "No such test package: %s" % pkg_dir_name
        log_error(err_msg)
        raise Exception(err_msg)
    
    #Build up a list of all subpackages/modules contained in test package
    subpkg_list = [x for x in os.listdir(pkg_dir_name) if not x.endswith(".py") and file_exists(os.path.join(pkg_dir_name, x, "__init__.py"))]
    log_debug("Subpackages found: %s" % (str(subpkg_list)))
    module_list = [x for x in os.listdir(pkg_dir_name) if x.endswith(".py") and x!="__init__.py"]
    log_debug("Modules found: %s" % (str(module_list)))
    if len(module_list)==0:
        log_warn("No test modules found in the %s test package!" % pkg_name)
        print("")
    
    if options.GEN_TEST_PLAN:
        l.info("Generating test documentation for '%s' package..." % pkg_name)
        pydoc.writedoc(pkg_name)
    
    #Import all tests
    for test_module in module_list:
        test_module = pkg_name + "." + test_module.split(".py", 1)[0]
        
        if options.RUN_TESTS:
            if test_module in do_not_run:
                log_info("--Testing of %s has been disabled!" % test_module)
                continue
            log_info("--Testing %s..." % test_module)
            try:
                __import__(test_module)
            except SystemExit as e:
                if e.code!=0: 
                    raise Exception("Importing '%s' caused an unexpected exit code: %s" % (test_module, str(e.code)))
            print("")
        
        if options.GEN_TEST_PLAN:
            l.info("Generating test documentation for '%s' module..." % test_module)
            pydoc.writedoc(test_module)

    
    #Recursively import subpackages
    for subpkg in subpkg_list:
        run_test_pkg(pkg_name + "." + subpkg) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:51,代码来源:runner.py


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