33 __cfp_json_path__ =
"/../cFp.json"
34 __env_file_name__ =
"/this_machine_env.sh"
36 __mandatory_keys__ = [
'cFpMOD',
'usedRoleDir',
'usedRoleDir2',
'cFpSRAtype',
'roleName1',
'roleName2']
37 __optional_keys__ = [
'cFa',
'additional_lines']
40 __replace_regex__ = []
42 __match_regex__.append(
"##ROOTDIR##")
43 __replace_regex__.append(
"abs_path")
45 __match_regex__.append(
"##MOD##")
46 __replace_regex__.append(
"cFpMOD")
48 __match_regex__.append(
"##SRA##")
49 __replace_regex__.append(
"cFpSRAtype")
51 __match_regex__.append(
"##DIR1##")
52 __replace_regex__.append(
"usedRoleDir")
54 __match_regex__.append(
"##DIR2##")
55 __replace_regex__.append(
"usedRoleDir2")
57 __match_regex__.append(
"##ROLE1##")
58 __replace_regex__.append(
"roleName1")
60 __match_regex__.append(
"##ROLE2##")
61 __replace_regex__.append(
"roleName2")
65 me_abs = os.path.realpath(__file__)
66 cfp_json_file = me_abs + __cfp_json_path__
67 print(
"The project describing file {} is invalid.\n{}\n".format(cfp_json_file, msg) +
68 "Please use 'cFBuild update' to fix this project setup.")
73 me_abs = os.path.dirname(os.path.realpath(__file__))
74 cfp_json_file = me_abs + __cfp_json_path__
75 with open(cfp_json_file,
'r')
as json_file:
76 data = json.load(json_file)
78 root_abs = os.path.realpath(me_abs+
"/../")
79 data[
'abs_path'] = root_abs
81 for e
in __mandatory_keys__:
82 if e
not in data.keys():
85 env_file = me_abs + __env_file_name__
88 if os.path.exists(env_file):
89 json_time = os.path.getmtime(cfp_json_file)
90 env_time = os.path.getmtime(env_file)
92 if env_time >= json_time:
96 with open(me_abs +
"/machine_env.template",
"r")
as input, open(env_file,
"w+")
as outfile:
98 for i
in range(0, len(__match_regex__)):
99 out = re.sub(re.escape(__match_regex__[i]), data[__replace_regex__[i]], out)
101 if 'additional_lines' in data.keys():
103 for e
in data[
'additional_lines']:
104 new_line =
str(e) +
'\n'
110 os.system(
"chmod +x {}".format(env_file))
113 if __name__ ==
'__main__':
def print_incomplete(msg="")