+ status = 0
+ if api_client is None:
+ api_client = arvados.api('v1')
+
+ # Determine the name to use
+ if args.name:
+ if args.stream or args.raw:
+ print >>stderr, "Cannot use --name with --stream or --raw"
+ sys.exit(1)
+ collection_name = args.name
+ else:
+ collection_name = "Saved at {} by {}@{}".format(
+ datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC"),
+ pwd.getpwuid(os.getuid()).pw_name,
+ socket.gethostname())
+
+ if args.project_uuid and (args.stream or args.raw):
+ print >>stderr, "Cannot use --project-uuid with --stream or --raw"
+ sys.exit(1)
+
+ # Determine the parent project
+ try:
+ project_uuid = desired_project_uuid(api_client, args.project_uuid,
+ args.retries)
+ except (apiclient_errors.Error, ValueError) as error:
+ print >>stderr, error
+ sys.exit(1)
+
+ # write_copies diverges from args.replication here.
+ # args.replication is how many copies we will instruct Arvados to
+ # maintain (by passing it in collections().create()) after all
+ # data is written -- and if None was given, we'll use None there.
+ # Meanwhile, write_copies is how many copies of each data block we
+ # write to Keep, which has to be a number.
+ #
+ # If we simply changed args.replication from None to a default
+ # here, we'd end up erroneously passing the default replication
+ # level (instead of None) to collections().create().
+ write_copies = (args.replication or
+ api_client._rootDesc.get('defaultCollectionReplication', 2))