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


Python errno.ENOSYS属性代码示例

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


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

示例1: rlimit

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def rlimit(self, resource, limits=None):
            # If pid is 0 prlimit() applies to the calling process and
            # we don't want that. We should never get here though as
            # PID 0 is not supported on Linux.
            if self.pid == 0:
                raise ValueError("can't use prlimit() against PID 0 process")
            try:
                if limits is None:
                    # get
                    return cext.linux_prlimit(self.pid, resource)
                else:
                    # set
                    if len(limits) != 2:
                        raise ValueError(
                            "second argument must be a (soft, hard) tuple, "
                            "got %s" % repr(limits))
                    soft, hard = limits
                    cext.linux_prlimit(self.pid, resource, soft, hard)
            except OSError as err:
                if err.errno == errno.ENOSYS and pid_exists(self.pid):
                    # I saw this happening on Travis:
                    # https://travis-ci.org/giampaolo/psutil/jobs/51368273
                    raise ZombieProcess(self.pid, self._name, self._ppid)
                else:
                    raise 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:27,代码来源:_pslinux.py

示例2: construct_cfgs

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def construct_cfgs(**kargs):
    """construct_cfgs

Performs actions to construct either the setup.cfg (rpm) or stdeb.cfg (deb)
files as per the operating system specified.  This construction is done as
per the setup_requirements.txt file from within the working directory
specified.

This is a very tempermental function by design.  It intentionally exits
with a non-zero if/when an error has occurred on its own.  Therefore, it is
not suggested to use this function if you intend to get control back again.
    """
    docker_dir = _check_args(**kargs)
    if not docker_dir or not os.path.isdir(docker_dir):
        print("Unable to determine the %s/%s combo under supported versioning"
              % (kargs['operating_system'], kargs['version']))
        exit_cleanly(error_number=errno.ENOSYS)
    if kargs['operating_system'] == 'redhat':
        _build_setup_cfg(kargs['working_directory'])
    elif kargs['operating_system'] == 'ubuntu':
        _build_stdeb_cfg(kargs['working_directory'])
    else:
        print("Unsure of what to do... operating_system(%s) is not recognized!"
              % kargs['operating_system']) 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:26,代码来源:construct_setups.py

示例3: _build_stdeb_cfg

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def _build_stdeb_cfg(wkg):
    setup_cfg = glob.glob(wkg + "/*-dist/deb_dist/stdeb.cfg")
    setup = wkg + "/setup_requirements.txt"
    fmt = "%s (%s),"
    if not setup_cfg:
        dist = glob.glob(wkg + "/*-dist")
        if not dist:
            print(str(EnvironmentError("Unable to find a *-dist directory")))
            print("No dist directory under: " + wkg)
            exit_cleanly(error_number=errno.ENOSYS)
        deb_dist = dist[0] + "/deb_dist"
        try:
            os.mkdir(deb_dist)
        except IOError as Error:
            if not os.path.isdir(deb_dist):
                print(str(Error))
                print("Unable to determine the existence of: " + deb_dist)
                exit_cleanly(error_number=errno.ENOSYS)
        setup_cfg = deb_dist + "/stdeb.cfg"
    else:
        setup_cfg = setup_cfg[0]
    _construct_file(setup_cfg, setup, fmt, 'Depends:\n    ') 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:24,代码来源:construct_setups.py

示例4: test_rmlinkError

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def test_rmlinkError(self):
        """
        An exception raised by L{rmlink} other than C{ENOENT} is passed up
        to the caller of L{FilesystemLock.lock}.
        """
        def fakeRmlink(name):
            raise OSError(errno.ENOSYS, None)
        self.patch(lockfile, 'rmlink', fakeRmlink)

        def fakeKill(pid, signal):
            if signal != 0:
                raise OSError(errno.EPERM, None)
            if pid == 43125:
                raise OSError(errno.ESRCH, None)
        self.patch(lockfile, 'kill', fakeKill)

        lockf = self.mktemp()

        # Make it appear locked so it has to use readlink
        lockfile.symlink(str(43125), lockf)

        lock = lockfile.FilesystemLock(lockf)
        exc = self.assertRaises(OSError, lock.lock)
        self.assertEqual(exc.errno, errno.ENOSYS)
        self.assertFalse(lock.locked) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:27,代码来源:test_lockfile.py

示例5: _sem_open

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def _sem_open(name, value=None):
    """ Construct or retrieve a semaphore with the given name

    If value is None, try to retrieve an existing named semaphore.
    Else create a new semaphore with the given value
    """
    if value is None:
        handle = pthread.sem_open(ctypes.c_char_p(name), 0)
    else:
        handle = pthread.sem_open(ctypes.c_char_p(name), SEM_OFLAG, SEM_PERM,
                                  ctypes.c_int(value))

    if handle == SEM_FAILURE:
        e = ctypes.get_errno()
        if e == errno.EEXIST:
            raise FileExistsError("a semaphore named %s already exists" % name)
        elif e == errno.ENOENT:
            raise FileNotFoundError('cannot find semaphore named %s' % name)
        elif e == errno.ENOSYS:
            raise NotImplementedError('No semaphore implementation on this '
                                      'system')
        else:
            raiseFromErrno()

    return handle 
开发者ID:joblib,项目名称:loky,代码行数:27,代码来源:semlock.py

示例6: test_copy_sendfile

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def test_copy_sendfile(self):
        # try copying using sendfile
        with mock.patch.object(osfs, "sendfile") as sendfile:
            sendfile.side_effect = OSError(errno.ENOSYS, "sendfile not supported")
            self.test_copy()
        # check other errors are transmitted
        self.fs.touch("foo")
        with mock.patch.object(osfs, "sendfile") as sendfile:
            sendfile.side_effect = OSError(errno.EWOULDBLOCK)
            with self.assertRaises(OSError):
                self.fs.copy("foo", "foo_copy")
        # check parent exist and is dir
        with self.assertRaises(errors.ResourceNotFound):
            self.fs.copy("foo", "spam/eggs")
        with self.assertRaises(errors.DirectoryExpected):
            self.fs.copy("foo", "foo_copy/foo") 
开发者ID:PyFilesystem,项目名称:pyfilesystem2,代码行数:18,代码来源:test_osfs.py

示例7: test_os_error_not_implemented

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def test_os_error_not_implemented(self):
    with self.assertRaises(OSError) as cm:
      stubs.os_error_not_implemented()
    self.mox.VerifyAll()
    e = cm.exception
    self.assertEqual(errno.ENOSYS, e.errno)
    self.assertEqual('Function not implemented', e.strerror)
    self.assertIsNone(e.filename) 
开发者ID:elsigh,项目名称:browserscope,代码行数:10,代码来源:stubs_test.py

示例8: os_error_not_implemented

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def os_error_not_implemented(*unused_args, **unused_kwargs):
  raise OSError(errno.ENOSYS, 'Function not implemented') 
开发者ID:elsigh,项目名称:browserscope,代码行数:4,代码来源:stubs.py

示例9: test_statvfs_attributes

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def test_statvfs_attributes(self):
        try:
            result = os.statvfs(self.fname)
        except OSError, e:
            # On AtheOS, glibc always returns ENOSYS
            if e.errno == errno.ENOSYS:
                self.skipTest('glibc always returns ENOSYS on AtheOS')

        # Make sure direct access works 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_os.py

示例10: test_rlimit_zombie

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def test_rlimit_zombie(self):
        # Emulate a case where rlimit() raises ENOSYS, which may
        # happen in case of zombie process:
        # https://travis-ci.org/giampaolo/psutil/jobs/51368273
        with mock.patch("psutil._pslinux.cext.linux_prlimit",
                        side_effect=OSError(errno.ENOSYS, "")) as m:
            p = psutil.Process()
            p.name()
            with self.assertRaises(psutil.ZombieProcess) as exc:
                p.rlimit(psutil.RLIMIT_NOFILE)
            assert m.called
        self.assertEqual(exc.exception.pid, p.pid)
        self.assertEqual(exc.exception.name, p.name()) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:15,代码来源:test_linux.py

示例11: exit_cleanly

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def exit_cleanly(errnum=None):
    """exit_cleanly

Exits the runtime cleanly using SystemExit.  This is the official, handling
exception here as this is mostly meant to be a standalone script.
    """
    default = "An Unknown Error has Occurred!"
    cases = {errno.EINVAL: "Improper or invalid input value",
             errno.ESPIPE: "Could not complete action due to a broken" +
             " dependency",
             errno.ENOSYS: "Could not complete action due to unexpected setup",
             errno.EIO: "Could not access an expected file",
             errno.EPERM: "Could not access an item due to permissions issues",
             -1: default}
    help_stmt = """
%s [--opt [option]]
    With opts:
        working_directory - ONLY use this if you're overwriting `pwd`!
    """ % (sys.argv[0])
    if not errnum:
        errnum = 0
    elif not isinstance(errnum, int) and hasattr(errno, errnum):
        errnum = getattr(errno, errnum)
    try:
        errnum = int(errnum)
    except TypeError:
        errnum = -1
    if errnum == 0:
        help_stmt = ''
        stmt = "Successful in configuration!"
    elif errnum in cases:
        stmt = cases[errnum]
    else:
        stmt = default
    print("%s\n\n%s" % (stmt, help_stmt)) 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:37,代码来源:configure.py

示例12: get_env

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def get_env(working_directory=None):
    """get_env

This function grabs key/value pair items and assigns them for the the
config.JSON.  This essentially checks the environment for key locations within
the filesystem.
    """
    working = working_directory if working_directory else os.getcwd()
    dist_dirs = glob.glob(working + "/f5-*-dist")
    dist_dir_re = re.compile('/([^/]+)-dist/?')
    if dist_dirs:
        dist_dir = dist_dirs[0]
        match = dist_dir_re.search(dist_dir)
        if match:
            project_name = match.group(1)
        else:
            print("Unrecognized run location:\n" + working)
            exit_cleanly(errnum=errno.EIO)
    elif '-dist/scripts' in working:
        match = dist_dir_re.search(working)
        if match:
            project_name = match.group(1)
    else:
        print("Unable to determine the *-dist directory from " + working)
        exit_cleanly(errnum=errno.ENOSYS)
    stdeb_cfg = dist_dir + "/deb_dist/stdeb.cfg"
    setup_cfg = working + "/setup.cfg"
    rpm_stp_reqs = working + "/rpm_setup_requirements.txt"
    deb_stp_reqs = working + "/deb_setup_requirements.txt"
    scripts = dist_dir + "/scripts"
    env = {'working': working, 'dist_dir': dist_dir,
           'rpm_setup_requirements': rpm_stp_reqs, 
           'deb_setup_requirements': deb_stp_reqs, 
           'setup_cfg': setup_cfg, 'stdeb_cfg': stdeb_cfg,
           'scripts': scripts, 'project': project_name}
    return env 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:38,代码来源:configure.py

示例13: test_statvfs_attributes

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENOSYS [as 别名]
def test_statvfs_attributes(self):
        if not hasattr(os, "statvfs"):
            return

        try:
            result = os.statvfs(self.fname)
        except OSError, e:
            # On AtheOS, glibc always returns ENOSYS
            if e.errno == errno.ENOSYS:
                return

        # Make sure direct access works 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:14,代码来源:test_os.py


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