• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python posix.stat_result函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中posix.stat_result函数的典型用法代码示例。如果您正苦于以下问题:Python stat_result函数的具体用法?Python stat_result怎么用?Python stat_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: stat

 def stat(self, path, followlinks=0, path_is_real=False):
     if not path_is_real:
         virtpath = self.split_virtual_path(path)
         if (virtpath.search_name != '' and
             virtpath.search_name not in [r[0] for r in
                                          self.search_request.get_searches()]):
             # raise OSError like os.stat does
             raise OSError('No such file or directory: "%s"' % path)
         if virtpath.search_relpath == '/' or virtpath.search_relpath == '':
             return posix.stat_result((
                 self.dir_perm,
                 0,  # st_ino
                 0,  # st_dev
                 0,  # st_nlink
                 0,  # st_uid
                 0,  # st_gid
                 4096,  # st_size
                 0,  # st_atime
                 0,  # st_mtime
                 0,  # st_ctime
             ))
         real_path = self.real_path(virtpath)
     else:
         real_path = path
     if followlinks:
         s = os.stat(real_path)
     else:
         s = os.lstat(real_path)
     if stat.S_ISDIR(s.st_mode):
         mode = self.dir_perm
     elif stat.S_ISREG(s.st_mode):
         mode = self.file_perm
     return posix.stat_result((mode,) + s[1:])
开发者ID:DimitriPapadopoulos,项目名称:rql_download,代码行数:33,代码来源:server.old.py


示例2: testFile

  def testFile(self):
    self.mox.StubOutWithMock(os, 'stat')
    os.stat('/home/ebroder/root.img').AndReturn(posix.stat_result([
      0100644, 0, 0, 0, 0, 0, 0, 0, 0, 0]))

    self.mox.ReplayAll()

    self.assertEqual(utils.diskIsBlockDevice('/home/ebroder/root.img'),
                     False)
开发者ID:ytrstu,项目名称:debmarshal,代码行数:9,代码来源:test_utils.py


示例3: testBlockDevice

  def testBlockDevice(self):
    self.mox.StubOutWithMock(os, 'stat')
    os.stat('/home/ebroder/root.img').AndReturn(posix.stat_result([
      # st_mode is the first argument
      060644, 0, 0, 0, 0, 0, 0, 0, 0, 0]))

    self.mox.ReplayAll()

    self.assertEqual(utils.diskIsBlockDevice('/home/ebroder/root.img'),
                     True)
开发者ID:ytrstu,项目名称:debmarshal,代码行数:10,代码来源:test_utils.py


示例4: stat

    def stat(self, path, followlinks=0, path_is_real=False):
        """ Method to access a path state.

        Parameters
        ----------
        path: str (mandatory)
            a path from which we want to get the associated statistics.
        followlinks: int (optional, default 0)
            if True the system will follow the symbolic links with the 'os.stat'
            method,
            otherwise the 'os.lstat' method is used.
        path_is_real: bool (optional, default False)
            if True the path really exists on the file system,
            otherwise we have a virtual cubicweb path.

        Returns
        -------
        out: posix.stat_result
            the same structure returned by a stat or lstat.     
        """
        if not path_is_real:
            virtpath = self.split_virtual_path(path)
            if (virtpath.search_name != '' and
               virtpath.search_name not in (self.all_cw_search_names +
                                            self.INSTANCE_NAMES)):
                # raise OSError like os.stat does
                raise OSError('No such file or directory: "%s"' % path)
            if virtpath.search_relpath == '/' or virtpath.search_relpath == '':
                return posix.stat_result((
                    self.dir_perm,
                    0,  # st_ino
                    0,  # st_dev
                    0,  # st_nlink
                    0,  # st_uid
                    0,  # st_gid
                    4096,  # st_size
                    0,  # st_atime
                    0,  # st_mtime
                    0,  # st_ctime
                ))
            real_path = self.real_path(virtpath)
        else:
            real_path = path
        if followlinks:
            s = os.stat(real_path)
        else:
            s = os.lstat(real_path)
        if stat.S_ISDIR(s.st_mode):
            mode = self.dir_perm
        elif stat.S_ISREG(s.st_mode):
            mode = self.file_perm
        return posix.stat_result((mode,) + s[1:])
开发者ID:rcherbonnier,项目名称:rql_download,代码行数:52,代码来源:server.py


示例5: stat

    def stat(self):
        if self.path == "":
            return posix.stat_result([stat.S_IFDIR + 0777, 0, 0, 0, 0, 0, 0, 0, 0, 0])
        for data in commands.ls_files(repo=self.repo, index=self.index, path=self.path, children=False):
            if data["path"] == self.path:
                mode = int(data["mode"], 8)
                size = commands.get_object_size(repo=self.repo, object=data["object"])
                return posix.stat_result([mode, 0, 0, 0, 0, 0, size, 0, 0, 0])
            else:
                # if current path has children, it must be a dir
                assert data["path"].startswith(self.path + "/")
                return posix.stat_result([stat.S_IFDIR + 0777, 0, 0, 0, 0, 0, 0, 0, 0, 0])

        # not found
        raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))
开发者ID:jisqyv,项目名称:pygitfs,代码行数:15,代码来源:indexfs.py


示例6: test_get_device_number

 def test_get_device_number(self, lstat):
     lstat.return_value = posix.stat_result([
         16877, 16, 51729L, 3, 0, 0, 217, 0, 1458086872, 1458086872
     ])
     major, minor = replace_osd.get_device_number(1)
     assert major == 202
     assert minor == 17
开发者ID:dosaboy,项目名称:charm-ceph-osd,代码行数:7,代码来源:test_replace_osd.py


示例7: stat_file_entity

    def stat_file_entity(self, binary_len=0):
        """ Return the file state.

        Parameters
        ----------
        binary_len: int (mandatory)
            the size of the file.

        Returns
        -------
        out: posix.stat_result
            the same structure returned by a stat or lstat.
        """
        return posix.stat_result((
            self.file_perm,
            0,  # st_ino
            0,  # st_dev
            0,  # st_nlink
            0,  # st_uid
            0,  # st_gid
            binary_len,  # st_size
            0,  # st_atime
            0,  # st_mtime
            0,  # st_ctime
        ))
开发者ID:rcherbonnier,项目名称:rql_download,代码行数:25,代码来源:server.py


示例8: fake_stat

 def fake_stat(arg):
     if arg in test_filepaths:
         faked = list(orig_os_stat(arg))
         faked[stat.ST_MTIME] = faked[stat.ST_MTIME] + 10
         return stat_result(faked)
     else:
         return orig_os_stat(arg)
开发者ID:mclabs,项目名称:kcdf_web,代码行数:7,代码来源:tests.py


示例9: getattr

 def getattr(self, path):
     for backup in self.backups:
         fpath = backup + path
         if os.path.exists(fpath):
             f_stat = os.lstat(fpath)
             mode = f_stat.st_mode
             if S_ISDIR(mode):
                 return f_stat
             else:
                 # it is a file, show as dir
                 f_stat = list(f_stat)
                 f_stat[0] = mode & 0b111111111111 | S_IFDIR
                 f_stat = stat_result(f_stat)
                 assert S_ISDIR(f_stat.st_mode)
                 parent = os.lstat(os.path.dirname(fpath))
                 # print 'done getattr - fake dir'
                 # print 'fstat:  ', f_stat
                 # print 'parent: ', parent
                 return parent  # XXX workaround
                 return f_stat
     # either the path does not exist or it actually is a file
     real_path = self._get_real_path(path)
     # print 'done getattr ', real_path
     if real_path:
         return os.lstat(real_path)
开发者ID:FlorianLudwig,项目名称:rsnapshotfs,代码行数:25,代码来源:mount.py


示例10: fake_lstat

 def fake_lstat(path):
     st_ino = 0
     st_dev = 0
     if path == ABSTFN:
         st_dev = 1
         st_ino = 1
     return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0))
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:7,代码来源:test_posixpath.py


示例11: fake_stat

 def fake_stat(arg):
     if arg == '/some/file':  # fake success
         return stat_result((16877, 2, 2049L,
                             23, 0, 0,
                             4096, 1381787843,
                             1381635971, 1381635971))
     else:
         return orig_os_stat(arg)
开发者ID:674009287,项目名称:nova,代码行数:8,代码来源:test_virt_disk.py


示例12: getattr

 def getattr(self, path):
     print '****************************************** getattr %s' % path
     stat = stub.getattr(sankalpa_fs_pb2.Path(path=path), _TIMEOUT_SECONDS)
     if stat.status != 0:
         print '****************************************** getattr status != 0 %s' % stat.status
         raise OSError(stat.status,"OSError", path)
     print '****************************************** server_stat.st_size %s' % stat.st_size
     return posix.stat_result((stat.st_mode, stat.st_ino, stat.st_dev, stat.st_nlink, stat.st_uid, stat.st_gid,
                                                     stat.st_size, stat.st_atime, stat.st_mtime, stat.st_ctime))
开发者ID:carriercomm,项目名称:SankalpaFS,代码行数:9,代码来源:sankalpa_fsc.py


示例13: getattr

 def getattr(self, path):
     print 'getattr %s' % path
     stats = _get_cache(_ATTR, path)
     if stats is None:
         stats = self._request(self._server.remote_getattr, path)
         _set_cache(_ATTR, path, stats)
     if stats is -1:
         return -errno.ENOENT
     return posix.stat_result(stats)
开发者ID:tchx84,项目名称:magic-store,代码行数:9,代码来源:magic-client.py


示例14: stat

 def stat(self):
     if not self._stat:
         e = OSError()
         e.errno = errno.ENOENT
         raise e
     if self._file:
         self._stat[6] = self._file.len
     ## bloat ... turning a list to a sequence to a stat_result object ;-)
     ## Well, StringIO implementation is not quite optimal anyway ;-)
     return posix.stat_result(list(self._stat))
开发者ID:nailor,项目名称:filesystem,代码行数:10,代码来源:inmem.py


示例15: dispatch

 def dispatch(me):
     stat_res = me._dispatch()
     # if os.path.split( me.q.path_in_aspect)[0] and isinstance( stat_res, stat_result):
     if Hardlink.getattr4symlink and isinstance(stat_res, stat_result):
         all = list(stat_res)
         log("original:", all)
         all[0] = all[0] | S_IFLNK
         log("new:", all)
         stat_res = stat_result(all)
     Hardlink.getattr4symlink = False
     return stat_res
开发者ID:hstanev,项目名称:fuselage,代码行数:11,代码来源:hardlink.py


示例16: fake_lstat

 def fake_lstat(path):
     st_ino = 0
     st_dev = 0
     if path.startswith(ABSTFN) and path != ABSTFN:
         # ismount tries to read something inside the ABSTFN directory;
         # simulate this being forbidden (no read permission).
         raise OSError("Fake [Errno 13] Permission denied")
     if path == ABSTFN:
         st_dev = 1
         st_ino = 1
     return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0))
开发者ID:1st1,项目名称:cpython,代码行数:11,代码来源:test_posixpath.py


示例17: myLstat

 def myLstat(path):
     s = origLstat(path)
     if path == fobj.name:
         # Convert the stat info to a tuple
         s = tuple(s)
         # Replace st_uid and st_gid
         s = s[:4] + (uid, gid) + s[6:]
         # Convert to stat_result
         s = posix.stat_result(s)
         self.assertEqual(s.st_uid, uid)
         self.assertEqual(s.st_gid, gid)
     return s
开发者ID:pombredanne,项目名称:conary,代码行数:12,代码来源:filestest.py


示例18: stat_file_entity

 def stat_file_entity(self, binary_len=0):
     return posix.stat_result((
         self.file_perm,
         0,  # st_ino
         0,  # st_dev
         0,  # st_nlink
         0,  # st_uid
         0,  # st_gid
         binary_len,  # st_size
         0,  # st_atime
         0,  # st_mtime
         0,  # st_ctime
     ))
开发者ID:DimitriPapadopoulos,项目名称:rql_download,代码行数:13,代码来源:server.old.py


示例19: fgetattr

 def fgetattr( self, file_descriptor, path ):
     logging.debug( 'FGETATTR' )
     
     try:
         op_result = os.fstat( file_descriptor )
         file_size = self.file_table[ path + 'size' ]
         stats_list = list( op_result )
         stats_list[ stat.ST_SIZE ] = file_size
         op_result = posix.stat_result( stats_list )
     except:
         op_result = -errno.EACCES
     
     return op_result
开发者ID:jpredmann,项目名称:mushroomfs,代码行数:13,代码来源:MushroomMaster.py


示例20: stat

 def stat(self, path):
     """Return stat result."""
     local_path = self.resolve(path)
     cmd = 'stat --printf="%f %i %d %h %u %g %s %X %Y %W" {path}' \
           .format(path=local_path)
     result = self.xal_session.sh.run(cmd)
     if not result.succeeded:
         if not self.exists(path):
             raise OSError(path)
         raise Exception()
     result = result.stdout.split(" ")
     result[0] = int(result[0], base=16)
     result = map(int, result)
     return posix.stat_result(result)
开发者ID:adamchainz,项目名称:xal,代码行数:14,代码来源:fabric.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python posixpath.abspath函数代码示例发布时间:2022-05-25
下一篇:
Python posix.stat函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap