forked from gofed/gofed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwizard.py
94 lines (74 loc) · 2.31 KB
/
wizard.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
# TODO
# [ ] - add check I am in a package folder
from modules.Tools import PhaseMethods
import optparse
from modules.Config import Config
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option(
"", "", "--scratch", dest="scratch", action = "store_true", default = False,
help = "Start from scratch build"
)
parser.add_option(
"", "", "--push", dest="push", action = "store_true", default = False,
help = "Start from push"
)
parser.add_option(
"", "", "--build", dest="build", action = "store_true", default = False,
help = "Start from build"
)
parser.add_option(
"", "", "--update", dest="update", action = "store_true", default = False,
help = "Start from update"
)
parser.add_option(
"", "", "--dry", dest="dry", action = "store_true", default = False,
help = "Use dry mode"
)
parser.add_option(
"", "", "--verbose", dest="debug", action = "store_true", default = False,
help = "Be more verbose"
)
parser.add_option(
"", "", "--master", dest="master", action = "store_true", default = False,
help = "use only master branche. If --branches or --ebranches option use, --master has higher priority"
)
parser.add_option(
"", "", "--branches", dest="branches", default = "",
help = "use only listed branches"
)
parser.add_option(
"", "", "--ebranches", dest="ebranches", default = "",
help = "use all branches except listed ones"
)
options, args = parser.parse_args()
pm = PhaseMethods(dry=options.dry, debug=options.debug)
# check branches
if options.branches:
branches = Config().getBranches()
sb = filter(lambda b: b != "", options.branches.split(","))
for b in sb:
if b not in branches:
print "%s branch not in common branches" % b
exit(1)
pm.setBranches(sorted(sb))
if options.ebranches:
branches = Config().getBranches()
sb = filter(lambda b: b != "", options.ebranches.split(","))
branches = list(set(branches) - set(sb))
pm.setBranches(sorted(branches))
if options.master:
branches = ["master"]
pm.setBranches(branches)
if options.scratch:
pm.startWithScratchBuild()
elif options.push:
pm.startWithPush()
elif options.build:
pm.startWithBuild()
elif options.update:
pm.startWithUpdate()
else:
print "Missing options, run --help."
exit(1)
pm.run()