forked from imitator-model-checker/imitator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_build_info.py
118 lines (95 loc) · 3.01 KB
/
gen_build_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/python
#************************************************************
#
# IMITATOR
#
# Increment the build number
#
# Etienne Andre
#
# Laboratoire d'Informatique de Paris Nord
# Universite Paris 13, Sorbonne Paris Cite, France
#
# Created : 2013/09/26
# Last modified: 2014/03/22
#************************************************************
import os
from time import gmtime, strftime
#************************************************************
# CONSTANTS
#************************************************************
build_number_file_name = "build_number.txt"
ml_file_name = "src/BuildInfo.ml"
mli_file_name = "src/BuildInfo.mli"
print "Python is now handling build information..."
#************************************************************
# GET CURRENT BUILD TIME
#************************************************************
current_build_date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) + " UTC"
# Just for generation date
date_str = strftime("%Y-%m-%d", gmtime())
year_str = strftime("%Y", gmtime())
#************************************************************
# GET CURRENT BUILD NUMBER
#************************************************************
# Open file in read mode
file_handler = open(build_number_file_name)
# Read content
content = file_handler.read()
# Close file
file_handler.close()
# Convert to int
current_build = int(content)
# Close file
file_handler.close()
#************************************************************
# CREATES OCAML FILES
#************************************************************
def write_to_file(file_name, content):
# Open and create if non existing
if os.path.exists(file_name):
file_handler = file(file_name, "r+")
else:
file_handler = file(file_name, "w")
# Write content
file_handler.write(content)
# Close
file_handler.close()
# .ml
write_to_file(ml_file_name, """
(*****************************************************************
*
* IMITATOR
*
* Laboratoire Specification et Verification (ENS Cachan & CNRS, France)
* Universite Paris 13, Sorbonne Paris Cite, LIPN (France)
*
* Author: python script
*
* Automatically generated: """ + date_str + """
*
****************************************************************)
let build_number = \"""" + str (current_build) + """\"
let build_time = \"""" + current_build_date + """\"
let build_year = \"""" + year_str + """\"
""")
# .mli
write_to_file(mli_file_name, """
(*****************************************************************
*
* IMITATOR
*
* Laboratoire Specification et Verification (ENS Cachan & CNRS, France)
* Universite Paris 13, Sorbonne Paris Cite, LIPN (France)
*
* Author: python script
*
* Automatically generated: """ + date_str + """
*
****************************************************************)
val build_number : string
val build_time : string
val build_year : string
""")
print "Files '" + ml_file_name + "' and '" + mli_file_name + "' successfully generated."
exit(0)