summaryrefslogtreecommitdiffstats
path: root/server/testclient_sendreportfile
blob: fe617ad7e3249bcfeb378d0f318c6b886b0bcc73 (plain)
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
#!/usr/bin/python -tt
#
#   testclient_sendfile.py
#   XML-RPC test client which just sends an XML file to the given rteval server
#
#   Copyright 2009      David Sommerseth <davids@redhat.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; either version 2 of the License, or
#   (at your option) any later version.
#
#   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, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
#   For the avoidance of doubt the "preferred form" of this code is one which
#   is in an open unpatent encumbered format. Where cryptographic key signing
#   forms part of the process of creating an executable the information
#   including keys needed to generate an equivalently functional executable
#   are deemed to be part of the source code.
#

import sys
import libxml2
from optparse import OptionParser

sys.path.append('../rteval')
import rtevalclient

if __name__ == '__main__':
    parser = OptionParser(version="%prog v0.1")

    parser.add_option("-r", "--report", action="store", dest="report", default="summary.xml",
                      help="Which XML report to send to the XML-RPC server  (default: %default)",
                      metavar="FILE")
    parser.add_option("-X", "--xmlrpc-submit", dest="xmlrpchost", default="localhost:65432",
                      help="Hostname to the XML-RPC server to send the data (default: %default)",
                      metavar="HOST[:PORT]")

    (opts, args) = parser.parse_args()

    d = libxml2.parseFile(opts.report)

    client = rtevalclient.rtevalclient("http://%s/rteval/API1/" % opts.xmlrpchost)

    status = client.SendReport(d)
    print "SendReport(xmlDoc): %s" % status
else:
    raise Exception, "This is a standalone program, not a module to be imported"