diff options
author | xudan <xudan16@huawei.com> | 2019-07-10 21:59:21 -0400 |
---|---|---|
committer | Dan Xu <xudan16@huawei.com> | 2019-08-23 09:28:42 +0000 |
commit | 14a9a43bf675469486a6991976bef24f3540217b (patch) | |
tree | a1acbba077ae0e6100970153a4951c96f3eaf027 /dovetail/api/app/utils.py | |
parent | a85d35f86170a2a2f2455fa157c12be823060522 (diff) |
Add run tests API
Change-Id: I456d5d1459faa20d9dd8afd0c235a4bb6cbfbcce
Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/api/app/utils.py')
-rw-r--r-- | dovetail/api/app/utils.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dovetail/api/app/utils.py b/dovetail/api/app/utils.py new file mode 100644 index 00000000..1708dfb7 --- /dev/null +++ b/dovetail/api/app/utils.py @@ -0,0 +1,21 @@ +import json +import os + + +def write_env_file(envs, file_path): + file_dir = os.path.dirname(file_path) + if not os.path.exists(file_dir): + os.makedirs(file_dir) + with open(file_path, "w") as f: + for key, value in envs.items(): + f.write("export {}={}\n".format(key, value)) + return True + + +def write_yaml_file(data, file_path): + file_dir = os.path.dirname(file_path) + if not os.path.exists(file_dir): + os.makedirs(file_dir) + with open(file_path, "w") as f: + f.write(json.dumps(data) + '\n') + return True |