Python sys.exitfunc() Examples

The following are 30 code examples of sys.exitfunc(). 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 sys , or try the search function .
Example #1
Source File: test_fixers.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
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) 
Example #2
Source File: test_fixers.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: test_fixers.py    From datafari with Apache License 2.0 6 votes vote down vote up
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) 
Example #4
Source File: test_fixers.py    From Computable with MIT License 6 votes vote down vote up
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) 
Example #5
Source File: test_fixers.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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) 
Example #6
Source File: runner.py    From django-drf-filepond with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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__))) 
Example #7
Source File: test_fixers.py    From oss-ftp with MIT License 6 votes vote down vote up
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) 
Example #8
Source File: sniffer-v1.0.py    From Sniffer with MIT License 6 votes vote down vote up
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) 
Example #9
Source File: test_fixers.py    From Imogen with MIT License 6 votes vote down vote up
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) 
Example #10
Source File: test_fixers.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #11
Source File: test_atexit.py    From medicare-demo with Apache License 2.0 6 votes vote down vote up
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") 
Example #12
Source File: test_fixers.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
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) 
Example #13
Source File: test_fixers.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #14
Source File: test_fixers.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_simple(self):
        b = """
            import sys
            sys.exitfunc = my_atexit
            """
        a = """
            import sys
            import atexit
            atexit.register(my_atexit)
            """
        self.check(b, a) 
Example #15
Source File: test_fixers.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #16
Source File: test_fixers.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #17
Source File: test_fixers.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #18
Source File: test_fixers.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_unchanged(self):
        s = """f(sys.exitfunc)"""
        self.unchanged(s) 
Example #19
Source File: test_fixers.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_unchanged(self):
        s = """f(sys.exitfunc)"""
        self.unchanged(s) 
Example #20
Source File: test_fixers.py    From datafari with Apache License 2.0 5 votes vote down vote up
def test_simple(self):
        b = """
            import sys
            sys.exitfunc = my_atexit
            """
        a = """
            import sys
            import atexit
            atexit.register(my_atexit)
            """
        self.check(b, a) 
Example #21
Source File: test_fixers.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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) 
Example #22
Source File: test_fixers.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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) 
Example #23
Source File: test_fixers.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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) 
Example #24
Source File: test_fixers.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_simple(self):
        b = """
            import sys
            sys.exitfunc = my_atexit
            """
        a = """
            import sys
            import atexit
            atexit.register(my_atexit)
            """
        self.check(b, a) 
Example #25
Source File: test_fixers.py    From Imogen with MIT License 5 votes vote down vote up
def test_unchanged(self):
        s = """f(sys.exitfunc)"""
        self.unchanged(s) 
Example #26
Source File: test_fixers.py    From Imogen with MIT License 5 votes vote down vote up
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) 
Example #27
Source File: test_fixers.py    From Imogen with MIT License 5 votes vote down vote up
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) 
Example #28
Source File: test_fixers.py    From Imogen with MIT License 5 votes vote down vote up
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) 
Example #29
Source File: test_fixers.py    From Imogen with MIT License 5 votes vote down vote up
def test_simple(self):
        b = """
            import sys
            sys.exitfunc = my_atexit
            """
        a = """
            import sys
            import atexit
            atexit.register(my_atexit)
            """
        self.check(b, a) 
Example #30
Source File: test_fixers.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_unchanged(self):
        s = """f(sys.exitfunc)"""
        self.unchanged(s)