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


Python IDirectoryNode.providedBy方法代码示例

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


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

示例1: make_handler_for

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
def make_handler_for(node, client, parentnode=None, name=None):
    if parentnode:
        assert IDirectoryNode.providedBy(parentnode)
    if IFileNode.providedBy(node):
        return FileNodeHandler(client, node, parentnode, name)
    if IDirectoryNode.providedBy(node):
        return DirectoryNodeHandler(client, node, parentnode, name)
    return UnknownNodeHandler(client, node, parentnode, name)
开发者ID:LeastAuthority,项目名称:tahoe-lafs,代码行数:10,代码来源:directory.py

示例2: _populate_row

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def _populate_row(self, keys, childnode_and_metadata):
     (childnode, metadata) = childnode_and_metadata
     values = []
     isdir = bool(IDirectoryNode.providedBy(childnode))
     for key in keys:
         if key == "size":
             if isdir:
                 value = 0
             else:
                 value = childnode.get_size() or 0
         elif key == "directory":
             value = isdir
         elif key == "permissions":
             # Twisted-14.0.2 (and earlier) expected an int, and used it
             # in a rendering function that did (mode & NUMBER).
             # Twisted-15.0.0 expects a
             # twisted.python.filepath.Permissions , and calls its
             # .shorthand() method. This provides both.
             value = IntishPermissions(0o600)
         elif key == "hardlinks":
             value = 1
         elif key == "modified":
             # follow sftpd convention (i.e. linkmotime in preference to mtime)
             if "linkmotime" in metadata.get("tahoe", {}):
                 value = metadata["tahoe"]["linkmotime"]
             else:
                 value = metadata.get("mtime", 0)
         elif key == "owner":
             value = self.username
         elif key == "group":
             value = self.username
         else:
             value = "??"
         values.append(value)
     return values
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:37,代码来源:ftpd.py

示例3: modify

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
    def modify(self, old_contents, servermap, first_time):
        children = self.node._unpack_contents(old_contents)
        now = time.time()
        for (namex, (child, new_metadata)) in self.entries.iteritems():
            name = normalize(namex)
            precondition(IFilesystemNode.providedBy(child), child)

            # Strictly speaking this is redundant because we would raise the
            # error again in _pack_normalized_children.
            child.raise_error()

            metadata = None
            if name in children:
                if not self.overwrite:
                    raise ExistingChildError("child %s already exists" % quote_output(name, encoding='utf-8'))

                if self.overwrite == "only-files" and IDirectoryNode.providedBy(children[name][0]):
                    raise ExistingChildError("child %s already exists as a directory" % quote_output(name, encoding='utf-8'))
                metadata = children[name][1].copy()

            metadata = update_metadata(metadata, new_metadata, now)
            if self.create_readonly_node and metadata.get('no-write', False):
                child = self.create_readonly_node(child, name)

            children[name] = (child, metadata)
        new_contents = self.node._pack_contents(children)
        return new_contents
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:29,代码来源:dirnode.py

示例4: add_node

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
    def add_node(self, node, path):
        dirnode.DeepStats.add_node(self, node, path)
        data = {"path": path,
                "cap": node.get_uri()}

        if IDirectoryNode.providedBy(node):
            data["type"] = "directory"
        elif IFileNode.providedBy(node):
            data["type"] = "file"
        else:
            data["type"] = "unknown"

        v = node.get_verify_cap()
        if v:
            v = v.to_string()
        data["verifycap"] = v or ""

        r = node.get_repair_cap()
        if r:
            r = r.to_string()
        data["repaircap"] = r or ""

        si = node.get_storage_index()
        if si:
            si = base32.b2a(si)
        data["storage-index"] = si or ""

        if self.repair:
            d = node.check_and_repair(self.monitor, self.verify, self.add_lease)
            d.addCallback(self.add_check_and_repair, data)
        else:
            d = node.check(self.monitor, self.verify, self.add_lease)
            d.addCallback(self.add_check, data)
        d.addCallback(self.write_line)
        return d
开发者ID:LeastAuthority,项目名称:tahoe-lafs,代码行数:37,代码来源:directory.py

示例5: _made_upload_dir

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def _made_upload_dir(n):
     self.failUnless(IDirectoryNode.providedBy(n))
     self.upload_dirnode = n
     self.upload_dircap = n.get_uri()
     self.uploader = DropUploader(self.client, self.upload_dircap, self.local_dir.encode('utf-8'),
                                  inotify=self.inotify)
     return self.uploader.startService()
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:9,代码来源:test_drop_upload.py

示例6: render_check_form

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
    def render_check_form(self, ctx, data):
        node = self.original
        quoted_uri = urllib.quote(node.get_uri())
        target = self.get_root(ctx) + "/uri/" + quoted_uri
        if IDirectoryNode.providedBy(node):
            target += "/"
        check = T.form(action=target, method="post",
                       enctype="multipart/form-data")[
            T.fieldset[
            T.input(type="hidden", name="t", value="check"),
            T.input(type="hidden", name="return_to", value="."),
            T.legend(class_="freeform-form-label")["Check on this object"],
            T.div[
            "Verify every bit? (EXPENSIVE):",
            T.input(type="checkbox", name="verify"),
            ],
            T.div["Repair any problems?: ",
                  T.input(type="checkbox", name="repair")],
            T.div["Add/renew lease on all shares?: ",
                  T.input(type="checkbox", name="add-lease")],
            T.div["Emit results in JSON format?: ",
                  T.input(type="checkbox", name="output", value="JSON")],

            T.input(type="submit", value="Check"),

            ]]
        return ctx.tag[check]
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:29,代码来源:info.py

示例7: __init__

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
    def __init__(self, client, local_path_u, db, upload_dirnode, pending_delay, clock):
        QueueMixin.__init__(self, client, local_path_u, db, 'uploader', clock, delay=pending_delay)

        self.is_ready = False

        if not IDirectoryNode.providedBy(upload_dirnode):
            raise AssertionError("The URI in '%s' does not refer to a directory."
                                 % os.path.join('private', 'magic_folder_dircap'))
        if upload_dirnode.is_unknown() or upload_dirnode.is_readonly():
            raise AssertionError("The URI in '%s' is not a writecap to a directory."
                                 % os.path.join('private', 'magic_folder_dircap'))

        self._upload_dirnode = upload_dirnode
        self._inotify = get_inotify_module()
        self._notifier = self._inotify.INotify()
        self._pending = set()  # of unicode relpaths

        self._periodic_full_scan_duration = 10 * 60 # perform a full scan every 10 minutes

        if hasattr(self._notifier, 'set_pending_delay'):
            self._notifier.set_pending_delay(pending_delay)

        # TODO: what about IN_MOVE_SELF and IN_UNMOUNT?
        #
        self.mask = ( self._inotify.IN_CREATE
                    | self._inotify.IN_CLOSE_WRITE
                    | self._inotify.IN_MOVED_TO
                    | self._inotify.IN_MOVED_FROM
                    | self._inotify.IN_DELETE
                    | self._inotify.IN_ONLYDIR
                    | IN_EXCL_UNLINK
                    )
        self._notifier.watch(self._local_filepath, mask=self.mask, callbacks=[self._notify],
                             recursive=False)#True)
开发者ID:gvsurenderreddy,项目名称:tahoe-lafs,代码行数:36,代码来源:magic_folder.py

示例8: render_directory_writecap

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def render_directory_writecap(self, ctx, data):
     node = self.original
     if not IDirectoryNode.providedBy(node):
         return ""
     if node.is_readonly():
         return ""
     return ctx.tag[node.get_uri()]
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:9,代码来源:info.py

示例9: got_child

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
    def got_child(self, node_or_failure, ctx, name):
        req = IRequest(ctx)
        method = req.method
        nonterminal = len(req.postpath) > 1
        t = get_arg(req, "t", "").strip()
        if isinstance(node_or_failure, Failure):
            f = node_or_failure
            f.trap(NoSuchChildError)
            # No child by this name. What should we do about it?
            if nonterminal:
                if should_create_intermediate_directories(req):
                    # create intermediate directories
                    d = self.node.create_subdirectory(name)
                    d.addCallback(make_handler_for,
                                  self.client, self.node, name)
                    return d
            else:
                # terminal node
                if (method,t) in [ ("POST","mkdir"), ("PUT","mkdir"),
                                   ("POST", "mkdir-with-children"),
                                   ("POST", "mkdir-immutable") ]:
                    # final directory
                    kids = {}
                    if t in ("mkdir-with-children", "mkdir-immutable"):
                        req.content.seek(0)
                        kids_json = req.content.read()
                        kids = convert_children_json(self.client.nodemaker,
                                                     kids_json)
                    file_format = get_format(req, None)
                    mutable = True
                    mt = get_mutable_type(file_format)
                    if t == "mkdir-immutable":
                        mutable = False

                    d = self.node.create_subdirectory(name, kids,
                                                      mutable=mutable,
                                                      mutable_version=mt)
                    d.addCallback(make_handler_for,
                                  self.client, self.node, name)
                    return d
                if (method,t) in ( ("PUT",""), ("PUT","uri"), ):
                    # we were trying to find the leaf filenode (to put a new
                    # file in its place), and it didn't exist. That's ok,
                    # since that's the leaf node that we're about to create.
                    # We make a dummy one, which will respond to the PUT
                    # request by replacing itself.
                    return PlaceHolderNodeHandler(self.client, self.node, name)
            # otherwise, we just return a no-such-child error
            return f

        node = node_or_failure
        if nonterminal and should_create_intermediate_directories(req):
            if not IDirectoryNode.providedBy(node):
                # we would have put a new directory here, but there was a
                # file in the way.
                raise WebError("Unable to create directory '%s': "
                               "a file was in the way" % name,
                               http.CONFLICT)
        return make_handler_for(node, self.client, self.node, name)
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:61,代码来源:directory.py

示例10: render_file_writecap

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def render_file_writecap(self, ctx, data):
     node = self.original
     if IDirectoryNode.providedBy(node):
         node = node._node
     write_uri = node.get_write_uri()
     if not write_uri:
         return ""
     return ctx.tag[write_uri]
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:10,代码来源:info.py

示例11: render_is_mutable_file

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def render_is_mutable_file(self, ctx, data):
     node = self.original
     if IDirectoryNode.providedBy(node):
         return ""
     if (IFileNode.providedBy(node)
         and node.is_mutable() and not node.is_readonly()):
         return ctx.tag
     return ""
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:10,代码来源:info.py

示例12: render_file_readcap

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def render_file_readcap(self, ctx, data):
     node = self.original
     if IDirectoryNode.providedBy(node):
         node = node._node
     read_uri = node.get_readonly_uri()
     if not read_uri:
         return ""
     return ctx.tag[read_uri]
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:10,代码来源:info.py

示例13: __init__

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def __init__(self, filenode, nodemaker, uploader):
     assert IFileNode.providedBy(filenode), filenode
     assert not IDirectoryNode.providedBy(filenode), filenode
     self._node = filenode
     filenode_cap = filenode.get_cap()
     self._uri = wrap_dirnode_cap(filenode_cap)
     self._nodemaker = nodemaker
     self._uploader = uploader
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:10,代码来源:dirnode.py

示例14: render_directory_verifycap

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def render_directory_verifycap(self, ctx, data):
     node = self.original
     if not IDirectoryNode.providedBy(node):
         return ""
     verifier = node.get_verify_cap()
     if verifier:
         return ctx.tag[node.get_verify_cap().to_string()]
     return ""
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:10,代码来源:info.py

示例15: render_raw_link

# 需要导入模块: from allmydata.interfaces import IDirectoryNode [as 别名]
# 或者: from allmydata.interfaces.IDirectoryNode import providedBy [as 别名]
 def render_raw_link(self, ctx, data):
     node = self.original
     if IDirectoryNode.providedBy(node):
         node = node._node
     elif IFileNode.providedBy(node):
         pass
     else:
         return ""
     root = self.get_root(ctx)
     quoted_uri = urllib.quote(node.get_uri())
     text_plain_url = "%s/file/%s/@@named=/raw.txt" % (root, quoted_uri)
     return T.li["Raw data as ", T.a(href=text_plain_url)["text/plain"]]
开发者ID:ArtRichards,项目名称:tahoe-lafs,代码行数:14,代码来源:info.py


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