コード例 #1
0
    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 = (',', ': '))

    # if no -v
    else:
        for item in permissions:
            permission_string = item['username'] + ' '
            if item['permission']['read']:
                permission_string += 'r'
            if item['permission']['write']:
コード例 #2
0
ファイル: vdj-files-move.py プロジェクト: jturcino/vdj-cli
        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 file; exit if file not found
    project_files = vdjpy.get_project_files(current_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 paths
    extra_path = ''
    if filetype == 'projectJobFile':
	extra_path += str(file_metadata['value']['relativeArchivePath']) + '/'
    current_path = vdjpy.build_vdj_path(current_uuid, args.file_name, filetype, extra_path)
    destination_path = vdjpy.build_vdj_path(destination_uuid, args.file_name, 'projectFile', '')

    # move in agave (cannot move to jobfile destination)
    agave_move = my_agave.files.manage(systemId = 'data.vdjserver.org',
				       filePath = current_path, 
				       body = {'action': 'move', 
					       'path': destination_path})

    # update filepath, project uuid, and remove unnecessary metadata if jobfile
    file_metadata['_links']['file']['href'] = unicode('https://vdj-agave-api.tacc.utexas.edu/files/v2/media/system/data.vdjserver.org/' + destination_path)
    file_metadata['value']['projectUuid'] = unicode(destination_uuid)
    if filetype == 'projectJobFile':
	file_metadata['name'] = 'projectFile'
        del file_metadata['value']['relativeArchivePath']
        del file_metadata['value']['jobName']
コード例 #3
0
ファイル: vdj-files-get.py プロジェクト: jturcino/vdj-cli
        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()

    # -n; use args.file_name if flag not used
    if args.newfile_name is '':
	args.newfile_name = args.file_name
    elif args.newfile_name is None:
	args.newfile_name = vdjpy.prompt_user('name of file once downloaded')
    
    # if jobfile, get extra path; then build path
    extra_path = ''
    if filetype == 'projectJobFile':
        extra_path += str(file_metadata['value']['relativeArchivePath']) + '/'
    file_path = vdjpy.build_vdj_path(project_uuid, args.file_name, filetype, extra_path)

    # download file
    download = my_agave.files.download(systemId = 'data.vdjserver.org',
				       filePath = file_path)
    download.raise_for_status()

    # write contents to file
    with open(os.path.expanduser(args.newfile_name), 'w') as download_file:
        download_file.write(download.text)

    print 'Successfully downloaded', args.file_name, 'as', args.newfile_name
コード例 #4
0
ファイル: vdj-files-upload.py プロジェクト: jturcino/vdj-cli
    parser.add_argument('-v', '--verbose', dest = 'verbose', action = 'store_true', help = 'verbose output')
    parser.add_argument('-z', '--accesstoken', dest = 'accesstoken', nargs = '?', help = 'access token')
    args = parser.parse_args()

    # UPLOAD FILE SETUP
    my_agave = vdjpy.make_vdj_agave(args.accesstoken)
    kwargs = {}
    kwargs['systemId'] = 'data.vdjserver.org'

    # -p
    if args.project is None:
        args.project = vdjpy.prompt_user('project name')
    project_uuid = vdjpy.get_uuid(args.project, my_agave)
    if project_uuid is None:
        sys.exit('Could not find specified project')
    kwargs['filePath'] = vdjpy.build_vdj_path(project_uuid, '', 'projectFile', '')

    # -f
    if args.file_upload is None:
        args.file_upload = vdjpy.prompt_user('file to upload')
    kwargs['fileToUpload'] = open(args.file_upload)

    # -n
    if args.file_name is None:
        args.file_name = args.file_upload
    kwargs['fileName'] = args.file_name

    # -w
    if args.email_or_webhook is not '':
        if args.email_or_webhook is None:
            args.email_or_webhook = vdjpy.prompt_user('email or webhook')