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


Python sys.exitfunc方法代码示例

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


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

示例1: test_comments

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_comments(self):
        b = """
            import sys # Foo
            sys.exitfunc = f # Blah
            """
        a = """
            import sys
            import atexit # Foo
            atexit.register(f) # Blah
            """
        self.check(b, a)

        b = """
            import apples, sys, crumbs, larry # Pleasant comments
            sys.exitfunc = func
            """
        a = """
            import apples, sys, crumbs, larry, atexit # Pleasant comments
            atexit.register(func)
            """
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:23,代码来源:test_fixers.py

示例2: start

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def start(argv=None):
    sys.exitfunc = lambda: sys.stderr.write("Shutting down...\n")

    if argv is None:
        argv = [
            "nosetests", "--cover-branches", "--with-coverage",
            "--cover-erase", "--verbose",
            "--cover-package=django_drf_filepond",
        ]
#        argv = [
#            "nosetests", "--cover-branches", "--verbose",
#            "--cover-package=django_drf_filepond",
#        ]

    nose.run_exit(argv=argv,
                  defaultTest=os.path.abspath(os.path.dirname(__file__))) 
开发者ID:ImperialCollegeLondon,项目名称:django-drf-filepond,代码行数:18,代码来源:runner.py

示例3: FoundPost

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def FoundPost(self, pkt):
        try:
            if pkt.load != None:
                self.PostPackages += 1
                self.ExtractInfo(pkt, 'Post')
                
        except Exception, e: 
	    e = str(e)
            if 'load' not in e:
                self.PostPackages -= 1
	    
		if 'byte' not in e: 
		    print '\n[X]%s' %putColor('Something went wrong', 'red'), ' '*100, '\n'
		    print putColor(traceback.format_exc(), 'white')
		    sys.exitfunc = self.Exit
		    sys.exit(1) 
开发者ID:Macr0phag3,项目名称:Sniffer,代码行数:18,代码来源:sniffer-v1.0.py

示例4: test_sys_override

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_sys_override(self):
        # be sure a preset sys.exitfunc is handled properly
        s = StringIO.StringIO()
        sys.stdout = sys.stderr = s
        save_handlers = atexit._exithandlers
        atexit._exithandlers = []
        exfunc = sys.exitfunc
        sys.exitfunc = self.h1
        reload(atexit)
        try:
            atexit.register(self.h2)
            atexit._run_exitfuncs()
        finally:
            sys.stdout = sys.__stdout__
            sys.stderr = sys.__stderr__
            atexit._exithandlers = save_handlers
            sys.exitfunc = exfunc
        self.assertEqual(s.getvalue(), "h2\nh1\n") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:20,代码来源:test_atexit.py

示例5: exec_

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def exec_(argv):  # never returns
    """Wrapper to os.execv which shows the command and runs any atexit handlers (for coverage's sake).
    Like os.execv, this function never returns.
    """
    # info('EXEC' + colorize(argv))  # TODO: debug logging by environment variable

    # in python3, sys.exitfunc has gone away, and atexit._run_exitfuncs seems to be the only pubic-ish interface
    #   https://hg.python.org/cpython/file/3.4/Modules/atexitmodule.c#l289
    import atexit
    atexit._run_exitfuncs()

    from os import execv
    execv(argv[0], argv) 
开发者ID:edmundmok,项目名称:mealpy,代码行数:15,代码来源:venv_update.py

示例6: test_simple

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

示例7: test_names_import

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_names_import(self):
        b = """
            import sys, crumbs
            sys.exitfunc = my_func
            """
        a = """
            import sys, crumbs, atexit
            atexit.register(my_func)
            """
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:12,代码来源:test_fixers.py

示例8: test_complex_expression

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_complex_expression(self):
        b = """
            import sys
            sys.exitfunc = do(d)/a()+complex(f=23, g=23)*expression
            """
        a = """
            import sys
            import atexit
            atexit.register(do(d)/a()+complex(f=23, g=23)*expression)
            """
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:13,代码来源:test_fixers.py

示例9: test_in_a_function

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_in_a_function(self):
        b = """
            import sys
            def f():
                sys.exitfunc = func
            """
        a = """
            import sys
            import atexit
            def f():
                atexit.register(func)
             """
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:15,代码来源:test_fixers.py

示例10: test_unchanged

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_unchanged(self):
        s = """f(sys.exitfunc)"""
        self.unchanged(s) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:5,代码来源:test_fixers.py

示例11: test_no_sys_import

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_no_sys_import(self):
        b = """sys.exitfunc = f"""
        a = """atexit.register(f)"""
        msg = ("Can't find sys import; Please add an atexit import at the "
            "top of your file.")
        self.warns(b, a, msg) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:8,代码来源:test_fixers.py

示例12: test_sys_override

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exitfunc [as 别名]
def test_sys_override(self):
        # be sure a preset sys.exitfunc is handled properly
        exfunc = sys.exitfunc
        sys.exitfunc = self.h1
        reload(atexit)
        try:
            atexit.register(self.h2)
            atexit._run_exitfuncs()
        finally:
            sys.exitfunc = exfunc
        self.assertEqual(self.subst_io.getvalue(), "h2\nh1\n") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_atexit.py


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