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


Python stat.S_IFSOCK属性代码示例

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


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

示例1: setUp

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def setUp(self):
        self.loop = self.new_test_loop()
        self.protocol = test_utils.make_test_protocol(asyncio.BaseProtocol)
        self.pipe = mock.Mock(spec_set=io.RawIOBase)
        self.pipe.fileno.return_value = 5

        blocking_patcher = mock.patch('asyncio.unix_events._set_nonblocking')
        blocking_patcher.start()
        self.addCleanup(blocking_patcher.stop)

        fstat_patcher = mock.patch('os.fstat')
        m_fstat = fstat_patcher.start()
        st = mock.Mock()
        st.st_mode = stat.S_IFSOCK
        m_fstat.return_value = st
        self.addCleanup(fstat_patcher.stop) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_unix_events.py

示例2: setUp

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def setUp(self):
        super().setUp()
        self.loop = self.new_test_loop()
        self.protocol = test_utils.make_test_protocol(asyncio.BaseProtocol)
        self.pipe = mock.Mock(spec_set=io.RawIOBase)
        self.pipe.fileno.return_value = 5

        blocking_patcher = mock.patch('asyncio.unix_events._set_nonblocking')
        blocking_patcher.start()
        self.addCleanup(blocking_patcher.stop)

        fstat_patcher = mock.patch('os.fstat')
        m_fstat = fstat_patcher.start()
        st = mock.Mock()
        st.st_mode = stat.S_IFSOCK
        m_fstat.return_value = st
        self.addCleanup(fstat_patcher.stop) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:19,代码来源:test_unix_events.py

示例3: test_unix_blocks

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_unix_blocks(self):

        inode = self.db.rowid("INSERT INTO inodes (mode,uid,gid,mtime_ns,atime_ns,ctime_ns,refcount) "
                              "VALUES (?,?,?,?,?,?,?)",
                              (stat.S_IFSOCK | stat.S_IRUSR | stat.S_IWUSR,
                               os.getuid(), os.getgid(), time_ns(), time_ns(), time_ns(), 1))
        self._link(b'test-entry', inode)

        self.fsck.found_errors = False
        self.fsck.check_unix()
        self.assertFalse(self.fsck.found_errors)

        obj_id = self.db.rowid('INSERT INTO objects (refcount, size) VALUES(1, 32)')
        block_id = self.db.rowid('INSERT INTO blocks (refcount, obj_id, size) VALUES(?,?,?)',
                                 (1, obj_id, 0))

        self.db.execute('INSERT INTO inode_blocks (inode, blockno, block_id) VALUES(?,?,?)',
                        (inode, 1, block_id))

        self.fsck.check_unix()
        self.assertTrue(self.fsck.found_errors) 
开发者ID:s3ql,项目名称:s3ql,代码行数:23,代码来源:t3_fsck.py

示例4: get_sock

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def get_sock(self, major, minor):
        return self.get(S_IFSOCK, self._rdev(major, minor)) 
开发者ID:kdart,项目名称:pycopia,代码行数:4,代码来源:devdb.py

示例5: is_sockfile

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def is_sockfile(self, path):
        """Returns whether or not the given path is a socket file."""
        try:
            s = os.stat(path)
        except OSError as error:
            (no, e) = error.args
            if no == errno.ENOENT:
                return False
            self._logger.error("warning: couldn't stat(%r): %s" % (path, e))
            return None
        return s.st_mode & stat.S_IFSOCK == stat.S_IFSOCK 
开发者ID:scalyr,项目名称:scalyr-agent-2,代码行数:13,代码来源:mysql_monitor.py

示例6: test_socketfile_failure_false

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_socketfile_failure_false(check_swarm, fs):
    fs.create_file('/tmp/socket', contents='', st_mode=(stat.S_IFSOCK | 0o666))
    args = ('--swarm', '--connection', '/tmp/socket')
    result = check_swarm.process_args(args=args)
    assert not check_swarm.socketfile_permissions_failure(parsed_args=result) 
开发者ID:timdaman,项目名称:check_docker,代码行数:7,代码来源:test_check_swarm.py

示例7: test_socketfile_failure_unwriteable

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_socketfile_failure_unwriteable(check_swarm, fs):
    fs.create_file('/tmp/unwritable', contents='', st_mode=(stat.S_IFSOCK | 0o000))
    args = ('--swarm', '--connection', '/tmp/unwritable')
    result = check_swarm.process_args(args=args)
    assert check_swarm.socketfile_permissions_failure(parsed_args=result) 
开发者ID:timdaman,项目名称:check_docker,代码行数:7,代码来源:test_check_swarm.py

示例8: test_socketfile_failure_unreadable

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_socketfile_failure_unreadable(check_swarm, fs):
    fs.create_file('/tmp/unreadable', contents='', st_mode=(stat.S_IFSOCK | 0o000))
    args = ('--swarm', '--connection', '/tmp/unreadable')
    result = check_swarm.process_args(args=args)
    assert check_swarm.socketfile_permissions_failure(parsed_args=result) 
开发者ID:timdaman,项目名称:check_docker,代码行数:7,代码来源:test_check_swarm.py

示例9: test_socketfile_failure_http

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_socketfile_failure_http(check_swarm, fs):
    fs.create_file('/tmp/http', contents='', st_mode=(stat.S_IFSOCK | 0o000))
    args = ('--swarm', '--connection', 'http://127.0.0.1')
    result = check_swarm.process_args(args=args)
    assert not check_swarm.socketfile_permissions_failure(parsed_args=result) 
开发者ID:timdaman,项目名称:check_docker,代码行数:7,代码来源:test_check_swarm.py

示例10: test_check_swarm_called

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_check_swarm_called(check_swarm, fs):
    fs.create_file(check_swarm.DEFAULT_SOCKET, contents='', st_mode=(stat.S_IFSOCK | 0o666))
    args = ['--swarm']
    with patch('check_docker.check_swarm.check_swarm') as patched:
        check_swarm.perform_checks(args)
        assert patched.call_count == 1 
开发者ID:timdaman,项目名称:check_docker,代码行数:8,代码来源:test_check_swarm.py

示例11: test_check_swarm_results_CRITICAL

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_check_swarm_results_CRITICAL(check_swarm, fs):
    fs.create_file(check_swarm.DEFAULT_SOCKET, contents='', st_mode=(stat.S_IFSOCK | 0o666))
    args = ['--swarm']
    with patch('check_docker.check_swarm.get_swarm_status', return_value=406):
        check_swarm.perform_checks(args)
        assert check_swarm.rc == cs.CRITICAL_RC 
开发者ID:timdaman,项目名称:check_docker,代码行数:8,代码来源:test_check_swarm.py

示例12: test_check_service_called

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_check_service_called(check_swarm, fs):
    service_info = {'Spec': {'Mode': {'Replicated': {'Replicas': 1}}}}

    fs.create_file(check_swarm.DEFAULT_SOCKET, contents='', st_mode=(stat.S_IFSOCK | 0o666))
    args = ['--service', 'FOO']
    with patch('check_docker.check_swarm.get_services', return_value=[service_info]):
        with patch('check_docker.check_swarm.check_service') as patched:
            check_swarm.perform_checks(args)
            assert patched.call_count == 1 
开发者ID:timdaman,项目名称:check_docker,代码行数:11,代码来源:test_check_swarm.py

示例13: test_check_services_routing_global

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_check_services_routing_global(check_swarm, service_info, expected_func, expected_args, fs):
    fs.create_file(check_swarm.DEFAULT_SOCKET, contents='', st_mode=(stat.S_IFSOCK | 0o666))
    with patch('check_docker.check_swarm.get_service_info', return_value=(service_info, 999)), \
         patch('check_docker.check_swarm.{}'.format(expected_func)) as patched:
        check_swarm.check_service('FOO')
        assert patched.call_count == 1
        assert patched.call_args == call(**expected_args) 
开发者ID:timdaman,项目名称:check_docker,代码行数:9,代码来源:test_check_swarm.py

示例14: test_check_services_global_ignore_paused

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_check_services_global_ignore_paused(check_swarm, fs):
    fs.create_file(check_swarm.DEFAULT_SOCKET, contents='', st_mode=(stat.S_IFSOCK | 0o666))
    service_info = {'Spec': {'Mode': {'Global': {}}}}

    with patch('check_docker.check_swarm.get_service_info', return_value=(service_info, 999)), \
         patch('check_docker.check_swarm.process_global_service') as patched:
        check_swarm.check_service('FOO', True)
        assert patched.call_count == 1
        assert patched.call_args == call(name='FOO', ignore_paused=True) 
开发者ID:timdaman,项目名称:check_docker,代码行数:11,代码来源:test_check_swarm.py

示例15: test_process_global_service

# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_IFSOCK [as 别名]
def test_process_global_service(check_swarm, fs, node_list, service_list, ignore_paused, expected_rc):
    fs.create_file(check_swarm.DEFAULT_SOCKET, contents='', st_mode=(stat.S_IFSOCK | 0o666))
    with patch('check_docker.check_swarm.get_nodes', return_value=(node_list, 999)) as patched_get_nodes, \
            patch('check_docker.check_swarm.get_service_tasks', return_value=service_list) as patched_get_service_tasks:
        check_swarm.process_global_service('FOO', ignore_paused)
        assert patched_get_nodes.call_count == 1
        assert patched_get_service_tasks.call_count == 1
        assert check_swarm.rc == expected_rc 
开发者ID:timdaman,项目名称:check_docker,代码行数:10,代码来源:test_check_swarm.py


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