#!/usr/bin/python

# Copyright (C) 2011  Canonical Ltd.
# Author: Colin Watson <cjwatson@ubuntu.com>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
from optparse import OptionParser

# See isotracker.py for setup instructions.
from isotracker import ISOTracker


def main():
    parser = OptionParser(usage="Usage: %prog [options] product version")

    parser.add_option('-m', '--milestone',
                      help='post to MILESTONE rather than the default')
    parser.add_option('-n', '--note', default="",
                      help='set the note field on the build')
    parser.add_option('-t', '--target', help='post to an alternate QATracker')

    options, args = parser.parse_args()
    if len(args) < 2:
        parser.error("product and version arguments required")

    isotracker = ISOTracker(target=options.target)
    if options.milestone is None:
        options.milestone = isotracker.default_milestone()

    isotracker.post_build(args[0], args[1], milestone=options.milestone,
                          note=options.note)


if __name__ == '__main__':
    sys.exit(main())
