forked from tabakg/quantum_state_diffusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_builds.py
47 lines (39 loc) · 1.33 KB
/
run_builds.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
#!/usr/bin/env python
# This script will automatically make a trivial change to the spec file,
# and push to github once every 10 minutes to build a new image
# This script will be added (commit) to the repo at the end,
# after we disable builds
import os
import sys
import time
def write_file(filename,content,mode="w"):
'''write_file will open a file, "filename" and write content, "content"
and properly close the file
'''
with open(filename,mode) as filey:
filey.writelines(content)
return filename
def read_file(filename,mode="r"):
'''write_file will open a file, "filename" and write content, "content"
and properly close the file
'''
with open(filename,mode) as filey:
content = filey.readlines()
return content
specfile = read_file('Singularity')
delay_minutes = 30
# We will alternate the last echo line to change the build file
last_lines = [' echo "To run, ./qsd.img --help"\n',' echo "To run, ./qsd.img --help"\n']
idx = 1
iters = range(0,100)
for i in iters:
print('Running iteration %s' %(i))
specfile[-1] = last_lines[idx]
write_file('Singularity',specfile)
os.system('git commit -a -m "pushing image %s"' %(i))
if idx == 0:
idx = 1
else:
idx = 0
os.system('git push origin master')
time.sleep(60*delay_minutes) # sleep 10 minutes