[skip e2e] Add new func of get_token on utils (#13744)

pull/13806/head
wt 2021-12-20 19:12:43 +08:00 committed by GitHub
parent fcddbc2401
commit 6cf73f1b9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import time
import logging
import string
import random
import requests
import json
import os
from yaml.representer import SafeRepresenter
@ -263,3 +264,15 @@ def read_json_file(file_name):
with open(file_name) as f:
file_dict = json.load(f)
return file_dict
def get_token(url):
""" get the request token and return the value """
rep = requests.get(url)
data = json.loads(rep.text)
if 'token' in data:
token = data['token']
else:
token = ''
print("Can not get token.")
return token