summaryrefslogtreecommitdiffstats
path: root/extensions/TryAutoLand/bin/TryAutoLand.updateStatus.pl
blob: 4a8f92089acb8a5d6be943c090d075cdfaab97af (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
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl -w
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.

use XMLRPC::Lite;
use Data::Dumper;
use HTTP::Cookies;

###################################
# Need to login first             #
###################################

my $username = shift;
my $password = shift;

my $cookie_jar = new HTTP::Cookies( file => "/tmp/lwp_cookies.dat" );

my $rpc = new XMLRPC::Lite;

$rpc->proxy('http://fedora/726193/xmlrpc.cgi');

$rpc->encoding('UTF-8');

$rpc->transport->cookie_jar($cookie_jar);

my $call = $rpc->call( 'User.login',
    { login => $username, password => $password } );

if ( $call->faultstring ) {
    print $call->faultstring . "\n";
    exit;
}

# Save the cookies in the cookie file
$rpc->transport->cookie_jar->extract_cookies(
    $rpc->transport->http_response );
$rpc->transport->cookie_jar->save;

print "Successfully logged in.\n";

###################################
# Main call here                  #
###################################

my $attach_id = shift;
my $action    = shift;
my $status    = shift;

$call = $rpc->call('TryAutoLand.update', 
                   { attach_id => $attach_id, action => $action, status => $status });

my $result = "";
if ( $call->faultstring ) {
    print $call->faultstring . "\n";
    exit;
}
else {
   $result = $call->result;
}

print Dumper($result);