-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci_agent_osx.py
64 lines (59 loc) · 1.71 KB
/
ci_agent_osx.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
import subprocess
import shutil
import re
import sys
import time
import imp
def build():
import build_osx
imp.reload(build_osx)
build_osx.main()
pass
def upload(revision):
release_filename = "build/HourglassIIr"+str(revision)+".dmg"
#rename file
shutil.copy(
"build/HourglassII.dmg",
release_filename)
#scp file
subprocess.call(
["scp"]
+ ["-B"]
+ ["-i","/Users/evan/.ssh/id_dsa"]
+ [release_filename]
+ ["evanwallace,[email protected]"
+":/home/frs/project/h/ho/hourglassii/Release/OSX/"])
#Attempts to update to HEAD
def svn_up():
print("Updating...")
output = subprocess.check_output(["svn"] + ["up"])
print("Updated to revision",
re.search(r"^((At revision )|(Updated to revision ))([0-9]*)\.$", output.decode("UTF-8"), re.MULTILINE).group(4))
#returns the current revision of the working copy
def svnversion():
return int(
re.search(
r"Last Changed Rev: ([0-9]*)",
subprocess.check_output(["svn", "info"]).decode("UTF-8")).group(1))
def main():
try:
current_revision = svnversion()
svn_up()
revision = svnversion()
if revision > current_revision:
print("Building revision", revision, "...")
build()
print("Finished building, uploading...")
upload(revision)
shutil.rmtree("build")
print("Finished uploading.")
else:
print("Going to sleep.")
time.sleep(60)
except (KeyboardInterrupt, SystemExit):
raise
except:
print("Unexpected error:", sys.exc_info())
time.sleep(1)
if __name__ == "__main__":
main()