Exemple #1
0
    def main(conninfo, credentials, args):
        if args.id and args.create:
            raise ValueError("cannot use --create with --id")
        if args.id and args.path:
            raise ValueError("--path conflicts with --id")
        elif not args.id and not args.path:
            raise ValueError("Must specify --path or --id")
        if args.stdin:
            if args.file:
                raise ValueError("--stdin conflicts with --file")
            elif not args.chunked:
                raise ValueError("--stdin must be sent chunked")
        elif args.file:
            if not os.path.isfile(args.file):
                raise ValueError("%s is not a file" % args.file)
        else:
            raise ValueError("Must specify --stdin or --file")

        infile = open(args.file, "rb") if args.file else sys.stdin

        if args.create:
            dirname, basename = qumulo.lib.util.unix_path_split(args.path)
            if not basename:
                raise ValueError("Path has no basename")
            fs.create_file(conninfo, credentials, basename, dirname)

        etag = None
        print fs.write_file(conninfo, credentials, infile,
            args.path, args.id, etag)
Exemple #2
0
    def main(conninfo, credentials, args):
        if args.id and args.path:
            raise ValueError("--path conflicts with --id")
        elif not args.id and not args.path:
            raise ValueError("Must specify --path or --id")

        print fs.create_file(conninfo, credentials, args.name,
            dir_path=args.path, dir_id=args.id)