Created
November 17, 2010 21:02
-
-
Save milmazz/704082 to your computer and use it in GitHub Desktop.
Trac tickets queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use Net::Trac; | |
use Class::CSV; | |
# Estableciendo la conexion a la instancia remota de Trac | |
my $trac = Net::Trac::Connection->new( | |
url => 'http://trac.example.com/project', | |
user => 'user', | |
password => 'password' | |
); | |
# Construccion del objecto CSV y definicion de opciones | |
my $csv = Class::CSV->new( | |
fields => [qw/ticket sumario estado responsable/], | |
line_separator => "\r\n", | |
csv_xs_options => { binary => 1, } # Manejo de caracteres non-ASCII | |
); | |
# Nos aseguramos que el inicio de sesion haya sido exitoso | |
if ( $trac->ensure_logged_in ) { | |
my $ticket = Net::Trac::Ticket->new( connection => $trac ); | |
# Consultamos cada uno de los tickets indicados en el fichero de entrada | |
while ( my $line = <> ) { | |
chomp($line); | |
if ( $line =~ m/^#\d+$/ ) { | |
$line =~ s/^#(\d+)$/$1/; | |
$ticket->load($line); | |
$csv->add_line( | |
{ | |
ticket => $ticket->id, | |
sumario => $ticket->summary, | |
estado => $ticket->status, | |
responsable => $ticket->owner | |
} | |
); | |
} | |
else { | |
print "[INFO] La linea no cumple el formato requerido: $line\n"; | |
} | |
} | |
$csv->print(); | |
} | |
else { | |
print "No se pudieron asegurar las credenciales"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment