blob: 9f35ee037c9255b25d7a3b85bc28693163820d18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import json
import os
class Utils(object):
@staticmethod
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
@staticmethod
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
|