- super(HomeDirectory, self).__init__(parent_inode, inodes, api, self.current_user)
-
- def build_project_trees():
- all_projects = self.api.groups().list(filters=[['group_class','=','project']], order=['name']).execute()['items']
- parent_of = {self.current_user['uuid']: 'me'}
- for ob in all_projects:
- parent_of[ob['uuid']] = ob['owner_uuid']
- children_of = {False: [], 'me': [self.current_user]}
-
- for ob in all_projects:
- if ob['owner_uuid'] != self.current_user['uuid'] and ob['owner_uuid'] not in parent_of:
- parent_of[ob['uuid']] = False
- if parent_of[ob['uuid']] not in children_of:
- children_of[parent_of[ob['uuid']]] = []
- children_of[parent_of[ob['uuid']]] += ob
-
- def buildtree(children_of, root_uuid):
- tree = {}
- for ob in children_of[root_uuid]:
- tree[ob] = buildtree(children_of, ob['uuid'])
- return tree
-
- my_project_tree = buildtree(children_of, 'me')
- shared_project_tree = buildtree(children_of, False)
-
- import pprint
- pprint.pprint(my_project_tree)
- pprint.pprint(shared_project_tree)
-
- #def contents(self):
- # return self.api.groups().contents(uuid=self.uuid).execute()['items']
+ self.inodes = inodes
+ self.api = api
+ self._poll = True
+ self._poll_time = poll_time
+
+ def update(self):
+ with llfuse.lock_released:
+ all_projects = arvados.util.list_all(self.api.groups().list, filters=[['group_class','=','project']])
+ objects = {}
+ for ob in all_projects:
+ objects[ob['uuid']] = ob
+
+ roots = []
+ root_owners = {}
+ for ob in all_projects:
+ if ob['owner_uuid'] != self.current_user['uuid'] and ob['owner_uuid'] not in objects:
+ roots.append(ob)
+ root_owners[ob['owner_uuid']] = True
+
+ lusers = arvados.util.list_all(self.api.users().list, filters=[['uuid','in', list(root_owners)]])
+ lgroups = arvados.util.list_all(self.api.groups().list, filters=[['uuid','in', list(root_owners)]])
+
+ users = {}
+ groups = {}
+
+ for l in lusers:
+ objects[l["uuid"]] = l
+ for l in lgroups:
+ objects[l["uuid"]] = l
+
+ contents = {}
+ for r in root_owners:
+ if r in objects:
+ obr = objects[r]
+ if "name" in obr:
+ contents[obr["name"]] = obr
+ if "first_name" in obr:
+ contents[u"{} {}".format(obr["first_name"], obr["last_name"])] = obr
+
+ for r in roots:
+ if r['owner_uuid'] not in objects:
+ contents[r['name']] = r
+
+ # end with llfuse.lock_released, re-acquire lock
+
+ try:
+ self.merge(contents.items(),
+ lambda i: i[0],
+ lambda a, i: a.uuid == i[1]['uuid'],
+ lambda i: ProjectDirectory(self.inode, self.inodes, self.api, i[1], poll=self._poll, poll_time=self._poll_time))
+ except Exception as e:
+ _logger.exception(e)
+