forked from PanDAWMS/pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
60 lines (47 loc) · 1.55 KB
/
build.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
from commands import getstatusoutput
from optparse import OptionParser
import os
def argumentParser():
""" """
filename = ""
url = ""
parser = OptionParser()
parser.add_option("-t", "--type", dest="type",
help="Build type (dev|rc)", metavar="TYPE")
parser.add_option("-d", "--destination", dest="url",
help="Destination URL", metavar="URL")
# options = {'type': 'dev'}
(options, args) = parser.parse_args()
if options.type == "dev" or not options.type:
print "Building dev pilot"
filename = "pilotcode-dev.tar.gz"
elif options.type == "rc":
print "Building rc pilot"
filename = "pilotcode-rc.tar.gz"
else:
print "Unknown build type: %s" % options.type
if options.url:
url = options.url
else:
url = "[email protected]:www/."
return filename, url
def executeCommand(cmd, dump=True):
""" """
print "Executing command: %s" % (cmd)
(ec, output) = getstatusoutput(cmd)
if ec != 0:
print "ec = %d" % (ec)
if dump:
print output
return ec
(filename, url) = argumentParser()
if filename != "":
if os.path.exists("PILOT_INITDIR"):
ec = executeCommand("rm -f PILOT_INITDIR", dump=False)
ec = executeCommand("rm -f *.tar.gz *.pyc", dump=False)
if ec == 0:
ec = executeCommand("tar cvfz %s *" % (filename), dump=False)
if ec == 0:
ec = executeCommand("scp %s %s" % (filename, url))
if ec == 0:
print "Done"