Beispiel #1
0
    parser.add_argument('-a', '--appID', dest = 'appID', default = '', nargs = '?', help = 'application ID')
    parser.add_argument('-f', '--description_file', dest = 'description_file', nargs = '?', help = 'file containing JSON app description')
    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()

    # make agave object and kwargs
    my_agave = vdjpy.make_vdj_agave(args.accesstoken)
    kwargs = {}

    # -f
    if args.description_file is None:
        args.description_file = vdjpy.prompt_user('path to file containing app description')
    
    # open -f and use as body
    body_contents = vdjpy.read_json(args.description_file)
    if body_contents is None:
        sys.exit('Not a valid file path or does not contain a valid app description.')
    kwargs['body'] = json.dumps(body_contents)

    # if -a, update app
    if args.appID is not '':
	if args.appID is None:
            args.appID = vdjpy.prompt_user('app ID')
	kwargs['appId'] = args.appID
	resp = my_agave.apps.update(**kwargs)

    # else, add app
    else:
	resp = my_agave.apps.add(**kwargs)
Beispiel #2
0
    parser = argparse.ArgumentParser(description = 'Add or update a metadata object. If the uuid of existing metadata is given, the metadata will be updated; otherwise, a new piece of metadata will be created.')
    parser.add_argument('-u', '--uuid', dest = 'uuid', default = '', nargs = '?', help = 'uuid of metadata object')
    parser.add_argument('-f', '--metadata_file', dest = 'metadata_file', nargs = '?', help = 'file containing JSON metadata description')
    parser.add_argument('-z', '--accesstoken', dest = 'accesstoken', nargs = '?', help = 'access token')
    args = parser.parse_args()

    # make agave object and kwargs
    kwargs = {}
    my_agave = vdjpy.make_vdj_agave(args.accesstoken)

    # -f
    if args.metadata_file is None:
        args.metadata_file = vdjpy.prompt_user('path to metadata file')
    
    # open -f and use as body
    body_contents = vdjpy.read_json(args.metadata_file)
    if body_contents is None:
        sys.exit('Not a valid file path or does not contain valid JSON.')
    kwargs['body'] = json.dumps(body_contents)
    
    # if -u given, use update
    if args.uuid is not '':
        if args.uuid is None:
            args.uuid = vdjpy.prompt_user('uuid of item')
        kwargs['uuid'] = args.uuid
        resp = my_agave.meta.updateMetadata(**kwargs)
    
    # else, use add
    else:
        resp = my_agave.meta.addMetadata(**kwargs)
Beispiel #3
0
    args = parser.parse_args()

    # make agave object and kwargs
    my_agave = vdjpy.make_vdj_agave(args.accesstoken)
    kwargs = {}

    # -a
    if args.appID is None:
        args.appID = vdjpy.prompt_user('ID of app to be cloned')
    kwargs['appId'] = args.appID

    # -f used if given
    if args.description_file is not '':
        if args.description_file is None:
            args.description_file = vdjpy.prompt_user('file name')
        body_contents = vdjpy.read_json(args.description_file)
        if body_contents is None:
            sys.exit()
        kwargs['body'] = json.dumps(body_contents)

    # -n, -s, -e, -x, and -d used if no -f
    else:
        # if -n, -e, or -x not given, load app data (exit if app does not exist)
        if args.clone_name or args.execution_system or args.version is '':
            apps = my_agave.apps.list()
            app_info = None
            for app in apps:
                if app['id'] == args.appID:
                    app_info = app
            if app_info is None:
                sys.exit('Could not find app to be cloned')
Beispiel #4
0
user_cache = '~/.vdjapi'
template_cache = './cache-template.json'

if __name__ == '__main__':

    # arguments
    parser = argparse.ArgumentParser(description = 'Authenticate a user by retrieving a new access and refresh token. If the refresh flag is used, the new tokens are retrieved using the refresh token in the user\'s cache (~/.vdjapi), or one supplied by the user. If the save flag is used, the new tokens are cached.')
    parser.add_argument('-u', '--username', dest = 'username', nargs = '?', help = 'user to authenticate')
    parser.add_argument('-p', '--password', dest = 'password', nargs = '?', help = 'password of the user')
    parser.add_argument('-r', '--refresh', dest = 'refresh', default = '', nargs = '?', help = 'use cached refresh token or one supplied by the user')
    parser.add_argument('-s', '--save', dest = 'save', action = 'store_true', help = 'cache tokens once retrieved')
    args = parser.parse_args()

    # load cache
    cache_dict = vdjpy.read_json(user_cache)
    if cache_dict is None:
	if args.save:
	    cache_dict = vdjpy.read_json(template_cache)
	else:
	    cache_dict = {}

    # -u
    if args.username is None:
	args.username = cache_dict.get('username')
	if args.username is None or args.username == unicode(''):
	    print 'Username in cache does not exist or is empty'
	    args.username = vdjpy.prompt_user('username')

    # -r
    if args.refresh is None: