move public functions to utils.py

This commit is contained in:
debugtalk
2017-06-22 23:08:01 +08:00
parent 1e6e6ad81b
commit 3fd53b4448
2 changed files with 18 additions and 8 deletions

View File

@@ -1,8 +1,22 @@
import hashlib
import json
import yaml
import os.path
import random
import string
import yaml
from ate.exception import ParamsError
def gen_random_string(str_len):
return ''.join(
random.choice(string.ascii_letters + string.digits) for _ in range(str_len))
def gen_md5(str_list):
authorization_str = "".join(str_list)
return hashlib.md5(authorization_str.encode('utf-8')).hexdigest()
def load_yaml_file(yaml_file):
with open(yaml_file, 'r+') as stream:
return yaml.load(stream)