예제 #1
0
    def readdir(self, path, fh):
        self.log.info("*** readdir %r with fh %r" % (path, fh))

        # default (required) entries
        entries = ['.', '..']

        # remove leading '/'
        path = path[1:]

        # retrieve subfolders
        for node in subdirs(self.sess, path):
            entries.append(
                node.basename.encode(sys.getfilesystemencoding(), 'replace'))

        # split into path elements
        for node in from_incremental_query(self.sess, path):
            if path.endswith('/__flat__'):
                entries.append(
                    node.flatname.encode(sys.getfilesystemencoding(),
                                         'replace'))
            else:
                entries.append(
                    node.basename.encode(sys.getfilesystemencoding(),
                                         'replace'))
        return entries
예제 #2
0
def query(query="root"):
    result = nodes.subdirs(g.sess, query)
    if not result:
        result = []

    result += nodes.from_incremental_query(g.sess, query)

    try:
        result = result.order_by([
            Node.mimetype != 'other/directory',
            Node.uri])
    except Exception, exc:
        LOG.info(exc)
예제 #3
0
def view(query, index=0):
    result = nodes.subdirs(g.sess, query)
    if not result:
        result = []
    result += nodes.from_incremental_query(g.sess, query)
    result = filter(lambda x: x.mimetype != 'other/directory', result)

    try:
        result = result.order_by([
            Node.mimetype != 'other/directory',
            Node.uri])
    except Exception, exc:
        LOG.info(exc)
예제 #4
0
def file_uri(query, index):
    """
    Retrieve the file URI for the given query on the given index
    """
    result = nodes.subdirs(g.sess, query)
    if not result:
        result = []
    result += nodes.from_incremental_query(g.sess, query)
    result = filter(lambda x: x.mimetype in (
        'image/jpeg',
        'image/png',
        'image/jpg'), result)

    try:
        result = result.order_by( [Node.mimetype != 'other/directory', Node.uri ] )
    except Exception, exc:
        LOG.info(exc)
예제 #5
0
    def readdir(self, path, fh):
        self.log.info("*** readdir %r with fh %r" % (path, fh))

        # default (required) entries
        entries = [ '.', '..' ]

        # remove leading '/'
        path = path[1:]

        # retrieve subfolders
        for node in subdirs(self.sess, path):
            entries.append(node.basename.encode(
                sys.getfilesystemencoding(), 'replace'))

        # split into path elements
        for node in from_incremental_query(self.sess, path):
            if path.endswith('/__flat__'):
                entries.append(node.flatname.encode(
                    sys.getfilesystemencoding(), 'replace'))
            else:
                entries.append(node.basename.encode(
                    sys.getfilesystemencoding(), 'replace'))
        return entries