Example #1
0
    # SET UP FILETYPE
    # -f
    if args.projectfile is not '' and args.jobfile is '':
        filetype = 'projectFile'
    # -j
    elif args.jobfile is not '' and args.projectfile is '':
        filetype = 'projectJobFile'
    else:
	filetype = None

    # get files for metadata
    files = vdjpy.get_project_files(project_uuid, filetype, kwargs, my_agave)

    # filter to one file if name specified; quit if file not found
    if filetype == 'projectFile' and args.projectfile is not None:
	files = vdjpy.get_file_metadata(files, args.projectfile)
    elif filetype == 'projectJobFile' and args.jobfile is not None:
	files = vdjpy.get_file_metadata(files, args.jobfile)
    if files is None:
	sys.exit()

    # if -v or specific file given
    if args.verbose is True or type(files) is not list:
        print json.dumps(files, default = vdjpy.json_serial, sort_keys = True, indent = 4, separators = (',', ': '))

    # if no -v and files is a list
    else:
        for item in files:
            print item['value']['name']
Example #2
0
    # SET UP FILETYPE AND GET FILE NAME IN ARGS.FILE_NAME
    # -f (default)
    if args.file_name is not '' or args.jobfile_name is '':
        if args.file_name is None or '':
            args.file_name = vdjpy.prompt_user('file name')
        filetype = 'projectFile'
    # -j (only if flag given)
    else:
        if args.jobfile_name is None:
            args.jobfile_name = vdjpy.prompt_user('jobfile name')
        filetype = 'projectJobFile'
        args.file_name = args.jobfile_name
        # get metadata for extra path; exit if file not found
        project_files = vdjpy.get_project_files(project_uuid, filetype, {}, my_agave)
        file_metadata = vdjpy.get_file_metadata(project_files, args.file_name)
        if file_metadata is None:
            sys.exit()

    # if jobfile, get extra path; then build file path
    extra_path = ''
    if filetype == 'projectJobFile':
        extra_path += str(file_metadata['value']['relativeArchivePath']) + '/'
    kwargs['filePath'] = vdjpy.build_vdj_path(project_uuid, args.file_name, filetype, extra_path)

    # list permissions
    permissions = my_agave.files.listPermissions(**kwargs)

    # if -v
    if args.verbose:
         print json.dumps(permissions, default = vdjpy.json_serial, sort_keys = True, indent = 4, separators = (',', ': '))
Example #3
0
    # -f (default file type; used if -j not called)
    if args.file_to_delete is not '' or args.jobfile_to_delete is '':
	if args.file_to_delete is None:
            args.file_to_delete = vdjpy.prompt_user('file to delete')
	filetype = 'projectFile'
    # -j (only used if specified)
    else:
	if args.jobfile_to_delete is None:
	    args.jobfile_to_delte = vdjpy.prompt_user('jobfile to delete')
	filetype = 'projectJobFile'
	# consolidate file name to args.file_to_delete no matter file type
	args.file_to_delete = args.jobfile_to_delete
    
    # get file_to_delete metadata
    files = vdjpy.get_project_files(project_uuid, filetype, {}, my_agave)
    file_metadata = vdjpy.get_file_metadata(files, args.file_to_delete) 
    if file_metadata is None:
        sys.exit()
   
    # change isDeleted to true
    file_metadata['value']['isDeleted'] = True

    # delete file via metadata update
    delete_resp = my_agave.meta.updateMetadata(uuid = file_metadata['uuid'],
					       body = json.dumps(file_metadata))

    # if -v
    if args.verbose:
        print json.dumps(delete_resp, default = vdjpy.json_serial, sort_keys = True, indent = 4, separators = (',', ': '))
    
    # if no -v