summaryrefslogtreecommitdiffstats
path: root/dovetail/api/app/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'dovetail/api/app/utils.py')
-rw-r--r--dovetail/api/app/utils.py21
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