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


Python Drive.stat方法代码示例

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


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

示例1: test_stat

# 需要导入模块: from libgsync.drive import Drive [as 别名]
# 或者: from libgsync.drive.Drive import stat [as 别名]
    def test_stat(self):
        drive = Drive()

        info = drive.stat("drive://")
        self.assertIsNotNone(info)
        self.assertEqual("root", info.id)

        info = drive.stat("drive://unittest/")
        self.assertIsNotNone(info)
        self.assertIsNotNone(info.id)
        self.assertEqual(info.title, "unittest")
开发者ID:feyrune,项目名称:gsync,代码行数:13,代码来源:unittests.py

示例2: get_info

# 需要导入模块: from libgsync.drive import Drive [as 别名]
# 或者: from libgsync.drive.Drive import stat [as 别名]
    def get_info(self, path = None):
        path = self.get_path(path)

        debug("Fetching remote file metadata: %s" % repr(path))

        # The Drive() instance is self caching.
        drive = Drive()

        info = drive.stat(path)
        if info is None:
            debug("File not found: %s" % repr(path))
            return None

        info = SyncFileInfo(**info)
        debug("Remote file = %s" % repr(info), 3)
        debug("Remote mtime: %s" % repr(info.modifiedDate))

        return info
开发者ID:GyroLand,项目名称:gsync,代码行数:20,代码来源:__init__.py

示例3: Crawler

# 需要导入模块: from libgsync.drive import Drive [as 别名]
# 或者: from libgsync.drive.Drive import stat [as 别名]
class Crawler(object):
    """
    Crawler class that defines an instance of a crawler that is bound to
    either a local or remote filesystem.
    """

    def __init__(self, src, dst):
        self._dev = None
        self._src = None
        self._dst = None
        self._sync = None

        force_dest_file = GsyncOptions.force_dest_file

        self._drive = Drive()

        if self._drive.is_drivepath(src):
            self._walk_callback = bind("walk", self._drive)
            self._src = self._drive.normpath(src)
            info = self._drive.stat(self._src)

            if info and info.mimeType != MimeTypes.FOLDER:
                debug("Source is not a directory, forcing dest file: %s" %
                      (repr(self._src)))
                force_dest_file = True
        else:
            self._walk_callback = os_walk_wrapper
            self._src = os.path.normpath(src)
            st_info = os.stat(self._src)

            if os.path.isfile(self._src):
                debug("Source is not a directory, forcing dest file: %s" %
                      (repr(self._src)))
                force_dest_file = True

            if GsyncOptions.one_file_system:
                self._dev = st_info.st_dev

        if self._drive.is_drivepath(dst):
            self._dst = self._drive.normpath(dst)
            info = self._drive.stat(self._dst)

            if info and info.mimeType == MimeTypes.FOLDER:
                debug("Dest is a directory, not forcing dest file: %s" % (repr(
                    self._dst)))
                force_dest_file = False
        else:
            self._dst = os.path.normpath(dst)
            if os.path.isdir(self._dst):
                debug("Dest is a directory, not forcing dest file: %s" % (repr(
                    self._dst)))
                force_dest_file = False

        if src[-1] == "/":
            self._src += "/"

        if dst[-1] == "/":
            self._dst += "/"
            debug("Dest has trailing slash, not forcing dest file: %s" %
                  (self._dst))
            force_dest_file = False

        # Only update if not already set.
        if GsyncOptions.force_dest_file is None:
            debug("force_dest_file = %s" % force_dest_file)
            GsyncOptions.force_dest_file = force_dest_file

        #super(Crawler, self).__init__(name = "Crawler: %s" % src)

    def _dev_check(self, device_id, path):
        """
        Checks if the path provided resides on the device specified by the
        device ID provided.

        @param {int} device_id    The device ID.
        @param {String} path      Path to verify.

        @return {bool} True if the path resides on device with the
                       specified ID.
        """
        if device_id is not None:
            st_info = os.stat(path)
            if st_info.st_dev != device_id:
                debug("Not on same device: %s" % repr(path))
                return False

        return True

    def _walk(self, path, generator, device_id):
        """
        Walks the path provided, calling the generator function on the path,
        which yields the subdirectories and files.  It then iterates these
        lists and calls the sync method '_sync'.

        @param {String} path          Path to walk.
        @param {Function} generator   Generator function to call on path.
        @param {int} device_id        Device ID for the path, None if device
                                      cannot be determined.
        """
        for dirpath, _, files in generator(path):
#.........这里部分代码省略.........
开发者ID:GyroLand,项目名称:gsync,代码行数:103,代码来源:crawler.py

示例4: Crawler

# 需要导入模块: from libgsync.drive import Drive [as 别名]
# 或者: from libgsync.drive.Drive import stat [as 别名]
class Crawler(object):
    def __init__(self, src, dst):
        self._dev = None
        self._src = None
        self._dst = None
        
        force_dest_file = GsyncOptions.force_dest_file

        self._drive = Drive()

        if self._drive.is_drivepath(src):
            self._walkCallback = bind("walk", self._drive)
            self._src = self._drive.normpath(src)
            info = self._drive.stat(self._src)

            if info and info.mimeType != MimeTypes.FOLDER:
                debug("Source is not a directory, forcing dest file: %s" % (
                    repr(self._src)
                ))
                force_dest_file = True
        else:
            self._walkCallback = os_walk_wrapper
            self._src = os.path.normpath(src)
            st_info = os.stat(self._src)

            if os.path.isfile(self._src):
                debug("Source is not a directory, forcing dest file: %s" % (
                    repr(self._src)
                ))
                force_dest_file = True

            if GsyncOptions.one_file_system:
                self._dev = st_info.st_dev

        if self._drive.is_drivepath(dst):
            self._dst = self._drive.normpath(dst)
            info = self._drive.stat(self._dst)

            if info and info.mimeType == MimeTypes.FOLDER:
                debug("Dest is a directory, not forcing dest file: %s" % (
                    repr(self._dst)
                ))
                force_dest_file = False
        else:
            self._dst = os.path.normpath(dst)
            if os.path.isdir(self._dst):
                debug("Dest is a directory, not forcing dest file: %s" % (
                    repr(self._dst)
                ))
                force_dest_file = False

        if src[-1] == "/":
            self._src += "/"

        if dst[-1] == "/":
            self._dst += "/"
            debug("Dest has trailing slash, not forcing dest file: %s" % (
                self._dst
            ))
            force_dest_file = False

        # Only update if not already set.
        if GsyncOptions.force_dest_file is None:
            debug("force_dest_file = %s" % force_dest_file)
            GsyncOptions.force_dest_file = force_dest_file

        #super(Crawler, self).__init__(name = "Crawler: %s" % src)
    

    def _devCheck(self, dev, path):
        if dev is not None:
            st_info = os.stat(path)
            if st_info.st_dev != dev:
                debug("Not on same dev: %s" % repr(path))
                return False

        return True


    def _walk(self, path, generator, dev):
        for d, dirs, files in generator(path):
            debug("Walking: %s" % repr(d))

            if not self._devCheck(dev, d):
                debug("Not on same device: %s" % repr(d))
                continue

            if not GsyncOptions.force_dest_file:
                if GsyncOptions.dirs or GsyncOptions.recursive:

                    # Sync the directory but not its contents
                    debug("Synchronising directory: %s" % repr(d))
                    self._sync(d)
                else:
                    sys.stdout.write("skipping directory %s\n" % d)
                    break

            for f in files:
                f = os.path.join(d, f)
                if not self._devCheck(dev, f):
#.........这里部分代码省略.........
开发者ID:lionandoil,项目名称:gsync,代码行数:103,代码来源:crawler.py


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