|
1 #!/usr/bin/python |
|
2 # This Source Code Form is subject to the terms of the Mozilla Public |
|
3 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 |
|
6 |
|
7 from optparse import OptionParser |
|
8 from datetime import datetime |
|
9 import time |
|
10 import sys |
|
11 import os |
|
12 |
|
13 o = OptionParser() |
|
14 o.add_option("--buildid", dest="buildid") |
|
15 o.add_option("--print-buildid", action="store_true", dest="print_buildid") |
|
16 o.add_option("--print-timestamp", action="store_true", dest="print_timestamp") |
|
17 o.add_option("--sourcestamp", dest="sourcestamp") |
|
18 o.add_option("--sourcerepo", dest="sourcerepo") |
|
19 |
|
20 (options, args) = o.parse_args() |
|
21 |
|
22 if options.print_timestamp: |
|
23 print int(time.time()) |
|
24 sys.exit(0) |
|
25 |
|
26 if options.print_buildid: |
|
27 print datetime.now().strftime('%Y%m%d%H%M%S') |
|
28 sys.exit(0) |
|
29 |
|
30 if not options.buildid: |
|
31 print >>sys.stderr, "--buildid is required" |
|
32 sys.exit(1) |
|
33 |
|
34 (milestoneFile,) = args |
|
35 for line in open(milestoneFile, 'r'): |
|
36 if line[0] == '#': |
|
37 continue |
|
38 |
|
39 line = line.strip() |
|
40 if line == '': |
|
41 continue |
|
42 |
|
43 milestone = line |
|
44 |
|
45 print """[Build] |
|
46 BuildID=%s |
|
47 Milestone=%s""" % (options.buildid, milestone) |
|
48 if options.sourcestamp: |
|
49 print "SourceStamp=%s" % options.sourcestamp |
|
50 if options.sourcerepo: |
|
51 print "SourceRepository=%s" % options.sourcerepo |