X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/676dfa352dbf55a23e0123b47d1affe33c028908..55db20860c90c60dd231083c1cc81001c3fbe971:/services/fuse/arvados_fuse/__init__.py diff --git a/services/fuse/arvados_fuse/__init__.py b/services/fuse/arvados_fuse/__init__.py index 2e7f4c7e02..c0ea03f06b 100644 --- a/services/fuse/arvados_fuse/__init__.py +++ b/services/fuse/arvados_fuse/__init__.py @@ -2,7 +2,6 @@ # FUSE driver for Arvados Keep # -from __future__ import print_function import os import sys @@ -16,12 +15,11 @@ import arvados.events import re import apiclient import json +import logging from time import time from llfuse import FUSEError -DEBUG = False - class FreshBase(object): '''Base class for maintaining fresh/stale state to determine when to update.''' def __init__(self): @@ -126,8 +124,7 @@ class Directory(FreshBase): try: self.update() except apiclient.errors.HttpError as e: - if DEBUG: - print(e, file=sys.stderr) + logging.debug(e) def __getitem__(self, item): self.checkupdate() @@ -200,8 +197,7 @@ class CollectionDirectory(Directory): self.fresh() return True except Exception as detail: - if DEBUG: - print("arv-mount %s: error: %s" % (self.collection_locator,detail), file=sys.stderr) + logging.debug("arv-mount %s: error: %s" % (self.collection_locator,detail)) return False class MagicDirectory(Directory): @@ -229,15 +225,14 @@ class MagicDirectory(Directory): else: return False except Exception as e: - if DEBUG: - print('arv-mount exception keep', e, file=sys.stderr) + logging.debug('arv-mount exception keep %s', e) return False def __getitem__(self, item): - if self.__contains__(item): + if item in self: return self._entries[item] else: - raise KeyError() + raise KeyError("No collection with id " + item) class TagsDirectory(Directory): '''A special directory that contains as subdirectories all tags visible to the user.''' @@ -260,10 +255,11 @@ class TagsDirectory(Directory): def update(self): tags = self.api.links().list(filters=[['link_class', '=', 'tag']], select=['name'], distinct = True).execute() - self.merge(tags['items'], - lambda i: i['name'], - lambda a, i: a.tag == i, - lambda i: TagDirectory(self.inode, self.inodes, self.api, i['name'], poll=self._poll, poll_time=self._poll_time)) + if "items" in tags: + self.merge(tags['items'], + lambda i: i['name'], + lambda a, i: a.tag == i, + lambda i: TagDirectory(self.inode, self.inodes, self.api, i['name'], poll=self._poll, poll_time=self._poll_time)) class TagDirectory(Directory): '''A special directory that contains as subdirectories all collections visible @@ -309,7 +305,8 @@ class GroupsDirectory(Directory): self._entries[a].invalidate() def update(self): - groups = self.api.groups().list().execute() + groups = self.api.groups().list( + filters=[['group_class','=','project']]).execute() self.merge(groups['items'], lambda i: i['uuid'], lambda a, i: a.uuid == i['uuid'], @@ -420,14 +417,9 @@ class Operations(llfuse.Operations): so request handlers do not run concurrently unless the lock is explicitly released with llfuse.lock_released.''' - def __init__(self, uid, gid, debug): + def __init__(self, uid, gid): super(Operations, self).__init__() - if debug: - global DEBUG - DEBUG = True - print("arv-mount debug enabled", file=sys.stderr) - self.inodes = Inodes() self.uid = uid self.gid = gid @@ -484,8 +476,7 @@ class Operations(llfuse.Operations): return entry def lookup(self, parent_inode, name): - if DEBUG: - print("arv-mount lookup: parent_inode", parent_inode, "name", name, file=sys.stderr) + logging.debug("arv-mount lookup: parent_inode %i name %s", parent_inode, name) inode = None if name == '.': @@ -521,8 +512,7 @@ class Operations(llfuse.Operations): return fh def read(self, fh, off, size): - if DEBUG: - print("arv-mount read", fh, off, size, file=sys.stderr) + logging.debug("arv-mount read %i %i %i", fh, off, size) if fh in self._filehandles: handle = self._filehandles[fh] else: @@ -539,8 +529,7 @@ class Operations(llfuse.Operations): del self._filehandles[fh] def opendir(self, inode): - if DEBUG: - print("arv-mount opendir: inode", inode, file=sys.stderr) + logging.debug("arv-mount opendir: inode %i", inode) if inode in self.inodes: p = self.inodes[inode] @@ -561,16 +550,14 @@ class Operations(llfuse.Operations): return fh def readdir(self, fh, off): - if DEBUG: - print("arv-mount readdir: fh", fh, "off", off, file=sys.stderr) + logging.debug("arv-mount readdir: fh %i off %i", fh, off) if fh in self._filehandles: handle = self._filehandles[fh] else: raise llfuse.FUSEError(errno.EBADF) - if DEBUG: - print("arv-mount handle.entry", handle.entry, file=sys.stderr) + logging.debug("arv-mount handle.entry %s", handle.entry) e = off while e < len(handle.entry):