Python setuptools.sandbox 模块,run() 实例源码

我们从Python开源项目中,提取了以下29个代码示例,用于说明如何使用setuptools.sandbox.run()

项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:NeuroMobile    作者:AndrewADykman    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:browser_vuln_check    作者:lcatro    | 项目源码 | 文件源码
def test_sandbox_violation_raised_hiding_setuptools(self, tmpdir):
        """
        When in a sandbox with setuptools hidden, a SandboxViolation
        should reflect a proper exception and not be wrapped in
        an UnpickleableException.
        """
        def write_file():
            "Trigger a SandboxViolation by writing outside the sandbox"
            with open('/etc/foo', 'w'):
                pass
        sandbox = DirectorySandbox(str(tmpdir))
        with pytest.raises(setuptools.sandbox.SandboxViolation) as caught:
            with setuptools.sandbox.save_modules():
                setuptools.sandbox.hide_setuptools()
                sandbox.run(write_file)

        cmd, args, kwargs = caught.value.args
        assert cmd == 'open'
        assert args == ('/etc/foo', 'w')
        assert kwargs == {}
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:BD_T2    作者:jfmolano1587    | 项目源码 | 文件源码
def test_win32com(self):
            """
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            """
            import win32com
            gen_py = win32com.__gen_path__
            target = os.path.join(gen_py, 'test_write')
            sandbox = DirectorySandbox(self.dir)
            try:
                try:
                    sandbox.run(self._file_writer(target))
                except SandboxViolation:
                    self.fail("Could not create gen_py file due to SandboxViolation")
            finally:
                if os.path.exists(target): os.remove(target)
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:NeuroMobile    作者:AndrewADykman    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def test_devnull(self, tmpdir):
        sandbox = DirectorySandbox(str(tmpdir))
        sandbox.run(self._file_writer(os.devnull))
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def test_win32com(self, tmpdir):
        """
        win32com should not be prevented from caching COM interfaces
        in gen_py.
        """
        win32com = pytest.importorskip('win32com')
        gen_py = win32com.__gen_path__
        target = os.path.join(gen_py, 'test_write')
        sandbox = DirectorySandbox(str(tmpdir))
        try:
            # attempt to create gen_py file
            sandbox.run(self._file_writer(target))
        finally:
            if os.path.exists(target):
                os.remove(target)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:browser_vuln_check    作者:lcatro    | 项目源码 | 文件源码
def test_devnull(self, tmpdir):
        sandbox = DirectorySandbox(str(tmpdir))
        sandbox.run(self._file_writer(os.devnull))
项目:browser_vuln_check    作者:lcatro    | 项目源码 | 文件源码
def test_win32com(self, tmpdir):
        """
        win32com should not be prevented from caching COM interfaces
        in gen_py.
        """
        win32com = pytest.importorskip('win32com')
        gen_py = win32com.__gen_path__
        target = os.path.join(gen_py, 'test_write')
        sandbox = DirectorySandbox(str(tmpdir))
        try:
            # attempt to create gen_py file
            sandbox.run(self._file_writer(target))
        finally:
            if os.path.exists(target):
                os.remove(target)
项目:facebook-face-recognition    作者:mathur    | 项目源码 | 文件源码
def test_devnull(self, tmpdir):
        sandbox = DirectorySandbox(str(tmpdir))
        sandbox.run(self._file_writer(os.devnull))
项目:facebook-face-recognition    作者:mathur    | 项目源码 | 文件源码
def test_win32com(self, tmpdir):
        """
        win32com should not be prevented from caching COM interfaces
        in gen_py.
        """
        win32com = pytest.importorskip('win32com')
        gen_py = win32com.__gen_path__
        target = os.path.join(gen_py, 'test_write')
        sandbox = DirectorySandbox(str(tmpdir))
        try:
            # attempt to create gen_py file
            sandbox.run(self._file_writer(target))
        finally:
            if os.path.exists(target):
                os.remove(target)
项目:MyFriend-Rob    作者:lcheniv    | 项目源码 | 文件源码
def test_devnull(self, tmpdir):
        sandbox = DirectorySandbox(str(tmpdir))
        sandbox.run(self._file_writer(os.devnull))
项目:MyFriend-Rob    作者:lcheniv    | 项目源码 | 文件源码
def test_win32com(self, tmpdir):
        """
        win32com should not be prevented from caching COM interfaces
        in gen_py.
        """
        win32com = pytest.importorskip('win32com')
        gen_py = win32com.__gen_path__
        target = os.path.join(gen_py, 'test_write')
        sandbox = DirectorySandbox(str(tmpdir))
        try:
            # attempt to create gen_py file
            sandbox.run(self._file_writer(target))
        finally:
            if os.path.exists(target):
                os.remove(target)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))
项目:BD_T2    作者:jfmolano1587    | 项目源码 | 文件源码
def test_devnull(self):
        if sys.version < '2.4':
            return
        sandbox = DirectorySandbox(self.dir)
        sandbox.run(self._file_writer(os.devnull))