當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。