michael@0: #!/usr/bin/python michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: michael@0: from optparse import OptionParser michael@0: from datetime import datetime michael@0: import time michael@0: import sys michael@0: import os michael@0: michael@0: o = OptionParser() michael@0: o.add_option("--buildid", dest="buildid") michael@0: o.add_option("--print-buildid", action="store_true", dest="print_buildid") michael@0: o.add_option("--print-timestamp", action="store_true", dest="print_timestamp") michael@0: o.add_option("--sourcestamp", dest="sourcestamp") michael@0: o.add_option("--sourcerepo", dest="sourcerepo") michael@0: michael@0: (options, args) = o.parse_args() michael@0: michael@0: if options.print_timestamp: michael@0: print int(time.time()) michael@0: sys.exit(0) michael@0: michael@0: if options.print_buildid: michael@0: print datetime.now().strftime('%Y%m%d%H%M%S') michael@0: sys.exit(0) michael@0: michael@0: if not options.buildid: michael@0: print >>sys.stderr, "--buildid is required" michael@0: sys.exit(1) michael@0: michael@0: (milestoneFile,) = args michael@0: for line in open(milestoneFile, 'r'): michael@0: if line[0] == '#': michael@0: continue michael@0: michael@0: line = line.strip() michael@0: if line == '': michael@0: continue michael@0: michael@0: milestone = line michael@0: michael@0: print """[Build] michael@0: BuildID=%s michael@0: Milestone=%s""" % (options.buildid, milestone) michael@0: if options.sourcestamp: michael@0: print "SourceStamp=%s" % options.sourcestamp michael@0: if options.sourcerepo: michael@0: print "SourceRepository=%s" % options.sourcerepo