#!/usr/bin/python3
# Copyright 2010 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
#
# Test script for manual use only.  Exercises the
# TranslationTemplatesBuildManager through XMLRPC.

from __future__ import print_function

import sys

from six.moves.xmlrpc_client import ServerProxy

if len(sys.argv) != 2:
    print("Usage: %s <chroot_sha1>" % sys.argv[0])
    print("Where <chroot_sha1> is the SHA1 of the chroot tarball to use.")
    print("The chroot tarball must be in the local Librarian.")
    print("See https://dev.launchpad.net/Soyuz/HowToUseSoyuzLocally")
    sys.exit(1)

chroot_sha1 = sys.argv[1]

proxy = ServerProxy('http://localhost:8221/rpc')
print(proxy.info())
print(proxy.status())
buildid = '1-2'
build_type = 'translation-templates'
filemap = {}
args = {'branch_url': 'no-branch-here-sorry'}
print(proxy.build(buildid, build_type, chroot_sha1, filemap, args))
