コード例 #1
0
ファイル: vdj-projects-list.py プロジェクト: jturcino/vdj-cli
        args.limit = vdjpy.prompt_for_integer('limit', 5000)
    kwargs['limit'] = args.limit

    # -o
    if args.offset is None:
        args.offset = vdjpy.prompt_for_integer('offset value', 0)
    kwargs['offset'] = args.offset

    # get projects
    projects = vdjpy.get_vdj_projects(my_agave, kwargs)
    
    # if -s
    if args.alphabetical_sort:
	projects.sort(key = lambda e: e['value']['name'])

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

    # if no -v
    else:
       for item in projects:
           # if args.show_uuids, print uuid with name
           if args.show_uuids:
               print item.value['name'] + '\t' + item.uuid
           else:
               print item.value['name']

    # write to cache
    vdjpy.write_json(projects, projects_cache)
コード例 #2
0
ファイル: vdj-login.py プロジェクト: jturcino/vdj-cli
	args.refresh = cache_dict.get('refresh_token')
	if args.refresh is None or args.refresh == unicode(''):
	    print 'Refresh token in cache does not exist or is empty'
	    args.refresh = vdjpy.prompt_user('refresh token')

    # -p
    if args.refresh is '' and args.password is None:
	args.password = getpass.getpass('Enter password: '******'The username, password, or refresh token is not valid. Please try again.')

    # if -s, insert correct values and write to user_cache
    if args.save:
        cache_dict['username'] = args.username
        cache_dict['access_token'] = response['result']['access_token']
        cache_dict['refresh_token'] = response['result']['refresh_token']
        cache_dict['expires_in'] = response['result']['expires_in']
        cache_dict['created_at'] = current_time
        cache_dict['expires_at'] = time.ctime(current_time + response['result']['expires_in'])
        vdjpy.write_json(cache_dict, user_cache)

    # print tokens
    print 'Access token is:', str(response['result']['access_token'])
    print 'Refresh token is:', str(response['result']['refresh_token'])