+ log_handler = None
+
+ if log_handler is not None:
+ arvados.logger.removeHandler(arvados.log_handler)
+ arvados.logger.addHandler(log_handler)
+
+ if args.debug:
+ arvados.logger.setLevel(logging.DEBUG)
+ logger.debug("arv-mount debugging enabled")
+
+ try:
+ # Create the request handler
+ operations = Operations(os.getuid(), os.getgid(), args.encoding, args.set_executable_bit)
+ api = SafeApi(arvados.config)
+
+ usr = api.users().current().execute(num_retries=args.retries)
+ now = time.time()
+ dir_class = None
+ dir_args = [llfuse.ROOT_INODE, operations.inodes, api, args.retries]
+ if args.by_id:
+ # Set up the request handler with the 'magic directory' at the root
+ dir_class = MagicDirectory
+ elif args.by_tag:
+ dir_class = TagsDirectory
+ elif args.shared:
+ dir_class = SharedDirectory
+ dir_args.append(usr)
+ elif args.home:
+ dir_class = ProjectDirectory
+ dir_args.append(usr)
+ dir_args.append(True)
+ elif args.collection is not None:
+ # Set up the request handler with the collection at the root
+ dir_class = CollectionDirectory
+ dir_args.append(args.collection)
+ elif args.project is not None:
+ dir_class = ProjectDirectory
+ dir_args.append(api.groups().get(uuid=args.project).execute(
+ num_retries=args.retries))
+
+ if dir_class is not None:
+ operations.inodes.add_entry(dir_class(*dir_args))
+ else:
+ e = operations.inodes.add_entry(Directory(llfuse.ROOT_INODE))
+ dir_args[0] = e.inode
+
+ e._entries['by_id'] = operations.inodes.add_entry(MagicDirectory(*dir_args))
+ e._entries['by_tag'] = operations.inodes.add_entry(TagsDirectory(*dir_args))
+
+ dir_args.append(usr)
+ dir_args.append(True)
+ e._entries['home'] = operations.inodes.add_entry(ProjectDirectory(*dir_args))
+ e._entries['shared'] = operations.inodes.add_entry(SharedDirectory(*dir_args))
+
+ text = '''
+Welcome to Arvados! This directory provides file system access to files and objects
+available on the Arvados installation located at '{}'
+using credentials for user '{}'.
+
+From here, the following directories are available:
+
+ by_id/ Access to Keep collections by uuid or portable data hash (see by_id/README for details).
+ by_tag/ Access to Keep collections organized by tag.
+ home/ The contents of your home project.
+ shared/ Projects shared with you.
+'''.format(arvados.config.get('ARVADOS_API_HOST'), usr['email'])
+
+ e._entries["README"] = operations.inodes.add_entry(StringFile(e.inode, text, now))
+
+
+ except Exception:
+ logger.exception("arv-mount: exception during API setup")
+ exit(1)