Python exceptions.SystemExit() Examples
The following are 6
code examples of exceptions.SystemExit().
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
exceptions
, or try the search function
.
Example #1
Source File: application.py From nightmare with GNU General Public License v2.0 | 6 votes |
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)
Example #2
Source File: application.py From bokken with GNU General Public License v2.0 | 6 votes |
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)
Example #3
Source File: application.py From cosa-nostra with GNU General Public License v3.0 | 6 votes |
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)
Example #4
Source File: util.py From garecovery with MIT License | 5 votes |
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()
Example #5
Source File: runner.py From ironpython2 with Apache License 2.0 | 4 votes |
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
Example #6
Source File: runner.py From ironpython3 with Apache License 2.0 | 4 votes |
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)