Python org.python.modules.posix.PosixModule.open() Examples
The following are 30
code examples of org.python.modules.posix.PosixModule.open().
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
org.python.modules.posix.PosixModule
, or try the search function
.
Example #1
Source File: sandbox.py From deepWordBug with Apache License 2.0 | 5 votes |
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)
Example #2
Source File: sandbox.py From stopstalk-deployment with MIT License | 5 votes |
def __enter__(self): self._copy(self) if _file: builtins.file = self._file builtins.open = self._open self._active = True
Example #3
Source File: sandbox.py From telegram-robot-rss with Mozilla Public License 2.0 | 5 votes |
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() # compile() function in Python 2.6 and 3.1 requires LF line endings. if sys.version_info[:2] < (2, 7) or sys.version_info[:2] >= (3, 0) and sys.version_info[:2] < (3, 2): script = script.replace(b'\r\n', b'\n') script = script.replace(b'\r', b'\n') if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)
Example #4
Source File: sandbox.py From stopstalk-deployment with MIT License | 5 votes |
def _open(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("open", path, mode, *args, **kw) return _open(path, mode, *args, **kw)
Example #5
Source File: sandbox.py From stopstalk-deployment with MIT License | 5 votes |
def open(self, file, flags, mode=0o777, *args, **kw): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode, *args, **kw) return _os.open(file, flags, mode, *args, **kw)
Example #6
Source File: sandbox.py From stopstalk-deployment with MIT License | 5 votes |
def __exit__(self, exc_type, exc_value, traceback): self._active = False if _file: builtins.file = _file builtins.open = _open self._copy(_os)
Example #7
Source File: sandbox.py From telegram-robot-rss with Mozilla Public License 2.0 | 5 votes |
def open(self, file, flags, mode=0o777, *args, **kw): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode, *args, **kw) return _os.open(file, flags, mode, *args, **kw)
Example #8
Source File: sandbox.py From telegram-robot-rss with Mozilla Public License 2.0 | 5 votes |
def _open(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("open", path, mode, *args, **kw) return _open(path, mode, *args, **kw)
Example #9
Source File: sandbox.py From telegram-robot-rss with Mozilla Public License 2.0 | 5 votes |
def __exit__(self, exc_type, exc_value, traceback): self._active = False if _file: builtins.file = _file builtins.open = _open self._copy(_os)
Example #10
Source File: sandbox.py From telegram-robot-rss with Mozilla Public License 2.0 | 5 votes |
def __enter__(self): self._copy(self) if _file: builtins.file = self._file builtins.open = self._open self._active = True
Example #11
Source File: sandbox.py From stopstalk-deployment with MIT License | 5 votes |
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)
Example #12
Source File: sandbox.py From deepWordBug with Apache License 2.0 | 5 votes |
def open(self, file, flags, mode=0o777, *args, **kw): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode, *args, **kw) return _os.open(file, flags, mode, *args, **kw)
Example #13
Source File: sandbox.py From deepWordBug with Apache License 2.0 | 5 votes |
def _open(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("open", path, mode, *args, **kw) return _open(path, mode, *args, **kw)
Example #14
Source File: sandbox.py From deepWordBug with Apache License 2.0 | 5 votes |
def __exit__(self, exc_type, exc_value, traceback): self._active = False if _file: builtins.file = _file builtins.open = _open self._copy(_os)
Example #15
Source File: sandbox.py From deepWordBug with Apache License 2.0 | 5 votes |
def __enter__(self): self._copy(self) if _file: builtins.file = self._file builtins.open = self._open self._active = True
Example #16
Source File: sandbox.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)
Example #17
Source File: sandbox.py From pex with Apache License 2.0 | 5 votes |
def open(self, file, flags, mode=0o777, *args, **kw): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode, *args, **kw) return _os.open(file, flags, mode, *args, **kw)
Example #18
Source File: sandbox.py From pex with Apache License 2.0 | 5 votes |
def _open(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("open", path, mode, *args, **kw) return _open(path, mode, *args, **kw)
Example #19
Source File: sandbox.py From pex with Apache License 2.0 | 5 votes |
def __exit__(self, exc_type, exc_value, traceback): self._active = False if _file: builtins.file = _file builtins.open = _open self._copy(_os)
Example #20
Source File: sandbox.py From pex with Apache License 2.0 | 5 votes |
def __enter__(self): self._copy(self) if _file: builtins.file = self._file builtins.open = self._open self._active = True
Example #21
Source File: sandbox.py From pex with Apache License 2.0 | 5 votes |
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)
Example #22
Source File: sandbox.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def open(self, file, flags, mode=0o777, *args, **kw): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode, *args, **kw) return _os.open(file, flags, mode, *args, **kw)
Example #23
Source File: sandbox.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def _open(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("open", path, mode, *args, **kw) return _open(path, mode, *args, **kw)
Example #24
Source File: sandbox.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def run(self, func): """Run 'func' under os sandboxing""" try: self._copy(self) if _file: builtins.file = self._file builtins.open = self._open self._active = True return func() finally: self._active = False if _file: builtins.file = _file builtins.open = _open self._copy(_os)
Example #25
Source File: sandbox.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() # compile() function in Python 2.6 and 3.1 requires LF line endings. if sys.version_info[:2] < (2, 7) or sys.version_info[:2] >= (3, 0) and sys.version_info[:2] < (3, 2): script = script.replace(b'\r\n', b'\n') script = script.replace(b'\r', b'\n') if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)
Example #26
Source File: sandbox.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def open(self, file, flags, mode=0o777, *args, **kw): """Called for low-level os.open()""" if flags & WRITE_FLAGS and not self._ok(file): self._violation("os.open", file, flags, mode, *args, **kw) return _os.open(file, flags, mode, *args, **kw)
Example #27
Source File: sandbox.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def _open(self, path, mode='r', *args, **kw): if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path): self._violation("open", path, mode, *args, **kw) return _open(path, mode, *args, **kw)
Example #28
Source File: sandbox.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def __exit__(self, exc_type, exc_value, traceback): self._active = False if _file: builtins.file = _file builtins.open = _open self._copy(_os)
Example #29
Source File: sandbox.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def __enter__(self): self._copy(self) if _file: builtins.file = self._file builtins.open = self._open self._active = True
Example #30
Source File: sandbox.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def _execfile(filename, globals, locals=None): """ Python 3 implementation of execfile. """ mode = 'rb' with open(filename, mode) as stream: script = stream.read() if locals is None: locals = globals code = compile(script, filename, 'exec') exec(code, globals, locals)