How to use the py.error.checked_call function in py

To help you get started, we’ve selected a few py examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github touilleMan / godot-python / tests / _lib_vendors / py / _path / local.py View on Github external
def rename(self, target):
        """ rename this path to target. """
        target = getattr(target, "strpath", target)
        return py.error.checked_call(os.rename, self.strpath, target)
github pytest-dev / pytest / py / _path / local.py View on Github external
def remove(self, rec=1, ignore_errors=False):
        """ remove a file or directory (or a directory tree if rec=1).
        if ignore_errors is True, errors while removing directories will
        be ignored.
        """
        if self.check(dir=1, link=0):
            if rec:
                # force remove of readonly files on windows
                if iswin32:
                    self.chmod(448, rec=1) # octcal 0700
                py.error.checked_call(py.std.shutil.rmtree, self.strpath,
                    ignore_errors=ignore_errors)
            else:
                py.error.checked_call(os.rmdir, self.strpath)
        else:
            if iswin32:
                self.chmod(448) # octcal 0700
            py.error.checked_call(os.remove, self.strpath)
github touilleMan / godot-python / tests / _lib_vendors / py / _path / local.py View on Github external
def samefile(self, other):
        """ return True if 'other' references the same file as 'self'.
        """
        other = getattr(other, "strpath", other)
        if not isabs(other):
            other = abspath(other)
        if self == other:
            return True
        if iswin32:
            return False # there is no samefile
        return py.error.checked_call(
                os.path.samefile, self.strpath, other)
github web-platform-tests / wpt / tools / py / py / _path / local.py View on Github external
def open(self, mode='r', ensure=False, encoding=None):
        """ return an opened file with the given mode.

        If ensure is True, create parent directories if needed.
        """
        if ensure:
            self.dirpath().ensure(dir=1)
        if encoding:
            return py.error.checked_call(io.open, self.strpath, mode, encoding=encoding)
        return py.error.checked_call(open, self.strpath, mode)
github touilleMan / godot-python / tests / _lib_vendors / py / _path / local.py View on Github external
def stat(self, raising=True):
        """ Return an os.stat() tuple. """
        if raising == True:
            return Stat(self, py.error.checked_call(os.stat, self.strpath))
        try:
            return Stat(self, os.stat(self.strpath))
        except KeyboardInterrupt:
            raise
        except Exception:
            return None
github catboost / catboost / contrib / python / py / py / _path / local.py View on Github external
def open(self, mode='r', ensure=False, encoding=None):
        """ return an opened file with the given mode.

        If ensure is True, create parent directories if needed.
        """
        if ensure:
            self.dirpath().ensure(dir=1)
        if encoding:
            return py.error.checked_call(io.open, self.strpath, mode, encoding=encoding)
        return py.error.checked_call(open, self.strpath, mode)
github spack / spack / lib / spack / external / py / _path / local.py View on Github external
def setmtime(self, mtime=None):
        """ set modification time for the given path.  if 'mtime' is None
        (the default) then the file's mtime is set to current time.

        Note that the resolution for 'mtime' is platform dependent.
        """
        if mtime is None:
            return py.error.checked_call(os.utime, self.strpath, mtime)
        try:
            return py.error.checked_call(os.utime, self.strpath, (-1, mtime))
        except py.error.EINVAL:
            return py.error.checked_call(os.utime, self.strpath, (self.atime(), mtime))
github servo / mozjs / mozjs / third_party / python / py / py / _path / local.py View on Github external
def stat(self, raising=True):
        """ Return an os.stat() tuple. """
        if raising == True:
            return Stat(self, py.error.checked_call(os.stat, self.strpath))
        try:
            return Stat(self, os.stat(self.strpath))
        except KeyboardInterrupt:
            raise
        except Exception:
            return None
github spack / spack / lib / spack / external / py / _path / local.py View on Github external
def open(self, mode='r', ensure=False, encoding=None):
        """ return an opened file with the given mode.

        If ensure is True, create parent directories if needed.
        """
        if ensure:
            self.dirpath().ensure(dir=1)
        if encoding:
            return py.error.checked_call(io.open, self.strpath, mode, encoding=encoding)
        return py.error.checked_call(open, self.strpath, mode)